1.0.9 • Published 6 years ago

@kingjs/descriptor.map v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

@kingjs/descriptor.map

Maps descriptor property values.

Usage

Map a properties using a variety of declarations like this:

var map = require('@kingjs/descriptor.map');
var write = require('@kingjs/descriptor.write');

var result = map.call({
  inflateMe: function $(arg, key, path) { return arg; },
  squareMe: 3,
  scorchMe: { foo: undefined },
  writeMe: 'Hello World'  
}, {
  inflate: { inflateMe: null },
  thunks: { squareMe: (value, arg, key) => value * value },
  scorch: { },
  callback: (descriptor, arg) =>
    write.call(descriptor, 'writeMe', descriptor.writeMe + '!')
}, 'myArg');

result:

{
  inflateMe: 'myArg',
  squareMe: 9,
  scorchMe: { },
  writeMe: 'Hello World!'
}

API

declare function map(
  this: Descriptor,
  action: (value, arg, key) => Descriptor | {
    inflate?: DescriptorTree | (arg, key, path) => Descriptor,
    thunks?: DescriptorTree | (value, arg, key) => Descriptor,
    scorch?: DescriptorTree,
    callback?: (descriptor, arg) => Descriptor
  },
  arg: any
): Descriptor

Interfaces

Parameters

  • this: The Descriptor whose property values will be mapped.
  • action: The callback which maps property values.

Returns

A descriptor with mapped property values.

Remarks

Inflate will only invoke functions named $.

Install

With npm installed, run

$ npm install @kingjs/descriptor.map

License

MIT

Analytics

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago