12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 'use strict';
- var objectKeys = require('object-keys');
- var hasSymbols = require('has-symbols/shams')();
- var callBound = require('call-bind/callBound');
- var toObject = Object;
- var $push = callBound('Array.prototype.push');
- var $propIsEnumerable = callBound('Object.prototype.propertyIsEnumerable');
- var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null;
- module.exports = function assign(target, source1) {
- if (target == null) { throw new TypeError('target must be an object'); }
- var to = toObject(target);
- if (arguments.length === 1) {
- return to;
- }
- for (var s = 1; s < arguments.length; ++s) {
- var from = toObject(arguments[s]);
-
- var keys = objectKeys(from);
- var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols);
- if (getSymbols) {
- var syms = getSymbols(from);
- for (var j = 0; j < syms.length; ++j) {
- var key = syms[j];
- if ($propIsEnumerable(from, key)) {
- $push(keys, key);
- }
- }
- }
-
- for (var i = 0; i < keys.length; ++i) {
- var nextKey = keys[i];
- if ($propIsEnumerable(from, nextKey)) {
- var propValue = from[nextKey];
- to[nextKey] = propValue;
- }
- }
- }
- return to;
- };
|