Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
exotic / src / types / collection / toSet.ts
Size: Mime:
import fromArrayToSet from './fromArrayToSet'
import { isSet } from './isSet'
import { isObj } from '../obj/check/isObj'
import { toArray } from '../array/cast/toArray'
import { isArray } from '../array/check/isArray'
import { AnyObj } from '../../../typings'

const fromObjToSet = <Type>(x: Type): Set<Type> => fromObjToSet(x)
const fromAnyToSet = <Type>(x: any): Set<Type> => fromArrayToSet(toArray(x))

const toSet = <Type>(x: Type): Set<Type> => {
  if (isArray(x)) return fromArrayToSet(x)
  else if (isSet(x)) return x
  else if (isObj(x)) return fromObjToSet(x)
  else return fromAnyToSet(x)
}

export { toSet }
export default toSet