Skip to content

Instantly share code, notes, and snippets.

@gonzofish gonzofish/esync.js
Created Nov 13, 2019

What would you like to do?
Just a simple wrapper for async/await that handles errors without a lot try/catch
const identity = (value) => value;
const esync = (promise, formatResult = identity) => (
promise.then(async (result) => [undefined, await formatResult(result)])
.catch((error) => [error])
export default esync;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.