Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / redefine.js
1 var global = require('../internals/global');
2 var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
3 var has = require('../internals/has');
4 var setGlobal = require('../internals/set-global');
5 var inspectSource = require('../internals/inspect-source');
6 var InternalStateModule = require('../internals/internal-state');
7
8 var getInternalState = InternalStateModule.get;
9 var enforceInternalState = InternalStateModule.enforce;
10 var TEMPLATE = String(String).split('String');
11
12 (module.exports = function (O, key, value, options) {
13   var unsafe = options ? !!options.unsafe : false;
14   var simple = options ? !!options.enumerable : false;
15   var noTargetGet = options ? !!options.noTargetGet : false;
16   var state;
17   if (typeof value == 'function') {
18     if (typeof key == 'string' && !has(value, 'name')) {
19       createNonEnumerableProperty(value, 'name', key);
20     }
21     state = enforceInternalState(value);
22     if (!state.source) {
23       state.source = TEMPLATE.join(typeof key == 'string' ? key : '');
24     }
25   }
26   if (O === global) {
27     if (simple) O[key] = value;
28     else setGlobal(key, value);
29     return;
30   } else if (!unsafe) {
31     delete O[key];
32   } else if (!noTargetGet && O[key]) {
33     simple = true;
34   }
35   if (simple) O[key] = value;
36   else createNonEnumerableProperty(O, key, value);
37 // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
38 })(Function.prototype, 'toString', function toString() {
39   return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
40 });