Skip to content

Commit 5478044

Browse files
committed
🐛 Support async function in isFunction
1 parent ff62231 commit 5478044

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

is.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ function isObjectOfStrict<
278278
* Return `true` if the type of `x` is `function`.
279279
*/
280280
export function isFunction(x: unknown): x is (...args: unknown[]) => unknown {
281-
return Object.prototype.toString.call(x) === "[object Function]";
281+
return x instanceof Function;
282282
}
283283

284284
/**

is_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const examples = {
4545
boolean: [true, false],
4646
array: [[], [0, 1, 2], ["a", "b", "c"], [0, "a", true]],
4747
record: [{}, { a: 0, b: 1, c: 2 }, { a: "a", b: "b", c: "c" }],
48-
function: [function a() {}, () => {}],
48+
function: [function a() {}, () => {}, async function b() {}, async () => {}],
4949
null: [null],
5050
undefined: [undefined],
5151
symbol: [Symbol("a"), Symbol("b"), Symbol("c")],

0 commit comments

Comments
 (0)