@pacote/result
TypeScript icon, indicating that this package has built-in type declarations

4.0.2 • Public • Published

@pacote/result

version minified minified + gzip

Result type inspired by Rust. It represents either a success (Ok) or an error (Err).

Installation

yarn add @pacote/result

Example

import { Ok, Err, map } from '@pacote/result'

function divide(numerator: number, denominator: number): Option<number> {
  return denominator === 0 : Err('division by zero') ? Ok(numerator / denominator)
}

map(n => n + 1, divide(4, 2)) // => Ok(3)
map(n => n + 1, divide(4, 0)) // => Err('division by zero')

License

MIT © Luís Rodrigues.

/@pacote/result/

    Package Sidebar

    Install

    npm i @pacote/result

    Weekly Downloads

    1

    Version

    4.0.2

    License

    MIT

    Unpacked Size

    56.5 kB

    Total Files

    13

    Last publish

    Collaborators

    • goblindegook