This package has been deprecated

Author message:

see @kingjs/descriptor.nested.transform

@kingjs/descriptor.transform

1.0.2 • Public • Published

@kingjs/descriptor.transform

Returns a new descriptor whose properties are those found on this whose values have been transformed by a callback.

Usage

Map a descriptor of lowercase letters to uppercase letters.

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

transform.call({
  apple: 'a',
  orange: 'o',
  banana: 'b'
}, function(x) { 
  return String.prototype.toUpperCase.call(x); 
})

result:

{
  apple: 'A',
  orange: 'O',
  banana: 'B'
}

API

declare function transform(
  this: Descriptor,
  name: string,
  action: {
    callback(
      name: string, 
      descriptor: Descriptor
    ): any,
    wrap,
    thunks,
    bases,
    defaults
  }
): Descriptor

Interfaces

Parameters

  • this: The descriptor to transform.
  • callback: Function that returns a property value of the resulting descriptor.
    • this: The descriptor being transformed.
    • value: The current value being transformed.
    • name: Than property name of the value being transformed.

Returns

Returns a new descriptor whose properties are those found on this whose values have been transformed by the callback.

Remarks

The list of properties to transform is set before the first callback is made. So if properties are added to the descriptor during mapping they will not be included in the resulting descriptor.

Install

With npm installed, run

$ npm install @kingjs/descriptor.transform

License

MIT

Analytics

Readme

Keywords

none

Package Sidebar

Install

npm i @kingjs/descriptor.transform

Weekly Downloads

8

Version

1.0.2

License

MIT

Unpacked Size

5.7 kB

Total Files

4

Last publish

Collaborators

  • kingces95