Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 23 days 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 (about 1 month ago)
- Default Branch: main
- Last Pushed: 2025-01-10T10:00:48.000Z (about 1 month ago)
- Last Synced: 2025-01-10T10:33:10.760Z (about 1 month ago)
- Topics: javascript, library, npm, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@kearash/safe?activeTab=readme
- Size: 79.1 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![safe() banner](./safe.png)
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.