Skip to content

unmatched

Eugene Lazutkin edited this page Jun 26, 2026 · 1 revision

unmatched

Emit rows of a primary stream whose key is absent from a probe stream — a sorted-stream anti-join filter. Whole rows pass through unchanged; there is no combine. The opposite of matching.

import unmatched from 'stream-sorting/sorted/unmatched.js';

// orders whose customerId is NOT in the bannedCustomers stream
for await (const order of unmatched(
  {input: orders, key: o => o.customerId},
  {input: bannedCustomers, key: c => c.id}
)) {
  // each order with no matching banned customer
}

primary and probe are {input, key?} descriptors, each sorted by its key (key defaults to identity). The result is an AsyncIterable of primary's rows. Primary duplicates are preserved; probe duplicates are ignored.

Options

Option Type Default Description
compareKey (a, b) => number natural order Orders keys. compareKey OR lessKey. Composite keys need an explicit one.
lessKey (a, b) => boolean Strict-less key comparator. compareKey OR lessKey.

Closely related to keyed difference, but it keeps the primary's whole rows rather than emitting surviving values. An out-of-order primary throws at runtime.

See also

matching, join, difference.

Clone this wiki locally