0.0.2 • Published 9 years ago

await-promise v0.0.2

Weekly downloads
4
License
ISC
Repository
github
Last release
9 years ago

await-promise

Install

npm i --save await-promise

Example

import await from 'await-promise';

function timer(name, time) {
	return new Promise(function(success, fail) {
		setTimeout(() => success(name), time*1000);
	});
}

function *myAsyncFunction(a, b, c) {
	yield timer(a, 3);
	yield timer(b, 1);
	yield timer(c, 2);
}

await(myAsyncFunction('Please', 'hit', 'me!')).then(console.log);
// [ 'Please', 'hit', 'me!' ]