rename-function-x
v1.1.2
Published
Rename a function.
Downloads
59
Maintainers
Readme
rename-function-x
Rename a function.
Note: This is not supported in all environments. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#Browser_compatibility
Example
import renameFunction from 'rename-function-x';
const fn = function test() {};
console.log(renameFunction(fn, 'hw')); // true if a success, else false
console.log(fn.name); // hw if set, else test
// The following would normally throw an error as it is a reserved name.
// However, you can for the rename as follows.
console.log(renameFunction(fn, 'catch', true)); // true if a success, else false