@kingjs/function-ex.rename
v1.0.2
Published
Renames a function.
Downloads
10
Readme
@kingjs/function-ex.rename
Renames a function.
Usage
var assert = require('assert');
var Rename = require('@kingjs/function-ex.rename');
function foo() { }
var fooDescriptor = Object.getOwnPropertyDescriptor(foo, 'name');
assert(fooDescriptor.value == 'foo');
var bar = foo[Rename]('bar');
var barDescriptor = Object.getOwnPropertyDescriptor(foo, 'name');
assert(barDescriptor.value == 'bar');
assert(barDescriptor.enumerable == fooDescriptor.enumerable);
assert(barDescriptor.configurable == fooDescriptor.configurable);
assert(barDescriptor.writable == fooDescriptor.writable);
API
rename(this, string)
Parameters
this
: The function to rename.string
: The name to assign the function.
Returns
Returns the function.
Install
With npm installed, run
$ npm install @kingjs/function-ex.rename
Source
https://repository.kingjs.net/function-ex/rename
License
MIT