pelt
v0.0.2
Published
Do a task repeatedly.
Readme
pelt
Do a task repeatedly.
How to use
Start a task like so:
import pelt from 'pelt'
pelt(1000, () => console.log('Hello there!'))Do something more interesting, like incrementing a value:
pelt(1000, 0, value => ++value)Whatever is returned from the task will be used as input for the next repetition.
The return value
pelt returns a value that can be manipulated to communicate with the task.
const p = pelt(1000, 0, value => ++value)
p(7) // will set value to 7const p = pelt(1000, 0, value => ++value)
p() // will stop the taskconst p = pelt(1000, {value: 99}, obj => ++obj.value)
p.value = 7 // will set value to 7
console.log(p.value) // prints whatever is in value