1 | var global = require('../internals/global');
|
2 | var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
|
3 | var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
|
4 | var redefine = require('../internals/redefine');
|
5 | var setGlobal = require('../internals/set-global');
|
6 | var copyConstructorProperties = require('../internals/copy-constructor-properties');
|
7 | var isForced = require('../internals/is-forced');
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | module.exports = function (options, source) {
|
24 | var TARGET = options.target;
|
25 | var GLOBAL = options.global;
|
26 | var STATIC = options.stat;
|
27 | var FORCED, target, key, targetProperty, sourceProperty, descriptor;
|
28 | if (GLOBAL) {
|
29 | target = global;
|
30 | } else if (STATIC) {
|
31 | target = global[TARGET] || setGlobal(TARGET, {});
|
32 | } else {
|
33 | target = (global[TARGET] || {}).prototype;
|
34 | }
|
35 | if (target) for (key in source) {
|
36 | sourceProperty = source[key];
|
37 | if (options.noTargetGet) {
|
38 | descriptor = getOwnPropertyDescriptor(target, key);
|
39 | targetProperty = descriptor && descriptor.value;
|
40 | } else targetProperty = target[key];
|
41 | FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
|
42 |
|
43 | if (!FORCED && targetProperty !== undefined) {
|
44 | if (typeof sourceProperty === typeof targetProperty) continue;
|
45 | copyConstructorProperties(sourceProperty, targetProperty);
|
46 | }
|
47 |
|
48 | if (options.sham || (targetProperty && targetProperty.sham)) {
|
49 | createNonEnumerableProperty(sourceProperty, 'sham', true);
|
50 | }
|
51 |
|
52 | redefine(target, key, sourceProperty, options);
|
53 | }
|
54 | };
|