2.0.0 • Published 10 months ago
@miyauci/result v2.0.0
result
Minimum result type port of Rust.
Option version.
Table of Contents
Install
deno.land:
import * as mod from "https://deno.land/x/result_js/mod.ts";
npm:
npm i @miyauci/result
Usage
Type Result represents an success or failure.
import {
Err,
Ok,
type Result,
unwrap,
} from "https://deno.land/x/result_js/mod.ts";
import { assertThrows } from "https://deno.land/std/testing/asserts.ts";
function divide(
numerator: number,
denominator: number,
): Result<number, string> {
if (!denominator) return Err("divide by 0");
return Ok(numerator / denominator);
}
const opt = divide(100, 0);
assertThrows(() => unwrap(opt));
All operators for Result are separated from prototype.
API
All APIs can be found in the deno doc.
Acknowledgements
Contributing
See contribution.
License
MIT © 2023 Tomoki Miyauchi
2.0.0-beta.2
10 months ago
2.0.0-beta.1
10 months ago
2.0.0
10 months ago
1.0.0
2 years ago
1.0.0-beta.2
2 years ago