@newdash/newdash
Version:
javascript/typescript utility library
40 lines (39 loc) • 1.34 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assignValue_1 = __importDefault(require("./assignValue"));
const baseAssignValue_1 = __importDefault(require("./baseAssignValue"));
/**
* Copies properties of `source` to `object`.
*
* @private
* @param source The object to copy properties from.
* @param props The property identifiers to copy.
* @param object The object to copy properties to.
* @param customizer The function to customize copied values.
* @returns Returns `object`.
*/
function copyObject(source, props, object, customizer) {
var isNew = !object;
object || (object = {});
var index = -1, length = props.length;
while (++index < length) {
var key = props[index];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
: undefined;
if (newValue === undefined) {
newValue = source[key];
}
if (isNew) {
(0, baseAssignValue_1.default)(object, key, newValue);
}
else {
(0, assignValue_1.default)(object, key, newValue);
}
}
return object;
}
exports.default = copyObject;