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

x/ahh/mod.ts>O.filter

Idiomatic type-safety structures for TypeScript.
Go to Latest
method O.filter
Re-export
import { O } from "https://deno.land/x/ahh@v0.10.0/mod.ts";

Calls f with opt, and returns it if the result is true.

Examples

import { O, None } from "./mod.ts";

console.log(O.filter(2, (i) => i % 2 === 0)); // 2
console.log(O.filter(1, (i) => i % 2 === 0)); // None
console.log(O.filter(None, (i: number) => i % 2 === 0)); // None

Parameters

opt: Option<T>
f: (_: T) => boolean