-
Notifications
You must be signed in to change notification settings - Fork 0
difference
Eugene Lazutkin edited this page Jun 26, 2026
·
1 revision
Values in the first stream not present in any of the remaining streams, deduplicated. {1,2,3} ∖ {2} = {1,3}.
import difference from 'stream-sorting/sorted/difference.js';
for await (const v of difference([primary, exclude1, exclude2])) {
// values from `primary` that appear in neither exclude stream
}streams is an array of sorted AsyncIterable<T> | Iterable<T>; streams[0] is the source and streams[1..] are subtracted from it. The result is an AsyncIterable<T>, each surviving value emitted once. With only one stream it deduplicates that stream.
| Option | Type | Default | Description |
|---|---|---|---|
compare |
(a, b) => number |
natural order | Orders items and defines equality. compare OR lessFn. |
lessFn |
(a, b) => boolean |
— | Strict-less comparator. compare OR lessFn. |
Two items are "equal" when the comparator ranks neither below the other. An out-of-order input throws when the offending item is reached.
union, intersection, merge, and the key-based filters matching / unmatched.