yancs

Elegant Async generator flow control

Usage no npm install needed!

<script type="module">
  import yancs from 'https://cdn.skypack.dev/yancs';
</script>

README

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