2020-08-26 01:57:08 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// modified from https://github.com/es-shims/es6-shim
|
2022-11-10 11:43:16 +01:00
|
|
|
var objectKeys = require('object-keys');
|
2020-08-26 01:57:08 +02:00
|
|
|
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) {
|
2022-11-10 11:43:16 +01:00
|
|
|
if (target == null) { throw new TypeError('target must be an object'); }
|
|
|
|
var to = toObject(target); // step 1
|
|
|
|
if (arguments.length === 1) {
|
|
|
|
return to; // step 2
|
|
|
|
}
|
|
|
|
for (var s = 1; s < arguments.length; ++s) {
|
|
|
|
var from = toObject(arguments[s]); // step 3.a.i
|
|
|
|
|
|
|
|
// step 3.a.ii:
|
|
|
|
var keys = objectKeys(from);
|
2020-08-26 01:57:08 +02:00
|
|
|
var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols);
|
|
|
|
if (getSymbols) {
|
2022-11-10 11:43:16 +01:00
|
|
|
var syms = getSymbols(from);
|
|
|
|
for (var j = 0; j < syms.length; ++j) {
|
|
|
|
var key = syms[j];
|
|
|
|
if ($propIsEnumerable(from, key)) {
|
|
|
|
$push(keys, key);
|
2020-08-26 01:57:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-10 11:43:16 +01:00
|
|
|
|
|
|
|
// step 3.a.iii:
|
|
|
|
for (var i = 0; i < keys.length; ++i) {
|
|
|
|
var nextKey = keys[i];
|
|
|
|
if ($propIsEnumerable(from, nextKey)) { // step 3.a.iii.2
|
|
|
|
var propValue = from[nextKey]; // step 3.a.iii.2.a
|
|
|
|
to[nextKey] = propValue; // step 3.a.iii.2.b
|
2020-08-26 01:57:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-10 11:43:16 +01:00
|
|
|
|
|
|
|
return to; // step 4
|
2020-08-26 01:57:08 +02:00
|
|
|
};
|