func-pool

1.0.2 • Public • Published

func-pool

Build Status Coverage Status npm version Total downloads PRs Welcome MIT Licence

Execute functions sequentially and modify (add, delete, sort) the order of execution when needed

Install

npm i func-pool

Quick Examples

import FuncPool from 'func-pool';
const funcPool = new FuncPool();
 
function hello() { console.log('hello'); }
function goodbye() { console.log('goodbye'); }
 
funcPool.autoRun([hello, goodbye]);
funcPool.update();
// print 'hello'
// print 'goodbye'
 
funcPool.removeFromAutoRun(goodbye);
funcPool.update();
// print 'hello'
 
funcPool.autoRun(goodbye);
funcPool.update();
// print 'goodbye'
// print 'hello'
 
funcPool.clear();
funcPool.update();
// print nothing

Methods

autoRun(Function | Array<Function>)

autoRun accept a function or an array of functions and will add to the update queue

removeFromAutoRun(Function | Array<Function>)

removeFromAutoRun accept a function or an array of functions and will remove the corresponding method from the update queue

update(): Promise<Array>

Call the update method will call the function in the queue in sequence and return a Promise Object

clear()

clear update queue

Dependents (1)

Package Sidebar

Install

npm i func-pool

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • runjuu