rename-fn
v2.1.0
Published
Rename a function
Downloads
16,919
Maintainers
Readme
rename-fn
Rename a function
JavaScript engines are good at inferring function names. You probably don't need this unless you want a different name.
Install
npm install rename-fn
Usage
import renameFunction from 'rename-fn';
function foo() {}
console.log(foo.name);
//=> 'foo'
foo.name = 'unicorn';
console.log(foo.name);
//=> 'foo' 😢
renameFunction(foo, 'unicorn');
console.log(foo.name);
//=> 'unicorn' 😁
API
renameFunction(function, name)
function
Type: function
The function to rename.
name
Type: string
The new name.
Related
- mimic-fn - Make a function mimic another one