Repository URL to install this package:
|
Version:
2.0.1 ▾
|
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