logo
byethrow
  • Guide
  • Examples
  • API Reference
    Getting Started
    Introduction
    Why byethrow?
    Quick Start
    Importing Result
    Best Practices
    Result vs throw
    Custom Error
    Pattern Matching
    Tools & Integrations
    MCP Server
    ESLint Plugin
    📝 Edit this page

    Last Updated: 11/28/2025, 5:42:58 AM

    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! 🎉