Skip to content

Commit 51091e2

Browse files
committed
👍 isObjectOf allows function object
1 parent 748257e commit 51091e2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

is.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,11 @@ export function isObjectOf<
11451145
}
11461146
return setPredicateFactoryMetadata(
11471147
(x: unknown): x is ObjectOf<T> => {
1148-
if (x == null || typeof x !== "object" || Array.isArray(x)) return false;
1148+
if (
1149+
x == null ||
1150+
typeof x !== "object" && typeof x !== "function" ||
1151+
Array.isArray(x)
1152+
) return false;
11491153
// Check each values
11501154
for (const k in predObj) {
11511155
if (!predObj[k]((x as T)[k])) return false;

is_test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,13 @@ Deno.test("isObjectOf<T>", async (t) => {
11371137
true,
11381138
"Object have an unknown property",
11391139
);
1140+
assertEquals(
1141+
isObjectOf(predObj)(
1142+
Object.assign(() => void 0, { a: 0, b: "a", c: true }),
1143+
),
1144+
true,
1145+
"Function object",
1146+
);
11401147
});
11411148
await t.step("returns false on non T object", () => {
11421149
const predObj = {

0 commit comments

Comments
 (0)