1.0.3 • Published 6 years ago

ts-optional-class v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Optional

npm Build Coverage Status Code style: prettier License

Optional for Typescript inspired by the Java Optional.

Install

npm install --save ts-optional-class

Usage

Example:

import {Optional} from '@ama-team/optional'

const fraudulent = Optional
  .of(user)
  .map(user => user.processors)
  .map(processors => processors.fraud)
  .map(metadata => metadata.fraudulent)
  .orElse(false);

API

You have four ways to create an optional:

Optional.empty();
Optional.of(value); // throws error if value is null
Optional.ofNullable(value);
Optional.ofAnything(value); // throws error if value is undefined
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago