open-index/open-npm huggingface dataset:
npm package: @munierujp/len
Description: Get length
Latest version: 1.0.0

[![npm version](https://badge.fury.io/js/%40munierujp%2Flen.svg)](https://badge.fury.io/js/%40munierujp%2Flen)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

# @munierujp/len

Get length
npm package: @munierujp/val
Description: Val class wraps value
Latest version: 1.0.0

[![npm version](https://badge.fury.io/js/%40munierujp%2Fval.svg)](https://badge.fury.io/js/%40munierujp%2Fval)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

# Val.js
Val class wraps value.

## Installation
```sh
$ npm i @munierujp/val
```

or

```sh
$ yarn add @munierujp/val
```

## Use in your script
```js
const Val = require('@munierujp/val')
```

## Usage
You can use below methods.

### Creation
#### Val.empty()
```js
const val = Val.empty()
console.log(val) // { _: null }
```

#### Val.of(value)
```js
const val = Val.of('foo')
console.log(val) // { _: 'foo' }
```

### Intermediate operation
#### Val.filter(matcher)
```js
const val = Val.of('foo')
const filtered = val.filter(v => v.startsWith('f'))
console.log(filtered) // { _: 'foo' }
```

```js
const val = Val.of('foo')
const filtered = val.filter(v => v.startsWith('b'))
console.log(filtered) // { _: null }
```

#### Val.map(mapper)
```js
const val = Val.of('foo')
const mapped = val.map(v => v + '_')
console.log(mapped) // { _: 'foo_' }
```

```js
const val = Val.empty()
const mapped = val.map(v => v + '_')
console.log(mapped) // { _: null }
```

#### Val.ifPresent(callback)
```js
const val = Val.of('foo')
let tmp
const val2 = val.ifPresent(v => {
  tmp = v
})
console.log(val2) // { _: 'foo' }
console.log(tmp) // foo
```

```js
const val = Val.empty()
let tmp
const val2 = val.ifPresent(v => {
  tmp = v
})
console.log(val2) // { _: null }
console.log(tmp) // undefined
```

#### Val.ifAbsent(callback)
```js
const val = Val.of('foo')
let tmp
const val2 = val.ifAbsent(() => {
  tmp = 'bar'
})
console.log(val2) // { _: 'foo' }
console.log(tmp) // undefined
```

```js
const val = Val.empty()
let tmp
const val2 = val.ifAbsent(() => {
  tmp = 'bar'
})
console.log(val2) // { _: null }
console.log(tmp) // bar
```

#### Val.or(other)
```js
const val = Val.of('foo')
const value = val.or('bar')
console.log(value) // foo
```

```js
const val = Val.empty()
const value = val.or('bar')
console.log(value) // bar
```

#### Val.is(value)
```js
const val = Val.of('foo')
console.log(val.is('foo')) // true
```

```js
const val = Val.of('foo')
console.log(val.is('bar')) // false
```

#### Val.isPresent()
```js
const val = Val.of('foo')
console.log(val.isPresent()) // true
```

```js
const val = Val.empty()
console.log(val.isPresent()) // false
```

#### Val.isAbsent()
```js
const val = Val.of('foo')
console.log(val.isAbsent()) // false
```

```js
const val = Val.empty()
console.log(val.isAbsent()) // true
```