1.0.1 • Published 5 years ago
@kingjs/property-descriptor.initialize.name v1.0.1
@kingjs/property-descriptor.initialize.name
Renames functions in the descriptor. Allows for optional parenthesized tag.
Usage
var assert = require('assert');
var name = require('@kingjs/property-descriptor.initialize.name');
var foo = {
value: function() { }
}
foo = name.call(foo, 'Foo', 'thunk');
assert(foo.value.name == 'Foo (thunk)');
var bar = {
get: function() { },
set: function(value) { }
}
bar = name.call(bar, 'Bar', 'stub');
assert(bar.get.name == 'Bar (stub)');
assert(bar.set.name == 'Bar (stub)');
API
name(this, name[, type])
Parameters
this
: The descriptor whose functions will be renamed.name
: The name to assign to each function.type
: An optional tag to parenthesize and append to the name (e.g. a stub id).
Returns
Returns the descriptor with its functions renamed.
Install
With npm installed, run
$ npm install @kingjs/property-descriptor.initialize.name
License
MIT