aboutsummaryrefslogtreecommitdiff
path: root/node_modules/core-js/modules/_redefine.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/core-js/modules/_redefine.js')
-rw-r--r--node_modules/core-js/modules/_redefine.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/node_modules/core-js/modules/_redefine.js b/node_modules/core-js/modules/_redefine.js
new file mode 100644
index 00000000..b7ba9f30
--- /dev/null
+++ b/node_modules/core-js/modules/_redefine.js
@@ -0,0 +1,31 @@
+var global = require('./_global');
+var hide = require('./_hide');
+var has = require('./_has');
+var SRC = require('./_uid')('src');
+var TO_STRING = 'toString';
+var $toString = Function[TO_STRING];
+var TPL = ('' + $toString).split(TO_STRING);
+
+require('./_core').inspectSource = function (it) {
+ return $toString.call(it);
+};
+
+(module.exports = function (O, key, val, safe) {
+ var isFunction = typeof val == 'function';
+ if (isFunction) has(val, 'name') || hide(val, 'name', key);
+ if (O[key] === val) return;
+ if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
+ if (O === global) {
+ O[key] = val;
+ } else if (!safe) {
+ delete O[key];
+ hide(O, key, val);
+ } else if (O[key]) {
+ O[key] = val;
+ } else {
+ hide(O, key, val);
+ }
+// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
+})(Function.prototype, TO_STRING, function toString() {
+ return typeof this == 'function' && this[SRC] || $toString.call(this);
+});