unwrap-or
v1.0.8
Published
A TypeScript implementation of Rust's Option and Result types.
Maintainers
Readme
It is a playground library that closely mirrors Rust's Option and Result API. While created primarily for fun and learning, it's robust enough for real-world applications. It allows for safer, more expressive handling of optional values through a monadic interface. Snake_case is used for the plausibility of the original.
Use it to:
- eliminate
nullchecks - make optional logic explicit
- chain transformations on values that might not exist
- handle errors gracefully
The name unwrap-or is a reference to the unwrap_or method in the
Option/Result types and a combination of the first letters "-OR" of two
monads for Option and Result types. It also relfects the logical OR
operation reflecting two possible states.
Installation
Via npm:
npm install unwrap-orYou can also use your favorite package manager:
# pnpm
pnpm add unwrap-or
# deno
deno add jsr:@lab/unwrap-or
# bun
bun add unwrap-or
# yarn
yarn add unwrap-orOverview
See the documentation for unwrap-or usage, module specifications and API/methods details:
Inspirations
fnts - minimal functional programming utilities for TypeScript & JavaScript inspired by the programming language Haskell.
ts-expression - pair constructor, binary representation, a minimal implementation of
Lisp's symbolic expressions (s-expressions) for TypeScript.
License
Made by a human being, not LLM.
Copyright © 2025 Roman Hnatiuk
Licensed under MIT.
