url: remove usage of require('util')
PR-URL: https://github.com/nodejs/node/pull/26808 Refs: https://github.com/nodejs/node/issues/26546 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
This commit is contained in:
parent
b8d4bafa03
commit
5b59b5f525
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const util = require('util');
|
const { inspect } = require('internal/util/inspect');
|
||||||
const {
|
const {
|
||||||
encodeStr,
|
encodeStr,
|
||||||
hexTable,
|
hexTable,
|
||||||
@ -184,7 +184,7 @@ class URLSearchParams {
|
|||||||
this[context] = null;
|
this[context] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
[util.inspect.custom](recurseTimes, ctx) {
|
[inspect.custom](recurseTimes, ctx) {
|
||||||
if (!this || !this[searchParams] || this[searchParams][searchParams]) {
|
if (!this || !this[searchParams] || this[searchParams][searchParams]) {
|
||||||
throw new ERR_INVALID_THIS('URLSearchParams');
|
throw new ERR_INVALID_THIS('URLSearchParams');
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ class URLSearchParams {
|
|||||||
if (recurseTimes !== null) {
|
if (recurseTimes !== null) {
|
||||||
innerOpts.depth = recurseTimes - 1;
|
innerOpts.depth = recurseTimes - 1;
|
||||||
}
|
}
|
||||||
var innerInspect = (v) => util.inspect(v, innerOpts);
|
var innerInspect = (v) => inspect(v, innerOpts);
|
||||||
|
|
||||||
var list = this[searchParams];
|
var list = this[searchParams];
|
||||||
var output = [];
|
var output = [];
|
||||||
@ -334,7 +334,7 @@ class URL {
|
|||||||
scheme === 'file:');
|
scheme === 'file:');
|
||||||
}
|
}
|
||||||
|
|
||||||
[util.inspect.custom](depth, opts) {
|
[inspect.custom](depth, opts) {
|
||||||
if (this == null ||
|
if (this == null ||
|
||||||
Object.getPrototypeOf(this[context]) !== URLContext.prototype) {
|
Object.getPrototypeOf(this[context]) !== URLContext.prototype) {
|
||||||
throw new ERR_INVALID_THIS('URL');
|
throw new ERR_INVALID_THIS('URL');
|
||||||
@ -368,7 +368,7 @@ class URL {
|
|||||||
obj[context] = this[context];
|
obj[context] = this[context];
|
||||||
}
|
}
|
||||||
|
|
||||||
return util.inspect(obj, opts);
|
return inspect(obj, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1194,7 +1194,7 @@ defineIDLClass(URLSearchParamsIteratorPrototype, 'URLSearchParams Iterator', {
|
|||||||
done: false
|
done: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[util.inspect.custom](recurseTimes, ctx) {
|
[inspect.custom](recurseTimes, ctx) {
|
||||||
if (this == null || this[context] == null || this[context].target == null)
|
if (this == null || this[context] == null || this[context].target == null)
|
||||||
throw new ERR_INVALID_THIS('URLSearchParamsIterator');
|
throw new ERR_INVALID_THIS('URLSearchParamsIterator');
|
||||||
|
|
||||||
@ -1221,8 +1221,8 @@ defineIDLClass(URLSearchParamsIteratorPrototype, 'URLSearchParams Iterator', {
|
|||||||
}
|
}
|
||||||
return prev;
|
return prev;
|
||||||
}, []);
|
}, []);
|
||||||
const breakLn = util.inspect(output, innerOpts).includes('\n');
|
const breakLn = inspect(output, innerOpts).includes('\n');
|
||||||
const outputStrs = output.map((p) => util.inspect(p, innerOpts));
|
const outputStrs = output.map((p) => inspect(p, innerOpts));
|
||||||
let outputStr;
|
let outputStr;
|
||||||
if (breakLn) {
|
if (breakLn) {
|
||||||
outputStr = `\n ${outputStrs.join(',\n ')}`;
|
outputStr = `\n ${outputStrs.join(',\n ')}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user