Skip to main content
Module

x/ahh/mod.ts>O.filter

Idiomatic type-safety functions.
Go to Latest
method O.filter
Re-export
import { O } from "https://deno.land/x/ahh@v0.10.1/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