// Copyright 2018-2026 the Deno authors. MIT license. // This module is browser compatible. /** * 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. * * @typeParam T The type of the values in the input record. * * @param record The record to check for the given value. * @param value The value to check for in the record. * * @returns `true` if the value is part of the record, otherwise `false`. * * @example Basic usage * ```ts * import { includesValue } from "includes_value.ts"; * import { assertEquals } from "../assert/mod.ts"; * * const input = { * first: 33, * second: 34, * }; * * assertEquals(includesValue(input, 34), true); * ``` */ export function includesValue( record: Readonly>, value: T, ): boolean { for (const i in record) { if ( Object.hasOwn(record, i) && (record[i] === value || Number.isNaN(value) && Number.isNaN(record[i])) ) { return true; } } return false; }