(collection, grouper, context)
| 382 | } |
| 383 | |
| 384 | export function groupByFactory(collection, grouper, context) { |
| 385 | const isKeyedIter = isKeyed(collection); |
| 386 | const groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable(); |
| 387 | collection.__iterate((v, k) => { |
| 388 | groups.update( |
| 389 | grouper.call(context, v, k, collection), |
| 390 | (a) => ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a) |
| 391 | ); |
| 392 | }); |
| 393 | const coerce = collectionClass(collection); |
| 394 | return groups.map((arr) => reify(collection, coerce(arr))).asImmutable(); |
| 395 | } |
| 396 | |
| 397 | export function partitionFactory(collection, predicate, context) { |
| 398 | const isKeyedIter = isKeyed(collection); |
no test coverage detected