rename-fn
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

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

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i rename-fn

    Weekly Downloads

    3,211

    Version

    2.1.0

    License

    MIT

    Unpacked Size

    3.26 kB

    Total Files

    5

    Last publish

    Collaborators

    • sindresorhus