Neighbor's Preppy Maltese

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

    1.0.0 • Public • Published

    ConcurrentArray

    Run array higher order functions asynchronously with concurrency control

    npm latest version Build states semantic-release

    Installation

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

    Usage

    Examples

    • async sorting
    import { ConcurrentArray } from "@sebowy/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 @sebowy/concurrent-queue and @sebowy/async-array README files to learn more about possible options and methods.

    Install

    npm i @sebowy/concurrent-array

    DownloadsWeekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    80.3 kB

    Total Files

    61

    Last publish

    Collaborators

    • sebowy.dev