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 |
|
13 | var $assign = Object.assign;
|
14 |
|
15 | var defineProperty = Object.defineProperty;
|
16 | var concat = uncurryThis([].concat);
|
17 |
|
18 |
|
19 |
|
20 | module.exports = !$assign || fails(function () {
|
21 |
|
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 |
|
32 | var A = {};
|
33 | var B = {};
|
34 |
|
35 | var symbol = Symbol('assign detection');
|
36 | var alphabet = 'abcdefghijklmnopqrst';
|
37 | A[symbol] = 7;
|
38 | alphabet.split('').forEach(function (chr) { B[chr] = chr; });
|
39 | return $assign({}, A)[symbol] !== 7 || objectKeys($assign({}, B)).join('') !== alphabet;
|
40 | }) ? function assign(target, source) {
|
41 | var T = toObject(target);
|
42 | var argumentsLength = arguments.length;
|
43 | var index = 1;
|
44 | var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
|
45 | var propertyIsEnumerable = propertyIsEnumerableModule.f;
|
46 | while (argumentsLength > index) {
|
47 | var S = IndexedObject(arguments[index++]);
|
48 | var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
|
49 | var length = keys.length;
|
50 | var j = 0;
|
51 | var key;
|
52 | while (length > j) {
|
53 | key = keys[j++];
|
54 | if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
|
55 | }
|
56 | } return T;
|
57 | } : $assign;
|