create repeating task chains
npm install repeat!version
!language
!maintenance
!prettier
create repeating task chains
- Features
- Install
- Chain
- Contributing
- [x] Chain any number of tasks and repeat them once or forever.
- [x] Optional synchronous and asynchronous API.
From NPM:
``cmd`
> npm i repeat
The following chain will execute all tasks every second. A task is any callable
function.
`javascript
// ES6
import { Chain } from 'repeat'
// ES5
// let { Chain } = require('repeat')
let chain = new Chain()
chain
.add(
// task A
() => console.log('how are you?'),
// task B
() => console.log('good')
// you can add task C, D, E, F ...
)
.every(1000)
`
The following methods are available on the chain.
- add
- once
- every
- forever
- cancel
#### add
`typescript`
// add any number of tasks to the chain
chain.add(
() => console.log('cat'),
() => console.log('dog'),
() => console.log('fish')
)
#### once
`typescript`
// execute the tasks once
chain.once()
#### every
`typescript`
// execute the tasks asynchronously every second
chain.every(1000)
#### forever
`typescript`
// execute the tasks as fast as possible
chain.forever()
#### cancel
`typescript``
// halt further execution of tasks
chain.cancel()
Pull requests are encouraged. 😁