New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

gean

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gean

Composable Generator Control

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
1
Created
Source

gean

gean provides a mechanism for composable generator control with promises.

why ?

  • tiny.
  • zero dependencies.
  • composable.
  • Promise based.

installation

$ npm install gean --save

usage

gean(function * () {
  // flow control here
});

gean accept a GeneratorFunction and returns a Promise that allow for composability.

example

We can use gean to create simple a fetch function backed by superagent. We'll use it to read from the randomuser API and sum the number of male and female gender entries per user.

import agent from 'superagent';
import gean from 'gean';

const fetch = uri => new Promise((yep, nope) => {
  agent.get(uri).end((err, res) ? nope(err) : yep(res));
};

gean(function * () {
  const uri = 'https://randomuser.me/api?results=10';
  const res = yield fetch(uri);
  const users = res.body.results;
  const counter = {female: 0, male: 0};

  for (let user of users)
    counter[user.gender]++;

  console.log(counter)
  // { female: 8, male: 2 }
});

license

MIT

Keywords

tiny

FAQs

Package last updated on 08 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts