1.3.5 • Published 3 months ago

yarut v1.3.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

yarut - Yet Another Result Utility for Typescript

A result/option utility for typescript.

import { Result, Ok, Err } from "yarut";

const apiCall = (): Result<string, Error> => {
    return ResultUtil.Ok("All good!");
}
const result = apiCall();

// With help of these type guards, either `value` or `error` is available
if (result.isOk()) {
    console.log("It works!", result.value);
} else {
    console.log("Oh no :(", result.error);
}

Features

  • Result - Encode errors as type information and explicitly handle them
  • Option - Don't use null/undefined to express values that doesn't exist. Use None and Some to indicate it.

Superjson support

import {optionSuperRegisterRecipe, resultSuperRegisterRecipe } from "yarut";
import superjson from "superjson";

superjson.registerCustom(resultSuperRegisterRecipe(superjson), "yarut/Result");
superjson.registerCustom(optionSuperRegisterRecipe(superjson), "yarut/Option");

Acknowledgements

Inspired by the work of @swan-io/boxed

1.3.5

3 months ago

1.3.4

3 months ago

1.3.2

3 months ago

1.3.1

3 months ago

1.3.0

5 months ago

1.2.0

5 months ago

1.1.1

5 months ago

1.1.0

6 months ago

1.0.1

6 months ago