From e951497c7122c642037084249cf18066fec0a3de Mon Sep 17 00:00:00 2001 From: Thomas Rory Gummerson Date: Mon, 2 Dec 2024 12:58:51 +0100 Subject: [PATCH] hotfix: also patch util.isRegExp and util.isArray --- index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index b4384a7..3165ed1 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,14 @@ // @ts-check 'use strict'; -// NeDB on life support, util.isDate is removed in node 23.x, monkeypatch it -// eslint-disable-next-line global-require -if (!('isDate' in require('util'))) { - // eslint-disable-next-line global-require - require('util').isDate = require('util').types.isDate; +// NeDB on life support +// some util methods are removed in node 23.x, monkeypatch them +const util = require('util'); +const patch_methods = [ 'isDate', 'isRegExp' ]; +for (let i = 0; i < patch_methods.length; i++) { + util[patch_methods[i]] = util.types[patch_methods[i]]; } +util.isArray = Array.isArray; process.chdir(__dirname); require('ts-node').register({ transpileOnly: true });