Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url: remove usage of require('util')  #26808

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const util = require('util');
const { inspect } = require('internal/util/inspect');
const {
encodeStr,
hexTable,
Expand Down Expand Up @@ -184,7 +184,7 @@ class URLSearchParams {
this[context] = null;
}

[util.inspect.custom](recurseTimes, ctx) {
[inspect.custom](recurseTimes, ctx) {
if (!this || !this[searchParams] || this[searchParams][searchParams]) {
throw new ERR_INVALID_THIS('URLSearchParams');
}
Expand All @@ -197,7 +197,7 @@ class URLSearchParams {
if (recurseTimes !== null) {
innerOpts.depth = recurseTimes - 1;
}
var innerInspect = (v) => util.inspect(v, innerOpts);
var innerInspect = (v) => inspect(v, innerOpts);

var list = this[searchParams];
var output = [];
Expand Down Expand Up @@ -336,7 +336,7 @@ class URL {
scheme === 'file:');
}

[util.inspect.custom](depth, opts) {
[inspect.custom](depth, opts) {
if (this == null ||
Object.getPrototypeOf(this[context]) !== URLContext.prototype) {
throw new ERR_INVALID_THIS('URL');
Expand Down Expand Up @@ -370,7 +370,7 @@ class URL {
obj[context] = this[context];
}

return util.inspect(obj, opts);
return inspect(obj, opts);
}
}

Expand Down Expand Up @@ -1196,7 +1196,7 @@ defineIDLClass(URLSearchParamsIteratorPrototype, 'URLSearchParams Iterator', {
done: false
};
},
[util.inspect.custom](recurseTimes, ctx) {
[inspect.custom](recurseTimes, ctx) {
if (this == null || this[context] == null || this[context].target == null)
throw new ERR_INVALID_THIS('URLSearchParamsIterator');

Expand All @@ -1223,8 +1223,8 @@ defineIDLClass(URLSearchParamsIteratorPrototype, 'URLSearchParams Iterator', {
}
return prev;
}, []);
const breakLn = util.inspect(output, innerOpts).includes('\n');
const outputStrs = output.map((p) => util.inspect(p, innerOpts));
const breakLn = inspect(output, innerOpts).includes('\n');
const outputStrs = output.map((p) => inspect(p, innerOpts));
let outputStr;
if (breakLn) {
outputStr = `\n ${outputStrs.join(',\n ')}`;
Expand Down