From 8c679f485c7e9eaafed2a567d41d25fbdba5a681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 3 Oct 2024 20:57:11 +0200 Subject: [PATCH] refactor: cleanup isFunction() helper implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/benchmark.js | 1 + src/utils.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/benchmark.js b/src/benchmark.js index 18b9ac5..25c6a0a 100644 --- a/src/benchmark.js +++ b/src/benchmark.js @@ -340,6 +340,7 @@ export async function run(opts = {}) { throw new TypeError( `expected function as 'now' option, got ${opts.now.constructor.name}` ) + opts.silent = opts.silent ?? false opts.units = opts.units ?? false opts.colors = opts.colors ?? colors diff --git a/src/utils.js b/src/utils.js index 5f78f03..de97e7b 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,5 +1,5 @@ export const isFunction = fn => { - return [Function, AsyncFunction].includes(fn.constructor) + return typeof fn === 'function' } export const AsyncFunction = (async () => {}).constructor