This TypeScript library provides Rust-like data structures, such as Result
and Option
, to facilitate error handling and value management in TypeScript projects.
- Result: A type that represents either a success (
Ok
) or a failure (Err
). - Option: A type that represents an optional value, either
Some
orNone
. - JSON-RPC: Utilities for working with JSON-RPC, enabling remote procedure calls.
- Deno runtime.
Clone the repository and navigate to the project directory:
git clone https://github.com/yourusername/your-repo.git
cd your-repo
Use the following command to start the development server with Deno:
deno task dev
This command runs the index.ts
file with the --watch
flag, enabling live reloading during development.
The Option
type represents an optional value, either Some
or None
.
import { Option, Some, None } from './option.ts';
const value: Option<number> = Some(5);
const empty: Option<number> = None;
console.log(value.isSome()); // true
console.log(empty.isNone()); // true
The Result
type represents either a success (Ok
) or a failure (Err
).
import { Result, Ok, Err } from './result.ts';
const success: Result<number, string> = Ok(10);
const failure: Result<number, string> = Err('An error occurred');
console.log(success.isOk()); // true
console.log(failure.isErr()); // true
Utilities for working with JSON-RPC.
import { JsonRpc } from './json_rpc.ts';
// Example usage of JSON-RPC utilities
index.ts
: Entry point for the library.option.ts
: Implementation of theOption
type.result.ts
: Implementation of theResult
type.json_rpc.ts
: Utilities for JSON-RPC.error_enum.ts
: Error enumeration used across the library.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or additions.
This project is licensed under the MIT License.
Inspired by Rust's Result
and Option
types.