Skip to content

Commit a9a619a

Browse files
committedMay 14, 2022
simplify defineBuiltIn helper
1 parent dad01b8 commit a9a619a

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed
 
+10-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
var global = require('../internals/global');
21
var isCallable = require('../internals/is-callable');
32
var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
43
var makeBuiltIn = require('../internals/make-built-in');
54
var setGlobal = require('../internals/set-global');
65

76
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;
1210
if (isCallable(value)) makeBuiltIn(value, name, options);
13-
if (O === global) {
11+
if (options.global) {
1412
if (simple) O[key] = value;
1513
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;
2520
};

0 commit comments

Comments
 (0)
Please sign in to comment.