| 395 | } |
| 396 | |
| 397 | export function partitionFactory(collection, predicate, context) { |
| 398 | const isKeyedIter = isKeyed(collection); |
| 399 | const groups = [[], []]; |
| 400 | collection.__iterate((v, k) => { |
| 401 | groups[predicate.call(context, v, k, collection) ? 1 : 0].push( |
| 402 | isKeyedIter ? [k, v] : v |
| 403 | ); |
| 404 | }); |
| 405 | const coerce = collectionClass(collection); |
| 406 | return groups.map((arr) => reify(collection, coerce(arr))); |
| 407 | } |
| 408 | |
| 409 | export function sliceFactory(collection, begin, end, useKeys) { |
| 410 | const originalSize = collection.size; |