Repository URL to install this package:
Version:
6.0.4 ▾
|
// // // --- export default exports
// import { curry2, recurse, merge } from 'chain'
// import { Typed, ROOT, isNative, get, set } from 'exotic'
// // import get from 'lodash/get'
// // import { get, set } from 'lodash'
//
// // import { toUnsigned32 } from 'exotic'
// // // import toUnsigned32 from '../../../modules/exotic/types/primitive/number/cast/toUint32'
// // toUnsigned32()
//
// const toDefault = curry2((shape, obj) => {
// let transformed = obj
//
// const traverseInstance = recurse(obj)
// traverseInstance.forEach((x, key, traverser) => {
// // ignore first
// if (!key) return
//
// const { path } = traverser
//
// let evolution = get(shape, path)
//
// // when we have an evolution, use it
// if (evolution !== undefined) {
// // get type
// const EvolutionType = Typed.findAll(evolution)[0]
// if (isNative(evolution)) {
// // if no default value, coerce to default
// evolution = EvolutionType.coerce
// } else {
// // with a default,
// // check type,
// // if not that type,
// // default it (would've autocoerced before this step)
// const defaulValue = evolution
// evolution = x => (EvolutionType.is(x) ? x : defaulValue)
// }
//
// set(transformed, path, evolution(x))
// }
// })
//
// return transformed
// })
//
// ROOT.toDefault = toDefault
//
// if (typeof window === 'object') {
// window.toDefault = toDefault
// }
// export { toDefault }