2.2.5 • Published 3 years ago

@yeldirium/gen-z v2.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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

CategoryStatus
Versionnpm
DependenciesDavid
Dev dependenciesDavid
BuildGitHub Actions
LicenseGitHub

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

Here.

2.2.5

3 years ago

2.2.4

4 years ago

2.2.3

4 years ago

2.2.1

4 years ago

2.2.2

4 years ago

2.2.0

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago