Ohm-Management - Projektarbeit B-ME
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.

_copyObject.js 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var assignValue = require('./_assignValue'),
  2. baseAssignValue = require('./_baseAssignValue');
  3. /**
  4. * Copies properties of `source` to `object`.
  5. *
  6. * @private
  7. * @param {Object} source The object to copy properties from.
  8. * @param {Array} props The property identifiers to copy.
  9. * @param {Object} [object={}] The object to copy properties to.
  10. * @param {Function} [customizer] The function to customize copied values.
  11. * @returns {Object} Returns `object`.
  12. */
  13. function copyObject(source, props, object, customizer) {
  14. var isNew = !object;
  15. object || (object = {});
  16. var index = -1,
  17. length = props.length;
  18. while (++index < length) {
  19. var key = props[index];
  20. var newValue = customizer
  21. ? customizer(object[key], source[key], key, object, source)
  22. : undefined;
  23. if (newValue === undefined) {
  24. newValue = source[key];
  25. }
  26. if (isNew) {
  27. baseAssignValue(object, key, newValue);
  28. } else {
  29. assignValue(object, key, newValue);
  30. }
  31. }
  32. return object;
  33. }
  34. module.exports = copyObject;