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 BethGriggs committed Mar 26, 2019
1 parent 8520c8b commit ed1c51a
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 ed1c51a

Please sign in to comment.