@sebastianowy/concurrent-array
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

ConcurrentArray

Run array higher order functions asynchronously with concurrency control

npm latest version Build states semantic-release

Installation

npm install --save @sebastianowy/concurrent-array
# or
yarn add @sebastianowy/concurrent-array

Usage

Examples

  • async sorting
import { ConcurrentArray } from "@sebastianowy/concurrent-array";

const array = [3, 5, 1, 2, 4];
const asyncArray = new ConcurrentArray(array, {
  maxConcurrency: 10,
});

asyncArray
  .sort((left, right) => new Promise((resolve) => setTimeout(() => resolve(left - right), 1000)), {
    maxConcurrency: 5, // overwrite max concurrency for sort array operation
  })
  .then(console.log);

will produce:

[1, 2, 3, 4, 5]

respecting allowed maximum concurrency.

Learn more

Please refer to @sebastianowy/concurrent-queue and @sebastianowy/async-array README files to learn more about possible options and methods.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    0

Package Sidebar

Install

npm i @sebastianowy/concurrent-array

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

64.1 kB

Total Files

52

Last publish

Collaborators

  • sebastianowy.dev