# optionalj

> A container object which may or may not contain a non-null value. If a value is present, isPresent() will return true and get() will return the value.

Latest version **0.1.0** (published 2018-12-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install optionalj
pnpm add optionalj
yarn add optionalj
bun add optionalj
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-12-02 |
| First published | 2018-12-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Pawel Rusek |
| Maintainers | sekru |

## Links

- npm: https://www.npmjs.com/package/optionalj
- npm.io page: https://npm.io/package/optionalj

## Recent versions

- 0.1.0 (latest) — 2018-12-02

## README

# Optional

How use:
```
    Optional.ofNullable(null).get() // null 

    Optional.of(null).get(); // throw error about null value

    Optional.ofNullable('foo').map(value => value + 'bar').get(); // foobar

    Optional.ofNullable(null).map(value => value + 'bar').get(); // null

    Optional.ofNullable(['foo', 'bar']).map(value => value + 'bar').get(); // ['foobar', 'barbar']

    Optional.ofNullable(20).filter(value => value > 15).get(); // 20

    Optional.ofNullable(20)
            .filter(value => value > 25)
            .orElse(value => value + 10).get(); // 30

    Optional.ofNullable(20)
            .filter(value => value > 25)
            .orElseThrow(Error('Invalid value')); // throw error

    Optional.ofNullable([20, 14]).filter(value => value > 15).get(); // [20]
```

---
_Source: https://npm.io/package/optionalj · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
