@extra-iterable/partition.min

Segregates values by test result. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Usage no npm install needed!

<script type="module">
  import extraIterablePartitionMin from 'https://cdn.skypack.dev/@extra-iterable/partition.min';
</script>

README

Segregates values by test result. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Alternatives: partition, partitionAs.
Similar: count, partition.

This is part of package extra-iterable.

This is browserified, minified version of @extra-iterable/partition.
It is exported as global variable iterable_partition.
CDN: unpkg, jsDelivr.


iterable.partition(x, ft);
// x:  an iterable
// ft: test function (v, i, x)
// → [satisfies, doesnt]
const iterable = require("extra-iterable");

var x = [1, 2, 3, 4];
iterable.partition(x, v => v % 2 == 0);
// [ [ 2, 4 ], [ 1, 3 ] ]

var x = [1, 2, 3, 4, 5];
iterable.partition(x, v => v % 2 == 1);
// [ [ 1, 3, 5 ], [ 2, 4 ] ]


References