# @9oelm/maybe

> ```bash npm i --save @9oelm/maybe

Latest version **1.0.0** (published 2020-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @9oelm/maybe
pnpm add @9oelm/maybe
yarn add @9oelm/maybe
bun add @9oelm/maybe
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-12-12 |
| First published | 2020-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | 9oelM |
| Maintainers | 9oelm |

## Links

- npm: https://www.npmjs.com/package/@9oelm/maybe
- Repository: https://github.com/9oelM/maybe
- npm.io page: https://npm.io/package/@9oelm/maybe

## Recent versions

- 1.0.0 (latest) — 2020-12-12
- 0.1.1 — 2020-12-12
- 0.1.0 — 2020-12-12

## README

# maybe

```bash
npm i --save @9oelm/maybe

yarn add @9oelm/maybe
```

Just my personal util for handling `null` and `undefined`.

## Usage

```ts
import { maybe } from '@9oelm/maybe'

const mayBeNullOrUndefined: HTMLElement | null = document.querySelector('#maybe-exists');

const text: string = 
  maybe(maybeNullOrUndefined)
  .then(({ innerText }) => innerText)
  .otherwise(`please fill out text first`);

// omit .then to just receive the defined value itself
const someHTMLElementOrMyFallbackHtmlElement: HTMLElement = 
  maybe(mayBeNullOrUndefined).otherwise(document.createElement('div'))
```

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