Skip to content

joey1887/result

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ result - Simplifying Error Handling in TypeScript

Download

πŸ“œ Description

The result library provides a type-safe way to handle results in TypeScript. Inspired by Rust, it helps you manage errors effectively, ensuring your functions return values consistently. This library is useful for anyone wanting to write clear, maintainable code without getting bogged down in error management.

🌟 Features

  • Type Safety: Avoid runtime errors by using types to manage success and failure states.
  • Functional Programming: Embrace a functional style for cleaner, more understandable code.
  • Inspired by Rust: Benefit from proven concepts adapted for TypeScript.
  • Easy to Use: Designed for ease of understanding, even for non-technical users.

πŸ› οΈ Requirements

  • A device with Windows, macOS, or Linux.
  • A current version of Node.js to run TypeScript applications. You can check your Node.js version by typing node -v in your terminal or command prompt.
  • Basic command line knowledge, such as navigating to folders.

πŸš€ Getting Started

  1. Visit the Releases Page
    Click the link below to access the download page:

    Visit the Releases Page

  2. Download the Latest Release
    Once on the page, look for the latest version of the library. You will see a list of available files. Download the appropriate file for your system.

  3. Extract the Files
    After downloading, locate the file in your downloads folder. If it's a zipped file, right-click and select "Extract All" to access its contents.

  4. Install the Library
    Open your terminal or command prompt. Navigate to the folder where you extracted the files. To install the library, run the following command:

    npm install ./<folder-name>
    

    Replace <folder-name> with the name of the folder where you extracted the files.

  5. Test the Installation
    To ensure the library is set up correctly, create a new TypeScript file. Add the following import statement at the top of your file:

    import { Result } from 'result';

    If you don’t see any errors when saving the file, the installation was successful!

πŸ“˜ Usage

To use the library in your TypeScript application:

  1. Import it at the beginning of your file as shown above.
  2. Use the Result class to manage success and error states in your functions.

Here’s a simple example:

import { Result } from 'result';

function divide(a: number, b: number): Result<number> {
    if (b === 0) {
        return Result.error('Cannot divide by zero');
    }
    return Result.ok(a / b);
}

const result = divide(10, 2);
result.match({
    ok: (value) => console.log(value),
    error: (message) => console.error(message),
});

πŸ“‚ Documentation

For detailed usage, check the documentation on our GitHub page. This includes various patterns and examples to help you get the most from the library.

πŸ’‘ Support

If you encounter issues or have questions, you can reach out by opening an issue on the GitHub repository. We are here to help!

πŸ–±οΈ Additional Resources

  • Explore various examples of how to use the library effectively.
  • Check our FAQ section to address common issues faced by users.
  • Join our community discussions to share ideas and find best practices.

🎯 Next Steps

  1. Experiment: Try integrating the library into your own projects.
  2. Explore: Look through the provided examples and documentation for more advanced usage.
  3. Contribute: If you find improvements or have ideas, consider contributing to the codebase.

πŸ”— Download & Install

To download the library, click the link below:

Download from Releases Page

This guide will help you navigate through the installation and start using the result library in your applications. Enjoy simplifying your error handling in TypeScript!

Releases

No releases published

Packages

 
 
 

Contributors