npm.io
1.1.2 • Published 7 years ago

rename-function-x

Licence
MIT
Version
1.1.2
Deps
7
Size
330 kB
Vulns
0
Weekly
0

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

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

Keywords