This library allows you wrap async generators and consume it using functional methods. For example:
import {wrap} from './async';
// genNums(9) is an async generator that yields 9 numbers (0 to 8),
// a number is generated every few ms
// checkout implementation in tests
it('should allow to buffer', async () => {
expect(
await wrap(genNums(9))
.filter(x => x % 2 === 0)
.buffer(2)
.take(2)
).toEqual([[0, 2], [4, 6]]);
});Binding to DOM events using onEvent():
wrap(onEvent('click', btn))
.throttle(2)
.forEach(ev => {
console.log('BOOM!!!', ev.target);
});npm installInstall all dependencies
npm run testThis will watch for changes and run the relevant tests after every change in code
npm run startThis will open the browser and start to watch for changes, auto reloading with each change