Lets consider a case where I would like to override the require()
function but I want it to avoid further redefinition at some point. Consider the following scenario:
// I redefine require here
var _require = require;
require = function(){
// some code to redefine original require
}
// After this redefinition shouldn't happen
I know that it is possible to "freeze" object's function using Object.freeze(obj)
hence I'm not allowed to modify the object after the statement. But I couldn't find the equivalent of Object.freeze()
for global/local functions like require
.