@kingjs/descriptor.reduce

1.0.2 • Public • Published

@kingjs/descriptor.reduce

Accumulate properties of a descriptor using a callback.

Usage

Increment all descriptor values like this:

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

function callback(value, key) {
  return value + 1;
}

var descriptor = {
  foo: 0,
  bar: 1,
}

reduce.call(descriptor, callback);

result:

{
  foo: 1,
  bar: 2
}

API

declare function reduce(
  this: Descriptor,
  accumulator: any,
  callback: (this, value, key: string) => any,
  thisArg?
): Descriptor

Interfaces

Parameters

  • this: The descriptor whose properties are to be mapped.
  • accumulator: The initial value into which the descriptor is accumulated.
  • callback: A mapping function called for each property of this.
    • value: The value being mapped.
    • key: The name of the property being mapped.
  • thisArg: The this argument to pass to callback.

Install

With npm installed, run

$ npm install @kingjs/descriptor.reduce

License

MIT

Analytics

Readme

Keywords

none

Package Sidebar

Install

npm i @kingjs/descriptor.reduce

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

3.13 kB

Total Files

4

Last publish

Collaborators

  • kingces95