1.0.2 • Published 8 years ago

async_polyfill v1.0.2

Weekly downloads
12
License
MIT
Repository
github
Last release
8 years ago

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));