2.1.0 • Published 1 year ago

rename-fn v2.1.0

Weekly downloads
374
License
MIT
Repository
github
Last release
1 year ago

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