Lodash - 集合
Lodash 拥有许多易于使用的方法,有助于处理集合。本章将详细讨论这些方法。
Lodash 提供各种方法来处理集合,如下所示:
| 序号 | 方法及语法 |
|---|---|
| 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]]) |