fix: don't use built-in util module for type-checking

Node.js 23 removes methods like `util.isRegExp()`: https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V23.md#semver-major-commits

Fixes #2126.
This commit is contained in:
Jeff Williams 2024-10-19 12:05:20 -07:00
parent a5232aa912
commit 59a565812d
No known key found for this signature in database
2 changed files with 5 additions and 6 deletions

View File

@ -2,7 +2,7 @@
* Recursively print out all names and values in a data structure.
* @module jsdoc/util/dumper
*/
const util = require('util');
const _ = require('underscore');
const OBJECT_WALKER_KEY = 'hasBeenSeenByWalkerDumper';
const SET_DEFINED = (typeof Set !== 'undefined');
@ -95,13 +95,13 @@ class ObjectWalker {
return newArray;
});
}
else if ( util.isRegExp(o) ) {
else if ( _.isRegExp(o) ) {
result = `<RegExp ${o}>`;
}
else if ( util.isDate(o) ) {
else if ( _.isDate(o) ) {
result = `<Date ${o.toUTCString()}>`;
}
else if ( util.isError(o) ) {
else if ( _.isError(o) ) {
result = { message: o.message };
}
else if ( this.isFunction(o) ) {

View File

@ -7,7 +7,6 @@ const _ = require('underscore');
const doop = require('jsdoc/util/doop');
const dump = require('jsdoc/util/dumper').dump;
const env = require('jsdoc/env');
const util = require('util');
const conf = env.conf.eventDumper || {};
@ -68,7 +67,7 @@ function cleanse(e) {
Object.keys(e).forEach(prop => {
// by default, don't stringify properties that contain an array of functions
if (!conf.includeFunctions && util.isArray(e[prop]) && e[prop][0] &&
if (!conf.includeFunctions && _.isArray(e[prop]) && e[prop][0] &&
String(typeof e[prop][0]) === 'function') {
result[prop] = `function[${e[prop].length}]`;
}