Skip to main content
Module

x/fun/record.ts>lookupWithKey

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

Lookup the value in a record at key and return an optional pair with the key and the value if the record holds the key. Returns None if the record does not hold the key.

Examples

Example 1

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

const result1 = pipe(
  { one: 1, two: 2 },
  R.lookupWithKey('one'),
); // Some(['one', 1])
const result2 = pipe(
  { one: 1, two: 2 },
  R.lookupWithKey('three'),
); // None

Parameters

key: string