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
Markdown
[](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.
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.
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);
```
```typescript
import { awaitPromiseSafely } from "safety-number-one";
awaitPromiseSafely(myPromiseValue);
```