Open
Description
From #75, isObjectOf
accept Function
with Object.assign
. Additionally, it accept string
, number
, bigint
, boolean
, object
, and symbol
natively. So isObjectOf
currently support almost all object except Array
like
import { is } from "./mod.ts";
const isMyType = is.ObjectOf({
a: is.Number,
b: is.String,
c: is.Boolean,
});
const myType = { a: 0, b: "a", c: true };
const cases = [
"string",
100,
100n,
true,
["a", "b", "c"],
{},
() => {},
Symbol("symbol"),
];
cases.forEach((c) => {
const x = Object.assign(c, myType);
console.log(c, isMyType(x));
});
Only array result become false
string true
100 true
100n true
true true
[ "a", "b", "c", a: 0, b: "a", c: true ] false
{ a: 0, b: "a", c: true } true
[Function (anonymous)] { a: 0, b: "a", c: true } true
Symbol(symbol) true