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`.

PR-URL: #26781
Refs: #26546
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
  • Loading branch information
dnlup authored and targos committed Mar 27, 2019
1 parent 14cc4f2 commit 9a5c149
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 @@ -77,11 +77,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);
}

function serializeError(error) {
Expand All @@ -106,7 +107,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')]);
}

function deserializeError(error) {
Expand Down

0 comments on commit 9a5c149

Please sign in to comment.