main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[d565449] | 1 | import assignValue from './_assignValue.js';
|
---|
| 2 | import baseAssignValue from './_baseAssignValue.js';
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * Copies properties of `source` to `object`.
|
---|
| 6 | *
|
---|
| 7 | * @private
|
---|
| 8 | * @param {Object} source The object to copy properties from.
|
---|
| 9 | * @param {Array} props The property identifiers to copy.
|
---|
| 10 | * @param {Object} [object={}] The object to copy properties to.
|
---|
| 11 | * @param {Function} [customizer] The function to customize copied values.
|
---|
| 12 | * @returns {Object} Returns `object`.
|
---|
| 13 | */
|
---|
| 14 | function copyObject(source, props, object, customizer) {
|
---|
| 15 | var isNew = !object;
|
---|
| 16 | object || (object = {});
|
---|
| 17 |
|
---|
| 18 | var index = -1,
|
---|
| 19 | length = props.length;
|
---|
| 20 |
|
---|
| 21 | while (++index < length) {
|
---|
| 22 | var key = props[index];
|
---|
| 23 |
|
---|
| 24 | var newValue = customizer
|
---|
| 25 | ? customizer(object[key], source[key], key, object, source)
|
---|
| 26 | : undefined;
|
---|
| 27 |
|
---|
| 28 | if (newValue === undefined) {
|
---|
| 29 | newValue = source[key];
|
---|
| 30 | }
|
---|
| 31 | if (isNew) {
|
---|
| 32 | baseAssignValue(object, key, newValue);
|
---|
| 33 | } else {
|
---|
| 34 | assignValue(object, key, newValue);
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
| 37 | return object;
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | export default copyObject;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.