3.0.3 • Published 6 years ago
apr-reflect v3.0.3
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
input
Function
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