UNPKG

safety-number-one

Version:

Utility functions to work with Promises, functions and async functions safely by converting throws to Result Tuple types

27 lines (19 loc) 878 B
# safety-number-one [Safety is number one priority](https://youtu.be/4ctKfYUisSQ) This is a collection of utility functions to work with Promises, functions and async functions safely by converting throws to Result Tuple types. ## Usage This library lets you use the utility functions either by importing or running a side effect to set the utility functions on `globalThis` so that it can be used anywhere in your codebase. ### Use as global value All global values have the `$` prefix. ```typescript // In your root entry file // import module for side effect (makes this available globally) import "safety-number-one/global"; // In any file in your codebase running after the root entry file $awaitPromiseSafely(myPromiseValue); ``` ### Use as module import ```typescript import { awaitPromiseSafely } from "safety-number-one"; awaitPromiseSafely(myPromiseValue); ```