https://github.com/notkearash/safe
Handle your await/async promises safely without try/catch blocks.
https://github.com/notkearash/safe
javascript library npm typescript
Last synced: about 1 year ago
JSON representation
Handle your await/async promises safely without try/catch blocks.
- Host: GitHub
- URL: https://github.com/notkearash/safe
- Owner: notkearash
- License: mit
- Created: 2025-01-10T08:44:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-10T10:00:48.000Z (over 1 year ago)
- Last Synced: 2025-03-30T07:41:21.321Z (over 1 year ago)
- Topics: javascript, library, npm, typescript
- Language: TypeScript
- Homepage: https://npmjs.com/package/@kearash/safe
- Size: 79.1 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

Handle your await/async promises safely without try/catch blocks.
## Installation
npm
```bash
npm i @kearash/safe
```
pnpm
```bash
pnpm add @kearash/safe
```
bun
```bash
bun i @kearash/safe
```
yarn
```bash
yarn add @kearash/safe
```
## Usage
```ts
import { safe } from '@kearash/safe';
const fetchData = async () => {
const [error, data] = await safe(fetch('https://jsonplaceholder.typicode.com/'));
if (error) {
console.error('Error fetching data:', error);
return;
}
console.log('Fetched data:', data);
};
fetchData();
```
## License
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.