import { isObjectOf } from "https://deno.land/x/unknownutil@v3.1.0/is.ts";
Return a type predicate function that returns true
if the type of x
is ObjectOf<T>
.
When options.strict
is true
, the number of keys of x
must be equal to the number of keys of predObj
.
Otherwise, the number of keys of x
must be greater than or equal to the number of keys of predObj
.
import is from "./is.ts";
const predObj = {
a: is.Number,
b: is.String,
c: is.Boolean,
};
const a: unknown = { a: 0, b: "a", c: true };
if (is.ObjectOf(predObj)(a)) {
// a is narrowed to { a: number, b: string, c: boolean }
const _: { a: number, b: string, c: boolean } = a;
}
Parameters
predObj: T