1.0.1 • Published 7 years ago
@kingjs/descriptor.normalize v1.0.1
@kingjs/descriptor.normalize
Returns a descriptor given a primitive value.
Usage
var normalize = require('@kingjs/descriptor.normalize');
var people = {
alice: { name: 'Alice', age: 21 },
bob: 'Bob'
}
for (var name in people)
people[name] = normalize(people[name], 'name');
people;result:
{
alice: { name: 'Alice', age: 21 },
bob: { name: 'Bob' }
}API
declare function normalize(
value,
action: string | (value) => Descriptor
): DescriptorInterfaces
Descriptor: see @kingjs/descriptor
Parameters
value: The value to normalize into a descriptor.action: The name of the property to holdvalueor a function that acceptsvalueand returns a descriptor.
Returns
Returns value if already a descriptor, else a normalized descriptor for value.
Install
With npm installed, run
$ npm install @kingjs/descriptor.normalizeLicense
MIT