An conceptual javascript utility library for array-like objects requiring a very limited interface:
var ArrayLike = function () {
this.length = 0;
/* iteration */
this.reduce = function (callback[, initialValue]) {};
/* mutation */
this.splice = function (start, deleteCount[, item1[, item2[, ...]]]) {};
};
The objectives is to clearly demonstrate the flexibility of Array#reduce
, Array#splice
and then to a lesser extent... you know... be accurate and robust. That being said, there is a smattering of unit tests to back it up.
- reduce, foldl, inject
- reduceRight, foldr
- map, collect
- forEach, each
- filter, select
- reject
- contains, includes, include
- compact
- some, any
- all, every
- find, detect
- findIndex
- first, head, take
- rest, tail, drop
- groupBy
- countBy
- indexBy
- partition
- flatten
- shuffle
- sample
- reverse
- min, max
- intersection
- union
- unique, uniq
- invoke
- slice
- random
- negate
- identity
- toArray