@yeldirium/gen-z
v2.2.5 generator generators async
Gen-z
UNMAINTAINED - Since I don't use it and it's still JS, not TS, I'm not going to maintain this any longer.
Next generation (lol) generator helpers.
Think any utility library (ramda, lodash) but for generators.
npm install @yeldirium/gen-z
# or
yarn install @yeldirium/gen-z
Status
Category | Status |
---|---|
Version | |
Dependencies | |
Dev dependencies | |
Build | |
License |
Short guide
Everything with more than one parameter is curried.
Process and acknowledge events from somewhere:
const g = require('gen-z').sync;
const generator = fetchEventsAsGenerator(fromSomewhere);
const acknowledgable = g.acknowledgable(generator, acknowledgeEventCallback);
g.forEach(
event => {
try {
processEventSomehow(event);
// Acknowledge the event.
return true;
} catch {
// Or make the generator re-yield the event.
return false;
}
},
acknowledgable
);
Get the powers of 2 from 2^10 to 2^15:
const g = require('gen-z').sync;
console.log(
g.collect(
g.take(
5,
g.drop(
10,
g.iterate(a => a * 2, 1)
)
)
)
);
Documentation
npm i @yeldirium/gen-z
Metadata
- MIT
- Whatever
- Hannes Leutloff
- released 2/26/2021