Skip to main content
Module

x/fun/record.ts>filterMap

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

Given a function over the values in a ReadonlyArray returning an Option, return a function thatsimultaneously filters and maps over the values in a ReadonlyRecord.

Examples

Example 1

import * as R from "./record.ts";
import * as O from "./option.ts";
import { pipe } from "./fn.ts";

const result = pipe(
  { one: 1, two: 2, three: 3 },
  R.filterMap(n => n > 1 ? O.some(`${n} is big enough`) : O.none),
); // { two: "2 is big enough", three: "3 is big enough" }

Parameters

fai: (a: A, key: string) => Option<I>