Skip to content

Commit

Permalink
errors: remove usage of require('util')
Browse files Browse the repository at this point in the history
Remove internal usage of `require('util').inspect`.

Refs: #26546
  • Loading branch information
dnlup committed Mar 22, 2019
1 parent 1f1914c commit 4aae313
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/internal/error-serdes.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ function GetName(object) {
return desc && desc.value;
}

let util;
function lazyUtil() {
if (!util)
util = require('util');
return util;
let internalUtilInspect;
function inspect(...args) {
if (!internalUtilInspect) {
internalUtilInspect = require('internal/util/inspect');
}
return internalUtilInspect.inspect(...args);
}

let serialize;
Expand All @@ -107,7 +108,7 @@ function serializeError(error) {
return Buffer.concat([Buffer.from([kSerializedObject]), serialized]);
} catch {}
return Buffer.concat([Buffer.from([kInspectedError]),
Buffer.from(lazyUtil().inspect(error), 'utf8')]);
Buffer.from(inspect(error), 'utf8')]);
}

let deserialize;
Expand Down

0 comments on commit 4aae313

Please sign in to comment.