90684e6ba7374af534c9e7a0ed72a0ffa75eb84f
[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   if (typeof value == 'function') {
17     if (typeof key == 'string' && !has(value, 'name')) createNonEnumerableProperty(value, 'name', key);
18     enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
19   }
20   if (O === global) {
21     if (simple) O[key] = value;
22     else setGlobal(key, value);
23     return;
24   } else if (!unsafe) {
25     delete O[key];
26   } else if (!noTargetGet && O[key]) {
27     simple = true;
28   }
29   if (simple) O[key] = value;
30   else createNonEnumerableProperty(O, key, value);
31 // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
32 })(Function.prototype, 'toString', function toString() {
33   return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
34 });