Skip to main content
Module

x/rimbu/mod.ts>AsyncTransformer.distinctPrevious

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
function AsyncTransformer.distinctPrevious
import { AsyncTransformer } from "https://deno.land/x/rimbu@1.1.0/mod.ts";
const { distinctPrevious } = AsyncTransformer;

Returns an async transformer that returns only those elements from the input that are different to previous element according to the optionally given eq function.

Examples

Example 1

await AsyncStream.of(1, 1, 2, 3, 2, 2)
  .transform(AsyncTransformer.distinctPrevious())
  .toArray()
// => [1, 2, 3, 2]

Parameters

optional
options: { eq?: Eq<T>; negate?: boolean; } = [UNSUPPORTED]
  • (optional) object specifying the following properties
  • eq: (default: Eq.objectIs) the Eq instance to use to test equality of elements
  • negate: (default: false) when true will negate the given predicate