apr-reflect
v3.0.3
Published
Wraps the function in another function that always returns data even when it errors.
Downloads
48
Maintainers
Readme
reflect
Wraps the function in another function that always returns data even when it errors. The object returned has either the property error or value.
Parameters
inputFunction
Examples
import parallel from 'apr-parallel';
import reflect from 'apr-reflect';
const then = (v) => new Promise((resolve) => resolve(v));
const res = await parallel([
async () => {
throw new Error('heyo')
},
async () => await then(2)
]);
// res = [{ error: Error('heyo'), value: null }, { error: null, value: 2 }]Returns Function
