You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * lodash 3.1.2 (Custom Build) <https://lodash.com/>
  3. * Build: `lodash modern modularize exports="npm" -o ./`
  4. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  7. * Available under MIT license <https://lodash.com/license>
  8. */
  9. var assign = require('lodash.assign'),
  10. restParam = require('lodash.restparam');
  11. /**
  12. * Used by `_.defaults` to customize its `_.assign` use.
  13. *
  14. * @private
  15. * @param {*} objectValue The destination object property value.
  16. * @param {*} sourceValue The source object property value.
  17. * @returns {*} Returns the value to assign to the destination object.
  18. */
  19. function assignDefaults(objectValue, sourceValue) {
  20. return objectValue === undefined ? sourceValue : objectValue;
  21. }
  22. /**
  23. * Creates a `_.defaults` or `_.defaultsDeep` function.
  24. *
  25. * @private
  26. * @param {Function} assigner The function to assign values.
  27. * @param {Function} customizer The function to customize assigned values.
  28. * @returns {Function} Returns the new defaults function.
  29. */
  30. function createDefaults(assigner, customizer) {
  31. return restParam(function(args) {
  32. var object = args[0];
  33. if (object == null) {
  34. return object;
  35. }
  36. args.push(customizer);
  37. return assigner.apply(undefined, args);
  38. });
  39. }
  40. /**
  41. * Assigns own enumerable properties of source object(s) to the destination
  42. * object for all destination properties that resolve to `undefined`. Once a
  43. * property is set, additional values of the same property are ignored.
  44. *
  45. * **Note:** This method mutates `object`.
  46. *
  47. * @static
  48. * @memberOf _
  49. * @category Object
  50. * @param {Object} object The destination object.
  51. * @param {...Object} [sources] The source objects.
  52. * @returns {Object} Returns `object`.
  53. * @example
  54. *
  55. * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
  56. * // => { 'user': 'barney', 'age': 36 }
  57. */
  58. var defaults = createDefaults(assign, assignDefaults);
  59. module.exports = defaults;