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.

52 lines
1.8 KiB

4 years ago
  1. /**
  2. * lodash 3.1.1 (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 bindCallback = require('lodash._bindcallback'),
  10. isIterateeCall = require('lodash._isiterateecall'),
  11. restParam = require('lodash.restparam');
  12. /**
  13. * Creates a function that assigns properties of source object(s) to a given
  14. * destination object.
  15. *
  16. * **Note:** This function is used to create `_.assign`, `_.defaults`, and `_.merge`.
  17. *
  18. * @private
  19. * @param {Function} assigner The function to assign values.
  20. * @returns {Function} Returns the new assigner function.
  21. */
  22. function createAssigner(assigner) {
  23. return restParam(function(object, sources) {
  24. var index = -1,
  25. length = object == null ? 0 : sources.length,
  26. customizer = length > 2 ? sources[length - 2] : undefined,
  27. guard = length > 2 ? sources[2] : undefined,
  28. thisArg = length > 1 ? sources[length - 1] : undefined;
  29. if (typeof customizer == 'function') {
  30. customizer = bindCallback(customizer, thisArg, 5);
  31. length -= 2;
  32. } else {
  33. customizer = typeof thisArg == 'function' ? thisArg : undefined;
  34. length -= (customizer ? 1 : 0);
  35. }
  36. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  37. customizer = length < 3 ? undefined : customizer;
  38. length = 1;
  39. }
  40. while (++index < length) {
  41. var source = sources[index];
  42. if (source) {
  43. assigner(object, source, customizer);
  44. }
  45. }
  46. return object;
  47. });
  48. }
  49. module.exports = createAssigner;