Skip to main content
Module

x/fun/set.ts>filter

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function filter
import { filter } from "https://deno.land/x/fun@v2.0.0-alpha.10/set.ts";

Given a Refinement or Predicate over A and a ReadonlySet return a new ReadonlySet with only values for which the predicate or refinement return true.

Examples

Example 1

import * as S from "./set.ts";
import { pipe } from "./fn.ts";

const set = S.set(1, 2, 3, 4, 5);

const result1 = pipe(set, S.filter(n => n > 2)); // Set(3, 4, 5)
const result2 = pipe(set, S.filter(n => n === 0)); // Set()

Type Parameters

A
B extends A

Parameters

refinement: Refinement<A, B>

Returns

(ua: ReadonlySet<A>) => ReadonlySet<B>

Returns

(ua: ReadonlySet<A>) => ReadonlySet<A>