2020-08-26 01:57:08 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// modified from https://github.com/es-shims/es6-shim
|
|
|
|
var keys = require('object-keys');
|
|
|
|
var canBeObject = function (obj) {
|
|
|
|
return typeof obj !== 'undefined' && obj !== null;
|
|
|
|
};
|
|
|
|
var hasSymbols = require('has-symbols/shams')();
|
2021-02-26 04:58:33 +01:00
|
|
|
var callBound = require('call-bind/callBound');
|
2020-08-26 01:57:08 +02:00
|
|
|
var toObject = Object;
|
2021-02-26 04:58:33 +01:00
|
|
|
var $push = callBound('Array.prototype.push');
|
|
|
|
var $propIsEnumerable = callBound('Object.prototype.propertyIsEnumerable');
|
2020-08-26 01:57:08 +02:00
|
|
|
var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null;
|
|
|
|
|
2021-02-26 04:58:33 +01:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
2020-08-26 01:57:08 +02:00
|
|
|
module.exports = function assign(target, source1) {
|
|
|
|
if (!canBeObject(target)) { throw new TypeError('target must be an object'); }
|
|
|
|
var objTarget = toObject(target);
|
|
|
|
var s, source, i, props, syms, value, key;
|
|
|
|
for (s = 1; s < arguments.length; ++s) {
|
|
|
|
source = toObject(arguments[s]);
|
|
|
|
props = keys(source);
|
|
|
|
var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols);
|
|
|
|
if (getSymbols) {
|
|
|
|
syms = getSymbols(source);
|
|
|
|
for (i = 0; i < syms.length; ++i) {
|
|
|
|
key = syms[i];
|
2021-02-26 04:58:33 +01:00
|
|
|
if ($propIsEnumerable(source, key)) {
|
|
|
|
$push(props, key);
|
2020-08-26 01:57:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < props.length; ++i) {
|
|
|
|
key = props[i];
|
|
|
|
value = source[key];
|
2021-02-26 04:58:33 +01:00
|
|
|
if ($propIsEnumerable(source, key)) {
|
2020-08-26 01:57:08 +02:00
|
|
|
objTarget[key] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return objTarget;
|
|
|
|
};
|