epicles
v2.1.2
Published
A library for creating gearboxes which are composed of multiple gears and can tick on each time interval and emit tick event on each tick.
Downloads
3
Readme
Epicles
A small periodic event emitter
Installation
npm install --save epicles
Usage
import { epicles } from 'epicles';
// create an emitter with initial state [0, 0, 0]
const emitter = epicles({
steps: 4,
steppers: 3,
});
emitter.subscribe((event) => {
console.log(event);
});
emitter.tick(); // [{ step: 1, stepper: 0 }]
emitter.tick(); // [{ step: 2, stepper: 0 }]
emitter.tick(); // [{ step: 3, stepper: 0 }]
emitter.tick(); // [{ step: 0, stepper: 0 }, { step: 1, stepper: 1 }]
emitter.tick(); // [{ step: 1, stepper: 0 }]
Test
npm run test
License
MIT