assignIn.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * lodash 4.0.1 (Custom Build) <https://lodash.com/>
  3. * Build: `lodash modularize exports="es" include="clone,extend,isPlainObject,isObject,isArray,last,isEqual" --development --output src/lib/lodash`
  4. * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
  5. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6. * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  7. * Available under MIT license <https://lodash.com/license>
  8. */
  9. import copyObject from './internal/copyObject';
  10. import createAssigner from './internal/createAssigner';
  11. import keysIn from './keysIn';
  12. /**
  13. * This method is like `_.assign` except that it iterates over own and
  14. * inherited source properties.
  15. *
  16. * **Note:** This method mutates `object`.
  17. *
  18. * @static
  19. * @memberOf _
  20. * @alias extend
  21. * @category Object
  22. * @param {Object} object The destination object.
  23. * @param {...Object} [sources] The source objects.
  24. * @returns {Object} Returns `object`.
  25. * @example
  26. *
  27. * function Foo() {
  28. * this.b = 2;
  29. * }
  30. *
  31. * function Bar() {
  32. * this.d = 4;
  33. * }
  34. *
  35. * Foo.prototype.c = 3;
  36. * Bar.prototype.e = 5;
  37. *
  38. * _.assignIn({ 'a': 1 }, new Foo, new Bar);
  39. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
  40. */
  41. var assignIn = createAssigner(function(object, source) {
  42. copyObject(source, keysIn(source), object);
  43. });
  44. export default assignIn;