https://github.com/aichbauer/bearray
A fun package with chainable higher order functions
https://github.com/aichbauer/bearray
Last synced: 10 months ago
JSON representation
A fun package with chainable higher order functions
- Host: GitHub
- URL: https://github.com/aichbauer/bearray
- Owner: aichbauer
- License: other
- Created: 2017-03-22T18:42:03.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-13T07:05:23.000Z (over 8 years ago)
- Last Synced: 2025-03-04T20:40:51.317Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 53.7 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bearray
[](https://travis-ci.org/aichbauer/bearray)
[](https://coveralls.io/github/aichbauer/bearray?branch=master)
> ʕ·ᴥ·ʔ says: "Hey there!"
## Installation
```sh
$ npm i bearray --save
```
or
```sh
$ yarn add bearray
```
## Methods
- [filter](#filter)
- [map](#map)
- [reduce](#reduce)
- [getValue](#getValue)
### filter
> Ƹ̵̡Ӝ̵̨̄Ʒ
Filter an array.
```js
import { ʕ·ᴥ·ʔ } from 'bearray';
const ᕕ·ᐛ·ᕗ = ʕ·ᴥ·ʔ([1, 2, 3, 4]).Ƹ̵̡Ӝ̵̨̄Ʒ((value, index) => {
return value % 2 === 0;
});
ᕕ·ᐛ·ᕗ.ʕᵔᴥᵔʔ() // [2, 4]
```
### map
> ʕʘ̅͜ʘ̅ʔ
Map over an array.
```js
import { ʕ·ᴥ·ʔ } from 'bearray';
const ᕕ·ᐛ·ᕗ = ʕ·ᴥ·ʔ([1, 2, 3, 4]).ʕʘ̅͜ʘ̅ʔ((value, index) => {
return value + value;
});
ᕕ·ᐛ·ᕗ.ʕᵔᴥᵔʔ() // [2, 4, 6, 8]
```
### reduce
> ಠ_ಠ
Reduce an array.
```js
import { ʕ·ᴥ·ʔ } from 'bearray';
const ᕕ·ᐛ·ᕗ = ʕ·ᴥ·ʔ([1, 2, 3, 4]).ಠ_ಠ((sum, current) => {
return sum + current;
});
ᕕ·ᐛ·ᕗ.ʕᵔᴥᵔʔ() // [10]
```
### getValue
> ʕᵔᴥᵔʔ
Get the value at the end of some chained operations (see other functions as well).
```js
import { ʕ·ᴥ·ʔ } from 'bearray';
const ᕕ·ᐛ·ᕗ = ʕ·ᴥ·ʔ([1, 2, 3, 4]);
ᕕ·ᐛ·ᕗ.ʕᵔᴥᵔʔ() // [1, 2, 3, 4]
```