# kobako-maybe

> Yet another Maybe type written by vanilla.js

Latest version **1.2.2** (published 2018-06-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install kobako-maybe
pnpm add kobako-maybe
yarn add kobako-maybe
bun add kobako-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.2.2 |
| Published | 2018-06-10 |
| First published | 2018-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | kobako |
| Maintainers | kobako |

## Links

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

## Recent versions

- 1.2.2 (latest) — 2018-06-10
- 1.2.1 — 2018-06-09
- 1.2.0 — 2018-06-09
- 1.1.0 — 2018-06-09
- 1.0.0 — 2018-06-09

## README

# Maybe

Yet another Maybe type written by vanilla.js

Inspired by Haskell's Maybe type

Can be used in browser,node and requireJs

## Installation

On browser or requireJs, just copy the `src/maybe.js` to desired path then use like this

```html
<script src="/yourpath/maybe.js"></script>
<script>
  // Lib export 'M' to global
  console.log(M.or(M.just('Hello kobako-maybe'),'Oh no'))
</script>
```

By npm

```
$ npm install kobako-maybe
```

## Usage

Import the lib:

```js
const M = require('kobako-maybe')
```

Use the `just` of `nothing` function to create a `Maybe` type from a value

```js
const value = M.just(1)

M.isJust(value) //true
M.isNothing(value) //false

const val2 = M.nothing()

M.isJust(val2) //false
M.isNothing(val2) //true
```

Use `map` to lift a function: you can use a traditional function on a Maybe value

```js
const value = M.just(1)
const nothing = M.nothing()

M.map(x => x+1, value) //Just 2
M.map(x => x+1, nothing) //Nothing
```

Use `or` to unwrap value from Maybe

```js
M.or(M.just(1),-1) //1
M.or(M.nothing(),-1) //-1
```

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