@niceeli/try-catch
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

A Go Like try-catch System

📝 License: MIT 💪 TypeScript: Strict

Usage

bun i @niceeli/try-catch
import safe from "@niceeli/try-catch";

const [data, err, type] = await safe(fetch("https://example.com"));

// data is Response | null
if (err) {
	console.error(`Error: ${err} (${type})`);
	return;
}

// data is Response now, both you and the type system know 100% sure its not null
console.log(data.text());

Readme

Keywords

none

Package Sidebar

Install

npm i @niceeli/try-catch

Weekly Downloads

17

Version

1.1.0

License

MIT

Unpacked Size

13.8 kB

Total Files

11

Last publish

Collaborators

  • niceeli