Convert async/await try/catch to `[error, result]`
npm install error-firstConvert async/await try/catch to [error, result]
``ts
import errorFirst from 'error-first'
const [error, result] = await errorFirst(doSomething)
`
ts
const addAsync = async (a, b) => {
if (a == null || b == null) {
throw 'Argument Error'
} return a + b
}
`$3
`ts
import errorFirst from 'error-first'
// const errorFirst = require('error-first').defaultconst [error, result] = await errorFirst(addAsync(1, 2)) // [undefined, 3]
`$3
`ts
let result = nulltry {
result = await addAsync(1, 2)
} catch(error) {
// Do something with error
}
``