object/defaults.js

  1. import { defaults as _defaults } from 'lodash/fp'
  2. import { applyLodashFp } from 'util/applyLodashFp'
  3. /**
  4. * Replaces by an object assigning own and inherited enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to <code>undefined</code>.<br >
  5. * Source objects are applied from left to right. Once a property is set, additional values of the same property are ignored.
  6. * @function
  7. * @memberof object
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {...Object} [sources] The source objects.
  11. * @return {Object} Returns the updated object.
  12. * @example defaults({ nested: { a: 1, b: 2 } }, 'nested', { b: 3, c: 4 }) // => { nested: { a:1, b: 2, c: 4 } }
  13. * @see {@link https://lodash.com/docs#defaults|lodash.defaults} for more information.
  14. * @since 1.0.0
  15. */
  16. const defaults = applyLodashFp(_defaults, { arity: 2 })
  17. export { defaults }