# tochkak-maybe

> Implementation of monad Maybe in javascript.

Latest version **1.0.1** (published 2017-04-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install tochkak-maybe
pnpm add tochkak-maybe
yarn add tochkak-maybe
bun add tochkak-maybe
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-04-25 |
| First published | 2017-04-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Gavrilov S.O. |
| Maintainers | vismu |
| Keywords | tochkak, tk, maybe |

## Links

- npm: https://www.npmjs.com/package/tochkak-maybe
- Repository: https://bitbucket.tochkak.ru:7999/js/tochkak-maybe
- npm.io page: https://npm.io/package/tochkak-maybe

## Recent versions

- 1.0.1 (latest) — 2017-04-25
- 1.0.0 — 2017-04-25

## README

Implementation of monad Maybe in javascript.
It used for working with data wich may not exist in runtime.

```javascript
class Maybe {
	static of = (value) => new Maybe(value); // method for creating Maybe container

	constructor(value) {
		this.value = value;
	}

	isNothing() { // method for checking that Maybe value exist or not
		return (
			this.value === null ||
			this.value === undefined ||
			Number.isNaN(this.value)
		);
	}

	isJust() { // antonim of isNothing method
		return !this.isNothing();
	}

	map(transform) { // method for safely working with Maybe value
		return this.isNothing() ? Maybe.of(null) : Maybe.of(transform(this.value));
	}

	get() { // method for extract Maybe value
		return this.value;
	}

	getOrElse(defaultValue) { // method for extract Maybe value with default value
		return this.isJust() ? this.value : defaultValue;
	}
}
```

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