@krlwlfrt/async-pool
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

@krlwlfrt/async-pool

pipeline status npm license) documentation

This is a TypeScript enabled version of tiny-async-pool.

Usage

import {asyncPool} from '@krlwlfrt/async-pool/lib/async-pool';

// can be anything that is iterable (aka implements Iterable)
const inputIterable = [100, 200, 300, 400];

/**
* Multiply input number by two
* 
* @param item Number to multiply by two
*/
async function iteratorFunction (item: number): Promise<number> {
  return item * 2;
}

// invoke async pool with limit 2 - meaning 2 iterator functions are executed simultaneously
asyncPool(2, inputIterable, iteratorFunction).then((result) => {
  console.log(result); // outputs [ 200, 400, 600, 800 ]
});

Documentation

See online documentation for detailed API description.

/@krlwlfrt/async-pool/

    Package Sidebar

    Install

    npm i @krlwlfrt/async-pool

    Weekly Downloads

    400

    Version

    1.1.2

    License

    MIT

    Unpacked Size

    8.85 kB

    Total Files

    6

    Last publish

    Collaborators

    • krlwlfrt