Skip to main content
Module

x/fun/record.ts>isSubrecord

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

Given an instance of Comparable for the values in a ReadonlyRecord return a curried function second => first => boolean that returns true when first is a subrecord of second.

Examples

Example 1

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

const first = { one: 1, two: 2 };
const second = { one: 1, two: 2, three: 3 };
const isSub = R.isSubrecord(ComparableNumber);

const result1 = pipe(
  first,
  isSub(second),
); // true
const result2 = pipe(
  second,
  isSub(first),
); // false

Returns

(second: ReadonlyRecord<A>) => (first: ReadonlyRecord<A>) => boolean