@ruffy/ts-optional
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Node.js CI codecov

Optional

This repository provides an optional type that allows for cleaner code when dealing with operations that would otherwise return undefined

Features

Refer to the API documentation to see available classes and their functions.

Requirements

  • Node and npm
  • To build or develop you will benefit from having npx https://github.com/npm/npx. This allows invoking of the other global npm requirements in the repository (Typescript, Jest) without having to install them.

Usage

You can install the package using

npm i -S @ruffy/ts-optional

You can then use the classes direct as:

Optional.of(undefined) === None.nil
Optional.of(2) === new Some(2)

or you can use the provided helper functions for cleaner code:

optional(undefined) === none
optional(2) === some(2)

Contributing

Contributions, if they are in line with Monad logic are welcome. Requirements for pull requests are:

  • All code is tested
  • Naming is consistent with project naming
  • Commits are squashed and contain commit messages according to RFC: Commit Message Guidelines

License

MIT

Package Sidebar

Install

npm i @ruffy/ts-optional

Weekly Downloads

432

Version

1.1.1

License

MIT

Unpacked Size

48 kB

Total Files

27

Last publish

Collaborators

  • ruffythepirate