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

1.0.0 • 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.

Readme

Keywords

Package Sidebar

Install

npm i @krlwlfrt/async-pool

Weekly Downloads

350

Version

1.0.0

License

MIT

Unpacked Size

8.81 kB

Total Files

6

Last publish

Collaborators

  • krlwlfrt