async_polyfill

1.0.2 • Public • Published

async_polyfill

es6 async await polyfill

converts function generators into async/await block and returns a Promise

promises should be yielded to syncronize the execution block

installation

npm install --save async_polyfill

usage

var async = require('async_polyfill');
 
//call generator function without parameters
async(function*(){
  var user = yield fetch('http://example.com/users/1');
  console.log(user);
})();
 
// call generator functions with parameters
var someUrl = "http://example.com/users/1";
 
var getUser = function*(url){
  var user = yield fetch(url);
  return user;
}
 
async(fn)(someUrl).then(user => console.log(user));

Package Sidebar

Install

npm i async_polyfill

Weekly Downloads

17

Version

1.0.2

License

MIT

Last publish

Collaborators

  • kutlugsahin