wishthis/node_modules/object-assign/index.js

40 lines
817 B
JavaScript
Raw Normal View History

2022-01-21 08:28:41 +00:00
'use strict';
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
2023-08-17 09:47:40 +00:00
function ToObject(val) {
if (val == null) {
2022-01-21 08:28:41 +00:00
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
2023-08-17 09:47:40 +00:00
function ownEnumerableKeys(obj) {
var keys = Object.getOwnPropertyNames(obj);
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
if (Object.getOwnPropertySymbols) {
keys = keys.concat(Object.getOwnPropertySymbols(obj));
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
return keys.filter(function (key) {
return propIsEnumerable.call(obj, key);
});
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
module.exports = Object.assign || function (target, source) {
2022-01-21 08:28:41 +00:00
var from;
2023-08-17 09:47:40 +00:00
var keys;
var to = ToObject(target);
2022-01-21 08:28:41 +00:00
for (var s = 1; s < arguments.length; s++) {
2023-08-17 09:47:40 +00:00
from = arguments[s];
keys = ownEnumerableKeys(Object(from));
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
for (var i = 0; i < keys.length; i++) {
to[keys[i]] = from[keys[i]];
2022-01-21 08:28:41 +00:00
}
}
return to;
};