@kingjs/enumerable.for-each

Invokes a function for each element in a sequence.

Stats

StarsIssuesVersionUpdatedCreatedSize
@kingjs/enumerable.for-each
1.0.13 years ago3 years agoMinified + gzip package size for @kingjs/enumerable.for-each in KB

Readme

@kingjs/enumerable.for-each

Invokes a function for each element in a sequence.

Usage

Log if a value has an even or odd index like this:

var forEach = require('@kingjs/enumerable.for-each');
var sequence = require('@kingjs/enumerable.create')

var result = [];

forEach(function(x, i) {
  result.push(x + ' at ' + i)
}, sequence('a', 'b', 'c'));

result;

result:

[ 
  'a at 0',
  'b at 1',
  'c at 2',
]

API

function forEach(
  action: (x, i) => void, 
  sequence: Enumerable
);

Interfaces

  • Enumerable: See @kingjs/enumerable.define.

    Parameters

  • action: The action to call for each element in sequence.
    • x: Current element of sequence.
    • i: The index of element x.
  • sequence: The elements to pass to action.

    Remarks

    action will be invoked with the same this as was passed to forEach.

    Install

    With npm installed, run
    $ npm install @kingjs/enumerable.for-each
    

    License

    MIT

Analytics

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.