-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async / Await #17
Comments
This idea is that would allow doing something like this:
|
Since this feature has to be implemented in the NEL package, I've opened an issue there. See n-riesco/nel#6 . In the meantime, as a workaround, you could define a helper function like this (untested): function awaitFor(promise, send, $_) {
send = send || $$.sendResult;
$_ = $_ || $$;
$_.async();
promise.then(function(result) {
send.call($_, result);
}).catch(function(error) {
$_.sendError(error);
});
} so that your example would be re-written as: const fetch = require('isomorphic-fetch');
awaitFor(fetch('http://google.com'), $$.html); And another example: const fs = require('fs');
const util = require('util');
const readdir = util.promisify(fs.readdir);
awaitFor(readdir('.')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there,
It would be nice to be able to use the new async/await syntax. Could it be as simple as wrapping the REPL as mentioned here? tc39/proposal-async-await#9 (comment)
Cheers,
Jun
The text was updated successfully, but these errors were encountered: