apr-reflect

3.0.3 • Public • Published

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

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

Package Sidebar

Install

npm i apr-reflect

Weekly Downloads

1

Version

3.0.3

License

MIT

Last publish

Collaborators

  • ramitos