1.0.4 • Published 2 years ago

partitioned-loops v1.0.4

Weekly downloads
114
License
MIT
Repository
github
Last release
2 years ago

partitioned-loops

npm version npm downloads dependencies status Build Status Coverage Status

Library for partitioned loops organization

Install

npm i partitioned-loops

Usage

const { forEachAsync } = require("partitioned-loops");

/*...*/

const finalState = await forEachAsync(
  [1, 2, 3, 4, 5],
  (currentValue, loopState) => {
    if (currentValue > 4) loopState.break = true;
    else loopState.sum += currentValue;
  },
  { sum: 0 }
);
const { forAsync } = require("partitioned-loops");

/*...*/

const array = [1, 2, 3, 4, 5];
const finalState = await forAsync(
  0,
  array.length,
  (i, loopState) => {
    if (array[i] > 4) loopState.break = true;
    else loopState.sum += array[i];
  },
  { sum: 0 }
);
1.0.4

2 years ago

1.0.3

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

5 years ago