1.0.0 • Published 6 years ago

neach v1.0.0

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

neach

It’s like .forEach(), but nested.

Installation

Requires Node.js 6.0.0 or above.

npm i neach

API

The module exports a single function.

Parameters

  1. Variadic: ...iterables (one or more of: iterable): The levels of the nested each-loop.
  2. cb (function): A callback which is given one argument for each iterable.

Return Value

None.

Example

Before

for (const message of ['Hello', 'Goodbye']) {
  for (const whom of ['world', 'Dolly']) {
    for (const punc of ['.', '!']) {
      console.log(message + ', ' + whom + punc)
    }
  }
}

After

const neach = require('neach')

neach(['Hello', 'Goodbye'], ['world', 'Dolly'], ['.', '!'], (message, whom, punc) => {
  console.log(message + ', ' + whom + punc)
})