Skip to main content
Module

x/rimbu/mod.ts>Reducer.contains

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

Returns a Reducer that outputs false as long as the given elem has not been encountered the given amount of times in the input values, true otherwise.

Examples

Example 1

console.log(Stream.range({ amount: 10 }).reduce(Reducer.contains(5)))
// => true

Type Parameters

T
optional
T2 extends T = T

Parameters

elem: T2
  • the element to search for
optional
options: { amount?: number; eq?: Eq<T | T2>; negate?: boolean; } = [UNSUPPORTED]
  • (optional) an object containing the following properties:
  • amount: (detaulf: 1) the amount of elements to find
  • eq: (default: Eq.objectIs) the Eq instance to use to compare elements
  • negate: (default: false) when true will invert the given predicate

Returns

Reducer<T, boolean>