A Javascript utility library that works with Arrays chaining operations. It is inspired by the Java Streams API but only works with arrays.
It is using a lot of functionality from the wonderful lodash library. It could be said that this library is kind of a lodash wrapper.
This is still a work in progress, no stable version has been released!
Basic Samples:
import CaptainArray from 'CaptainArray';
const result = new CaptainArray([1, 4, 5, 7, 5, 4, 2]) // Initializing Array
.map(n => n * 2) // [2, 8, 10, 14, 10, 8, 4]
.filter(n => n >= 10) // [10, 14, 10]
.distinct() // [10, 14]
.sum(); // 24
import CaptainArray from 'CaptainArray';
const result = new CaptainArray(['peter', 'jhon', 'michael', 'melvin']) // Initializing Array
.sortAsc()
.join(' - '); //result is equal to:'jhon - melvin - michael - peter';
Current operations list:
- average
- concat
- count
- distinct
- filter
- first
- join
- last
- limit
- map
- max
- min
- skip
- sortAsc
- sortDesc
- sum
- forEach
- range