npm.io
1.0.0 • Published 8 years ago

neach

Licence
MIT
Version
1.0.0
Deps
1
Size
3 kB
Vulns
0
Weekly
0

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)
})

Keywords