JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q53169F
  • License MIT

Option type inspired by Rust.

Package Exports

  • @pacote/option
  • @pacote/option/lib/cjs/index.js
  • @pacote/option/lib/esm/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@pacote/option) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@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.