From 57e0b32940a31d294e1eff49d7120e17a9ed04e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 3 Oct 2024 21:30:42 +0200 Subject: [PATCH] refactor: use isFunction() in more code paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/lib.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lib.js b/src/lib.js index 7eb41cd..63ccb74 100644 --- a/src/lib.js +++ b/src/lib.js @@ -119,9 +119,7 @@ export const spawnSync = (() => { export const gc = (() => { return { unknown: () => - typeof globalThis.gc === 'function' - ? () => globalThis.gc() - : emptyFunction, + isFunction(globalThis.gc) ? () => globalThis.gc() : emptyFunction, browser: () => { try { globalThis.$262.gc() @@ -137,9 +135,7 @@ export const gc = (() => { gc() }, deno: () => - typeof globalThis.gc === 'function' - ? () => globalThis.gc() - : emptyFunction, + isFunction(globalThis.gc) ? () => globalThis.gc() : emptyFunction, bun: () => () => Bun.gc(true), }[runtime]() })()