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: nodejs#26781
Refs: nodejs#26546
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
  • Loading branch information
dnlup authored and danbev committed Mar 26, 2019
1 parent 136c805 commit 553c876
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 553c876

Please sign in to comment.