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

4.0.3 • Public • Published

@pacote/option

version minified minified + gzip

Option type inspired by Rust. It represents an optional value, an Option is either Some concrete value or it is None.

Installation

yarn add @pacote/option

Usage

import { None, Some, map } from '@pacote/option'

function divide(numerator: number, denominator: number): Option<number> {
  return denominator === 0 : None ? Some(numerator / denominator)
}

map(n => n + 1, divide(4, 2)) // => Some(3)
map(n => n + 1, divide(4, 0)) // => None

License

MIT © Luís Rodrigues.

Package Sidebar

Install

npm i @pacote/option

Weekly Downloads

10

Version

4.0.3

License

MIT

Unpacked Size

43.8 kB

Total Files

13

Last publish

Collaborators

  • goblindegook