result-co
Turn a generator function back into a normal one but where any yield
ed values are awaited before continuing. Promises, thunks, etc.. get you closer to blocking semantics but often the syntax they require obscures that. This helps get your syntax even closer to the blocking version.
Installation
With your favorite package manager:
- packin:
packin add result-co
- component:
component install jkroso/result-co
- npm:
npm install result-co
then in your app:
var co =
API
co(generator)
co
takes a generator function and returns a normal one. Except it will have the special ability to unwrap/await results by yielding them.
var Result = var wrap = Resultwrapvar add = // => 3 // => 3var one = var three = three // => new Resultonethree // => wrap(3) // => 6