1.0.19 • Published 2 years ago

catchmeoutside v1.0.19

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

catchmeoutside

catchmeoutside is a utility library designed to simplify asynchronous error handling by capturing errors from asynchronous operations.

Installation

You can install catchmeoutside using npm:

npm install catchmeoutside
import { catchMeOutside, createFloat, Float } from 'catchmeoutside';

// Example asynchronous function
async function exampleAsyncFunction() {
  // Your asynchronous operation goes here
  return new Promise((resolve, reject) => {
    // Simulate an error
    // reject(new Error('Something went wrong'));

    // Simulate a successful operation
    resolve('Data fetched successfully');
  });
}

// Example usage of catchMeOutside
async function exampleUsage() {
  var {err, val} = await catchMeOutside(exampleAsyncFunction)

  if (err) {
    console.error('Error creating Float:', err);
  } else {
    console.log('Valid Float:', val);
  }
  
  var { err, val } = await catchMeOutside(async () => createFloat(34)); // throws error and error is stored in value err

  if (err) {
    console.error('Error creating Float:', err);
  } else {
    console.log('Valid Float:', val);
  }
}
exampleUsage();

API

asyncFunc: A function that returns a promise representing the asynchronous operation.

Returns an object with two properties:

err: The error object if the asynchronous operation fails, or null if successful.

val: The resolved value if the asynchronous operation is successful, or null if an error occurs.

Additional Types For stricter type checking, catchmeoutside provides the following interfaces:

Float: A type representing a floating-point number.

Int8: A type representing an 8-bit integer.

Int16: A type representing a 16-bit integer.

Int32: A type representing a 32-bit integer.

These types are designed to enhance type safety when working with numeric values.

License This project is licensed under the MIT License - see the LICENSE file for details.

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago