yancs
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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

Package Sidebar

Install

npm i yancs

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

165 kB

Total Files

10

Last publish

Collaborators

  • nivrith