|
1 |
| -var global = require('../internals/global'); |
2 | 1 | var isCallable = require('../internals/is-callable');
|
3 | 2 | var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
|
4 | 3 | var makeBuiltIn = require('../internals/make-built-in');
|
5 | 4 | var setGlobal = require('../internals/set-global');
|
6 | 5 |
|
7 | 6 | module.exports = function (O, key, value, options) {
|
8 |
| - var unsafe = options ? !!options.unsafe : false; |
9 |
| - var simple = options ? !!options.enumerable : false; |
10 |
| - var noTargetGet = options ? !!options.noTargetGet : false; |
11 |
| - var name = options && options.name !== undefined ? options.name : key; |
| 7 | + if (!options) options = {}; |
| 8 | + var simple = options.enumerable; |
| 9 | + var name = options.name !== undefined ? options.name : key; |
12 | 10 | if (isCallable(value)) makeBuiltIn(value, name, options);
|
13 |
| - if (O === global) { |
| 11 | + if (options.global) { |
14 | 12 | if (simple) O[key] = value;
|
15 | 13 | else setGlobal(key, value);
|
16 |
| - return O; |
17 |
| - } else if (!unsafe) { |
18 |
| - delete O[key]; |
19 |
| - } else if (!noTargetGet && O[key]) { |
20 |
| - simple = true; |
21 |
| - } |
22 |
| - if (simple) O[key] = value; |
23 |
| - else createNonEnumerableProperty(O, key, value); |
24 |
| - return O; |
| 14 | + } else { |
| 15 | + if (!options.unsafe) delete O[key]; |
| 16 | + else if (O[key]) simple = true; |
| 17 | + if (simple) O[key] = value; |
| 18 | + else createNonEnumerableProperty(O, key, value); |
| 19 | + } return O; |
25 | 20 | };
|
0 commit comments