https://github.com/wjsc/async-functions-pool
Minimal Async Tasks Pool Manager
https://github.com/wjsc/async-functions-pool
async jobs parallel pool tasks-manager
Last synced: 5 months ago
JSON representation
Minimal Async Tasks Pool Manager
- Host: GitHub
- URL: https://github.com/wjsc/async-functions-pool
- Owner: wjsc
- License: mit
- Created: 2018-07-24T15:21:40.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-28T16:37:36.000Z (over 6 years ago)
- Last Synced: 2024-11-11T20:48:16.286Z (6 months ago)
- Topics: async, jobs, parallel, pool, tasks-manager
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/async-functions-pool
- Size: 45.9 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README






[](https://nodei.co/npm/async-functions-pool)
# async-functions-pool
Minimal Async Tasks Pool Manager## Usage
```
// 1. Import module and execute it to create a pool
const pool = require('async-functions-pool')();// 2. Add functions to the queue. For example:
pool.add(() => fetch('http://someAPI.com/resource/1'));
pool.add(() => fetch('http://someAPI.com/resource/2'));
pool.add(() => fetch('http://someAPI.com/resource/3'));
pool.add(() => fetch('http://someAPI.com/resource/4'));
pool.add(() => fetch('http://someAPI.com/resource/5'));
pool.add(() => fetch('http://someAPI.com/resource/6'));// 3. Set number of parallel jobs and run!
async function foo(){
const results = await pool.run(3);
console.log('All jobs have finished');
}
foo();
```## FAQs
- How minimal it is? 25 Lines of code and no dependencies
- Can it run common sync functions? Yes
- Which version of Node is required? > 8.0.0 because it uses async/await