https://github.com/typeofweb/safe-try
https://github.com/typeofweb/safe-try
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/typeofweb/safe-try
- Owner: typeofweb
- License: mit
- Created: 2024-08-17T09:27:08.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-17T09:54:50.000Z (over 1 year ago)
- Last Synced: 2025-08-31T17:47:10.198Z (7 months ago)
- Language: TypeScript
- Size: 54.7 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# `safe-try`
Want this?
```ts
const [result, error] = try await asyncMightFail();
```
Do this!
```ts
const [result, error] = await try_(asyncMightFail());
```
Inspired by Matt Pocock's [tweet](https://x.com/mattpocockuk/status/1823822755562967230):

## Usage
```ts
import { try_ } from "safe-try";
const [result, error] = await try_(asyncMightFail());
```