This package has been deprecated

    Author message:

    see @kingjs/enumerable.for-each

    @kingjs/for-each

    1.0.3 • Public • Published

    @kingjs/for-each

    Invoke a function for each element in an enumerable.

    Usage

    Logging if each number in a range is even or odd could be done like this:

    var forEach = require('@kingjs/for-each');
    var sequence = require('@kingjs/sequence')
     
    var result = [];
     
    forEach(function(x, i) {
      result.push(+ ' 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

    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/for-each
    

    License

    MIT

    Analytics

    Keywords

    none

    Install

    npm i @kingjs/for-each

    DownloadsWeekly Downloads

    10

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    3 kB

    Total Files

    4

    Last publish

    Collaborators

    • kingces95