Lodash – Collection
”;
Lodash has many easy to use methods which helps in processing Collections. This chapter discusses them in detail.
Lodash provides various methods to process the Collections as listed below −
Sr.No. | Method & Syntax |
---|---|
1 |
_.countBy(collection, [iteratee=_.identity]) |
2 |
_.every(collection, [predicate=_.identity]) |
3 |
_.filter(collection, [predicate=_.identity]) |
4 |
_.find(collection, [predicate=_.identity], [fromIndex=0]) |
5 |
_.findLast(collection, [predicate=_.identity], [fromIndex=collection.length-1]) |
6 |
_.flatMap(collection, [iteratee=_.identity]) |
7 |
_.flatMapDeep(collection, [iteratee=_.identity]) |
8 |
_.flatMapDepth(collection, [iteratee=_.identity], [depth=1]) |
9 |
_.forEach(collection, [iteratee=_.identity]) |
10 |
_.forEachRight(collection, [iteratee=_.identity]) |
11 |
_.groupBy(collection, [iteratee=_.identity]) |
12 |
_.includes(collection, value, [fromIndex=0]) |
13 |
_.invokeMap(collection, path, [args]) |
14 |
_.keyBy(collection, [iteratee=_.identity]) |
15 |
_.map(collection, [iteratee=_.identity]) |
16 |
_.orderBy(collection, [iteratees=[_.identity]], [orders]) |
17 |
_.partition(collection, [predicate=_.identity]) |
18 |
_.reduce(collection, [iteratee=_.identity], [accumulator]) |
19 |
_.reduceRight(collection, [iteratee=_.identity], [accumulator]) |
20 |
_.reject(collection, [predicate=_.identity]) |
21 |
_.sample(collection) |
22 |
_.sampleSize(collection, [n=1]) |
23 |
_.shuffle(collection) |
24 |
_.size(collection) |
25 |
_.some(collection, [predicate=_.identity]) |
26 |
_.sortBy(collection, [iteratees=[_.identity]]) |
”;