Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nescalante/very-array
Javascript arrays helper LINQ style
https://github.com/nescalante/very-array
Last synced: 20 days ago
JSON representation
Javascript arrays helper LINQ style
- Host: GitHub
- URL: https://github.com/nescalante/very-array
- Owner: nescalante
- License: mit
- Created: 2013-11-29T19:52:31.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-01-21T12:54:44.000Z (almost 7 years ago)
- Last Synced: 2024-11-11T14:12:30.300Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 182 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Such array library](https://raw.github.com/nescalante/very-array/master/resources/such-dog.jpg)
# Very Array [![Build Status](https://travis-ci.org/nescalante/very-array.svg?branch=master)](https://travis-ci.org/nescalante/very-array) [![Greenkeeper badge](https://badges.greenkeeper.io/nescalante/very-array.svg)](https://greenkeeper.io/)
*Such functional array helper*
# Install
```shell
npm install very-array --savebower install very-array
```Many functions:
* skip:```js
va([1, 2, 3])
.skip(1); // [2, 3]
```* take:
```js
va([1, 2, 3])
.take(2); // [1, 2]
```* sum:
```js
va([{ a: 1 }, { a: 2 }, { a: 3 }])
.sum(function (i) { return i.a; }); // 6
```
* select:
```js
va([{ a: 1 }, { a: 2 }, { a: 3 }])
.select(function (i) { return i.a; }) // [1, 2, 3]
```* selectMany:
```js
va([{ a: [1, 2] }, { a: [3] }, { a: [4, 5, 6] }])
.selectMany(function (i) { return i.a; }) // [1, 2, 3, 4, 5, 6]
```
* contains:```js
va([1, 2, 3])
.contains(1); // true
```
* all:```js
va([1, 2, 3])
.all(function (i) { return i > 0; }); // true
```
* any:```js
va([1, 2, 3])
.any(function (i) { return i > 2; }); // true
```
* where:```js
va([1, 2, 3])
.where(function (i) { return i > 2; }); // [3]
```
* first:
```js
va([1, 2, 3])
.first(function (i) { return i > 1; }); // [2]
```* last:
```js
va([1, 2, 3])
.last(); // 3
```* distinct:
```js
va([1, 1, 2, 3, 3])
.distinct(); // [1, 2, 3]
```* groupBy:
```js
va([{ a: 1 }, { a: 1 }, { a: 2 }, { a: 3 }])
.groupBy(function (i) { return i.a; }); //Array[2], Array[1], Array[1]
```* orderBy:
```js
va([{ a: 2 }, { a: 1 }, { a: 3 }])
.orderBy(function (i) { return i.a; }); // [{ a: 1 }, { a: 2 }, { a: 3 }]
```
* orderByDescending:```js
va([{ a: 1 }, { a: 2 }, { a: 3 }])
.orderByDescending(function (i) { return i.a; }); // [{ a: 3 }, { a: 2 }, { a: 1 }]
```
* forEach:```js
va([1, 2, 3])
.forEach(function (item, index) { console.log(item) }); // 1, 2, 3
```Such prototype extension:
```js
va.extends(Array);[1, 2, 3].sum() // 6
```