logo
byethrow
Guide
Examples
API Reference
Guide
Examples
API Reference
logo
byethrow

Getting Started

Introduction
Why byethrow?
Quick Start
Importing Result

Best Practices

Result vs throw
Custom Error
Pattern Matching

Tools & Integrations

MCP Server
ESLint Plugin

Last Updated: 2025/10/13 08:39:30

Next PageWhy byethrow?

#Introduction

Welcome to @praha/byethrow, a lightweight and tree-shakable Result type library designed to handle fallible operations in JavaScript and TypeScript with elegance and simplicity.

#Features

  • 🌲 Tree-Shakable: Only bundle the functions you actually use. The library is designed with modern JavaScript bundlers in mind.
  • 🧱 Lightweight & Object-Based: No classes or complex inheritance hierarchies. Just plain objects that are easy to understand and debug.
  • 🔄 Consistent API: All functions follow the same naming and usage patterns, making the library predictable and easy to learn.
  • 🔀 Unified Sync/Async Handling: Works seamlessly with both synchronous Result<T, E> and asynchronous Promise<Result<T, E>> operations.
  • 🎯 Focused Functionality: Concentrates on Result-centric utilities without unnecessary complexity or confusing variants.

#When to Use byethrow

This library is perfect for:

  • API calls that might fail due to network issues
  • Data validation where you need to accumulate or handle multiple errors
  • File operations that might encounter permissions or I/O errors
  • Parser implementations where invalid input should be handled gracefully
  • Business logic where errors are expected and should be handled explicitly

Happy coding with explicit error handling! 🎉