0
0
mirror of https://github.com/Doodle3D/Doodle3D-API synced 2024-12-23 14:13:47 +01:00
Doodle3D-API/jspm_packages/npm/core-js@0.9.18/modules/$.redef.js
2015-07-15 15:06:18 +02:00

28 lines
709 B
JavaScript

/* */
var $ = require("./$"),
tpl = String({}.hasOwnProperty),
SRC = require("./$.uid").safe('src'),
_toString = Function.toString;
function $redef(O, key, val, safe) {
if ($.isFunction(val)) {
var base = O[key];
$.hide(val, SRC, base ? String(base) : tpl.replace(/hasOwnProperty/, String(key)));
if (!('name' in val))
val.name = key;
}
if (O === $.g) {
O[key] = val;
} else {
if (!safe)
delete O[key];
$.hide(O, key, val);
}
}
$redef(Function.prototype, 'toString', function toString() {
return $.has(this, SRC) ? this[SRC] : _toString.call(this);
});
$.core.inspectSource = function(it) {
return _toString.call(it);
};
module.exports = $redef;