rename-fn
Rename a function
Last updated 4 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install rename-fn 
SYNC missed versions from official npm registry.

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

Current Tags

  • 2.1.0                                ...           latest (4 years ago)

3 Versions

  • 2.1.0                                ...           4 years ago
  • 2.0.0                                ...           5 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 13
Today 0
This Week 2
This Month 8
Last Day 1
Last Week 0
Last Month 4
Dependencies (0)
None
Dev Dependencies (3)

© 2010 - cnpmjs.org x YWFE | Home | YWFE