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');
8 var getInternalState = InternalStateModule.get;
9 var enforceInternalState = InternalStateModule.enforce;
10 var TEMPLATE = String(String).split('String');
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 : '');
21 if (simple) O[key] = value;
22 else setGlobal(key, value);
26 } else if (!noTargetGet && O[key]) {
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);