3.0.3 • Published 6 years ago

apr-reflect v3.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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.

npm.io npm.io

Parameters

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