[79a0317] | 1 | 'use strict';
|
---|
| 2 | var DESCRIPTORS = require('../internals/descriptors');
|
---|
| 3 | var uncurryThis = require('../internals/function-uncurry-this');
|
---|
| 4 | var call = require('../internals/function-call');
|
---|
| 5 | var fails = require('../internals/fails');
|
---|
| 6 | var objectKeys = require('../internals/object-keys');
|
---|
| 7 | var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');
|
---|
| 8 | var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');
|
---|
| 9 | var toObject = require('../internals/to-object');
|
---|
| 10 | var IndexedObject = require('../internals/indexed-object');
|
---|
| 11 |
|
---|
| 12 | // eslint-disable-next-line es/no-object-assign -- safe
|
---|
| 13 | var $assign = Object.assign;
|
---|
| 14 | // eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
---|
| 15 | var defineProperty = Object.defineProperty;
|
---|
| 16 | var concat = uncurryThis([].concat);
|
---|
| 17 |
|
---|
| 18 | // `Object.assign` method
|
---|
| 19 | // https://tc39.es/ecma262/#sec-object.assign
|
---|
| 20 | module.exports = !$assign || fails(function () {
|
---|
| 21 | // should have correct order of operations (Edge bug)
|
---|
| 22 | if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
|
---|
| 23 | enumerable: true,
|
---|
| 24 | get: function () {
|
---|
| 25 | defineProperty(this, 'b', {
|
---|
| 26 | value: 3,
|
---|
| 27 | enumerable: false
|
---|
| 28 | });
|
---|
| 29 | }
|
---|
| 30 | }), { b: 2 })).b !== 1) return true;
|
---|
| 31 | // should work with symbols and should have deterministic property order (V8 bug)
|
---|
| 32 | var A = {};
|
---|
| 33 | var B = {};
|
---|
| 34 | // eslint-disable-next-line es/no-symbol -- safe
|
---|
| 35 | var symbol = Symbol('assign detection');
|
---|
| 36 | var alphabet = 'abcdefghijklmnopqrst';
|
---|
| 37 | A[symbol] = 7;
|
---|
| 38 | // eslint-disable-next-line es/no-array-prototype-foreach -- safe
|
---|
| 39 | alphabet.split('').forEach(function (chr) { B[chr] = chr; });
|
---|
| 40 | return $assign({}, A)[symbol] !== 7 || objectKeys($assign({}, B)).join('') !== alphabet;
|
---|
| 41 | }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
|
---|
| 42 | var T = toObject(target);
|
---|
| 43 | var argumentsLength = arguments.length;
|
---|
| 44 | var index = 1;
|
---|
| 45 | var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
|
---|
| 46 | var propertyIsEnumerable = propertyIsEnumerableModule.f;
|
---|
| 47 | while (argumentsLength > index) {
|
---|
| 48 | var S = IndexedObject(arguments[index++]);
|
---|
| 49 | var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
|
---|
| 50 | var length = keys.length;
|
---|
| 51 | var j = 0;
|
---|
| 52 | var key;
|
---|
| 53 | while (length > j) {
|
---|
| 54 | key = keys[j++];
|
---|
| 55 | if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
|
---|
| 56 | }
|
---|
| 57 | } return T;
|
---|
| 58 | } : $assign;
|
---|