Function includesValue

  • 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.

    Type Parameters

    • T

      The type of the values in the input record.

    Parameters

    • record: Readonly<Record<string, T>>

      The record to check for the given value.

    • value: T

      The value to check for in the record.

    Returns boolean

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

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

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

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