Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/core/mod.ts>Transformer.distinctPrevious

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

Returns a 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

Stream.of(1, 1, 2, 3, 2, 2)
  .transform(Transformer.distinctPrevious())
  .toArray()
// => [1, 2, 3, 2]

Parameters

optional
options: { eq?: Eq<T> | undefined; negate?: boolean | undefined; } = [UNSUPPORTED]
  • eq - (default: Eq.objectIs) the equality testing function
  • negate: (default: false) when true will negate the given predicate