import { isRecord } from "https://dotland.deno.dev/x/unknownutil@v3.18.0/mod.ts";
Return true
if the type of x
satisfies Record<PropertyKey, unknown>
.
Note that this function returns true
for ambiguous instances like Set
, Map
, Date
, Promise
, etc.
import { is } from "@core/unknownutil";
const a: unknown = {"a": 0, "b": 1};
if (is.Record(a)) {
// a is narrowed to Record<PropertyKey, unknown>
const _: Record<PropertyKey, unknown> = a;
}
const b: unknown = new Set();
if (is.Record(b)) {
// b is narrowed to Record<PropertyKey, unknown>
const _: Record<PropertyKey, unknown> = b;
}