- Notifications
You must be signed in to change notification settings - Fork1
mfbx9da4/async-await-with-generators
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Async await implemented with generators. This code is an experiment for showing how async await could be implemented.
Thanks toEli who originally had the idea for async await with generators before promises were a thing.
constlib=require('./lib')// Some example asynchronous function// The library assumes that all async funcs must have a callback as the last argfunctiondoGet(url,callback){setTimeout(()=>{callback(`<div>${url}</div>`)},1)}// our example function which takes await as a parameterfunction*example(await){for(leti=0;i<5;i++){constres=yieldawait(doGet,[`http://url.com/${i}`]);expect(res).to.equal(`<div>http://url.com/${i}</div>`)}}// invoking our function with the librarylib.async(example)
npm testAbout
Async await implemented with generators
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.