includesValue

import { includesValue } from "jsr:@ende/collections";

function

function includesValue<T>(record: Readonly<Record<string, T>>, value: T): boolean

Returns true if the given value is part of the given object, otherwise it returns false.

Note: this doesn't work with non-primitive values. For example, includesValue({x: {}}, {}) returns false.

record: Readonly<Record<string, T>>

The record to check for the given value.

value: T

The value to check for in the record.

Returns

true if the value is part of the record, otherwise false.

Example: Basic usage

import { includesValue } from "@ende/collections/includes-value";
import { assertEquals } from "@ende/assert";

const input = {
  first: 33,
  second: 34,
};

assertEquals(includesValue(input, 34), true);

Source