Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
async function suspenseReadToPromise(read, ...args) {
let value;
try {
value = read(...args);
} catch (e) {
if (e && typeof e.then === "function") {
value = await e;
}
else {
throw e;
}
}
return value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment