1.0.1 • Published 5 years ago

yancs v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

yancs

CircleCI NPM Downloads node License MIT

Elegant Async generator flow control

Highlights

  • Written in Typescript

Installation

npm:

$ npm install yancs

yarn:

$ yarn add yancs

Usage

Elegant Async generator flow control

  const { yancs } = require('yancs');

  // yield promises in async/await fashion
  yancs(function *() {
    let response = yield fetch(`https://api.github.com/users/nivrith`);
    let data = yield response.json();
    console.log(data)
  });

  // Flow control with thunks

   yancs(function *() {
    let response = yield fetch(`https://api.github.com/users/nivrith`);
    let data = yield () => response.json();
    console.log(data)
  });

  // yield arrays
  yancs(function *() {
    console.log(yield [1,2,3].map(x=>x*2)) //[2,4,6]
  });

License

MIT © Nivrith