npm package: @munierujp/super-set
Description: SuperSet class extends Set and add some methods, such as higher-order function.
Latest version: 1.0.0

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

# SuperSet.js
SuperSet class extends Set and add some methods, such as higher-order function.

## Installation
```sh
$ npm i @munierujp/super-set
```

or

```sh
$ yarn add @munierujp/super-set
```

## Use in your script
```js
const SuperSet = require('@munierujp/super-set')
```

## Usage
You can use Set's self methods and below additional methods.

### Creation
#### SuperSet.empty()
```js
const set = SuperSet.empty()
console.log(set) // {}
```

#### SuperSet.of(...values)
```js
const set = SuperSet.of('foo', 'bar')
console.log(set) // { 'foo', 'bar' }
```

#### SuperSet.from(iterable)
```js
const set = new Set(['foo', 'bar'])
const superSet = SuperSet.from(set)
console.log(superSet) // { 'foo', 'bar' }
```

### Intermediate operation
#### SuperSet.peek(callback)
```js
const set = SuperSet.of('foo', 'bar')
const tmpArray = []
const peekedSet = set.peek(v => tmpArray.push(v))
console.log(peekedSet) // { 'foo', 'bar' }
console.log(tmpArray) // [ 'foo', 'bar' ]
```

#### SuperSet.peek(callback, thisArg)
```js
const set = SuperSet.of('foo', 'bar')
const thisArg = 'baz'
const tmpArray = []
const peekedSet = set.peek(function (v) {
  tmpArray.push(v + this)
}, thisArg)
console.log(peekedSet) // { 'foo', 'bar' }
console.log(tmpArray) // [ 'foobaz', 'barbaz' ]
```

#### SuperSet.filter(matcher)
```js
const set = SuperSet.of('foo', 'bar')
const filteredSet = set.filter(v => v.startsWith('f'))
console.log(filteredSet) // { 'foo' }
```

#### SuperSet.map(mapper)
```js
const set = SuperSet.of('foo', 'bar')
const mappedSet = set.map(v => v + '_')
console.log(mappedSet) // { 'foo_', 'bar_' }
```

### Terminal operation
#### SuperSet.find(matcher)
```js
const set = SuperSet.of('foo', 'bar')
const value = set.find(v => v.startsWith('f'))
console.log(value) // foo
```

```js
onst set = SuperSet.empty()
const value = set.find(v => v.startsWith('f'))
console.log(value) // undefined
```

#### SuperSet.some(matcher)
```js
const set = SuperSet.of('foo', 'bar')
console.log(set.some(v => v.startsWith('f'))) // true
```

```js
const set = SuperSet.empty()
console.log(set.some(v => v.startsWith('f'))) // false
```

#### SuperSet.every(matcher)
```js
const set = SuperSet.of('foo', 'bar')
console.log(set.every(v => v.length === 3)) // true
```

```js
const set = SuperSet.of('foo', 'bar')
console.log(set.every(v => v.startsWith('f'))) // false
```

#### SuperSet.isEmpty()
```js
const set = SuperSet.of('foo', 'bar')
console.log(set.isEmpty()) // false
```

```js
const set = SuperSet.empty()
console.log(set.isEmpty()) // true
```

#### SuperSet.isNotEmpty()
```js
const set = SuperSet.of('foo', 'bar')
console.log(set.isNotEmpty()) // true
```

```js
const set = SuperSet.empty()
console.log(set.isNotEmpty()) // false
```

#### SuperSet.toArray()
```js
const set = SuperSet.of('foo', 'bar')
const values = set.toArray()
console.log(values) // [ 'foo', 'bar' ]
```

#### SuperSet.toSet()
```js
const superSet = SuperSet.of('foo', 'bar')
const set = superSet.toSet()
console.log(set) // { 'foo', 'bar' }
```