Skip to main content
Module

x/rimbu/mod.ts>Match.createAny

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

Returns a function that takes a value of type T, and returns true if the value matches any of the given matches array of Match instances.

Examples

Example 1

type Person = { name: string, age: number }
const m = Match.createAny<Person>({ age: v => v > 20 }, { name: v => v.length > 2 })

console.log(m({ name: 'abc', age: 10 }))
// => true
console.log(m({ name: 'abc', age: 20 }))
// => true
console.log(m({ name: 'a', age: 20 }))
// => true
console.log(m({ name: 'a', age: 10 }))
// => false

Type Parameters

T
optional
T2 extends T = T

Parameters

...matches: Match.Multi<T2>
  • at least one Match instance to perform on a given value

Returns

(value: T) => boolean