Skip to content

Commit

Permalink
hotfix: also patch util.isRegExp and util.isArray
Browse files Browse the repository at this point in the history
  • Loading branch information
trgwii committed Dec 2, 2024
1 parent d1b686a commit e951497
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down

0 comments on commit e951497

Please sign in to comment.