1.0.2 • Published 5 years ago
@kingjs/property-descriptor.initialize.external v1.0.2
@kingjs/property-descriptor.initialize.external
Overwrites a descriptors properties with those of the result of a callback invoked with the name and target.
Usage
var assert = require('assert');
var external = require('@kingjs/property-descriptor.initialize.external');
function Target() { };
function Foo() { }
var descriptor = {
configurable: true,
enumerable: false,
}
external.call(descriptor, () => Foo, 'foo', Target);
assert(descriptor.value == Foo);
assert(!descriptor.enumerable);
assert(descriptor.configurable);
function init(name, target) {
assert(name == 'foo');
assert(target == Target);
return {
enumerable: true,
value: Foo
};
}
external.call(descriptor, init, 'foo', Target);
assert(descriptor.value == Foo);
assert(descriptor.enumerable);
assert(descriptor.configurable);
API
external(this, callback(name, target), name, target)
Parameters
this
: The descriptor that delegates its initialization tocallback
.callback
: Returns a function or a descriptor givenname
andtarget
.name
: The name of property being described.target
: The target on which the property is defined.
name
: The name of property being described.target
: The target on which the property is defined.
Returns
The descriptor whose properties have been overwritten with those of the callback result.
Install
With npm installed, run
$ npm install @kingjs/property-descriptor.initialize.external
Source
https://repository.kingjs.net/property-descriptor/initialize/external
License
MIT