diff options
Diffstat (limited to 'node_modules/core-js/internals/redefine.js')
| -rw-r--r-- | node_modules/core-js/internals/redefine.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/node_modules/core-js/internals/redefine.js b/node_modules/core-js/internals/redefine.js new file mode 100644 index 0000000..8b936a4 --- /dev/null +++ b/node_modules/core-js/internals/redefine.js @@ -0,0 +1,40 @@ +var global = require('../internals/global'); +var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); +var has = require('../internals/has'); +var setGlobal = require('../internals/set-global'); +var inspectSource = require('../internals/inspect-source'); +var InternalStateModule = require('../internals/internal-state'); + +var getInternalState = InternalStateModule.get; +var enforceInternalState = InternalStateModule.enforce; +var TEMPLATE = String(String).split('String'); + +(module.exports = function (O, key, value, options) { + var unsafe = options ? !!options.unsafe : false; + var simple = options ? !!options.enumerable : false; + var noTargetGet = options ? !!options.noTargetGet : false; + var state; + if (typeof value == 'function') { + if (typeof key == 'string' && !has(value, 'name')) { + createNonEnumerableProperty(value, 'name', key); + } + state = enforceInternalState(value); + if (!state.source) { + state.source = TEMPLATE.join(typeof key == 'string' ? key : ''); + } + } + if (O === global) { + if (simple) O[key] = value; + else setGlobal(key, value); + return; + } else if (!unsafe) { + delete O[key]; + } else if (!noTargetGet && O[key]) { + simple = true; + } + if (simple) O[key] = value; + else createNonEnumerableProperty(O, key, value); +// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative +})(Function.prototype, 'toString', function toString() { + return typeof this == 'function' && getInternalState(this).source || inspectSource(this); +}); |
