pair-foreach

1.0.1 • Public • Published

pair-foreach NPM version NPM monthly downloads

Runs an operation for each pair in an array.

Install

Install with npm:

$ npm install --save pair-foreach

Usage

const pairForEach = require("pair-foreach");

const pairs = [
    [1, 10],
    [2, 9],
    [3, 8],
    [4, 7],
    [5, 6]
];

pairForEach(pairs, (elem1, elem2) => {
    console.log(elem1 * elem2);
});

The first argument for pairForEach must be an array of 2-length arrays.

The second argument must be a function with between 2 and 4 arguments. The first 2 arguments are elements, the 3rd one is the index, and the 4th one is the original array.

Readme

Keywords

none

Package Sidebar

Install

npm i pair-foreach

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

1.82 kB

Total Files

4

Last publish

Collaborators

  • milesman34