Version 1
[yaffs-website] / node_modules / core-js / modules / _redefine.js
1 var global    = require('./_global')
2   , hide      = require('./_hide')
3   , has       = require('./_has')
4   , SRC       = require('./_uid')('src')
5   , TO_STRING = 'toString'
6   , $toString = Function[TO_STRING]
7   , TPL       = ('' + $toString).split(TO_STRING);
8
9 require('./_core').inspectSource = function(it){
10   return $toString.call(it);
11 };
12
13 (module.exports = function(O, key, val, safe){
14   var isFunction = typeof val == 'function';
15   if(isFunction)has(val, 'name') || hide(val, 'name', key);
16   if(O[key] === val)return;
17   if(isFunction)has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
18   if(O === global){
19     O[key] = val;
20   } else {
21     if(!safe){
22       delete O[key];
23       hide(O, key, val);
24     } else {
25       if(O[key])O[key] = val;
26       else hide(O, key, val);
27     }
28   }
29 // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
30 })(Function.prototype, TO_STRING, function toString(){
31   return typeof this == 'function' && this[SRC] || $toString.call(this);
32 });