MCPcopy Index your code
hub / github.com/immutable-js/immutable-js / partitionFactory

Function partitionFactory

src/Operations.js:397–407  ·  view source on GitHub ↗
(collection, predicate, context)

Source from the content-addressed store, hash-verified

395}
396
397export 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
409export function sliceFactory(collection, begin, end, useKeys) {
410 const originalSize = collection.size;

Callers 1

partitionFunction · 0.90

Calls 6

isKeyedFunction · 0.90
collectionClassFunction · 0.85
reifyFunction · 0.85
pushMethod · 0.65
mapMethod · 0.65
__iterateMethod · 0.45

Tested by

no test coverage detected