fix: fix util import statement (#45104)
Co-authored-by: IsmailTlemcani <ismail.tlemcani@gmail.com>
This commit is contained in:
@ -229,7 +229,7 @@ exports.onCreateWebpackConfig = ({ stage, actions }) => {
|
|||||||
path: require.resolve('path-browserify'),
|
path: require.resolve('path-browserify'),
|
||||||
assert: require.resolve('assert'),
|
assert: require.resolve('assert'),
|
||||||
crypto: require.resolve('crypto-browserify'),
|
crypto: require.resolve('crypto-browserify'),
|
||||||
util: false,
|
util: require.resolve('util/util'),
|
||||||
buffer: require.resolve('buffer'),
|
buffer: require.resolve('buffer'),
|
||||||
stream: require.resolve('stream-browserify'),
|
stream: require.resolve('stream-browserify'),
|
||||||
process: require.resolve('process/browser')
|
process: require.resolve('process/browser')
|
||||||
|
@ -124,6 +124,7 @@
|
|||||||
"stream-browserify": "3.0.0",
|
"stream-browserify": "3.0.0",
|
||||||
"tone": "14.7.77",
|
"tone": "14.7.77",
|
||||||
"typescript": "4.5.5",
|
"typescript": "4.5.5",
|
||||||
|
"util": "^0.12.4",
|
||||||
"uuid": "8.3.2",
|
"uuid": "8.3.2",
|
||||||
"validator": "13.7.0"
|
"validator": "13.7.0"
|
||||||
},
|
},
|
||||||
|
@ -25,6 +25,7 @@ const __utils = (() => {
|
|||||||
|
|
||||||
const oldLog = ctx.console.log.bind(ctx.console);
|
const oldLog = ctx.console.log.bind(ctx.console);
|
||||||
function proxyLog(...args: string[]) {
|
function proxyLog(...args: string[]) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||||
logs.push(args.map(arg => __format(arg)).join(' '));
|
logs.push(args.map(arg => __format(arg)).join(' '));
|
||||||
if (logs.join('\n').length > MAX_LOGS_SIZE) {
|
if (logs.join('\n').length > MAX_LOGS_SIZE) {
|
||||||
flushLogs();
|
flushLogs();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { inspect } from 'util';
|
import { inspect } from 'util/util';
|
||||||
|
|
||||||
export function format(x) {
|
export function format(x) {
|
||||||
// we're trying to mimic console.log, so we avoid wrapping strings in quotes:
|
// we're trying to mimic console.log, so we avoid wrapping strings in quotes:
|
||||||
@ -10,6 +10,10 @@ export function format(x) {
|
|||||||
x.entries(),
|
x.entries(),
|
||||||
([k, v]) => `${k} => ${v}`
|
([k, v]) => `${k} => ${v}`
|
||||||
).join(', ')}})`;
|
).join(', ')}})`;
|
||||||
|
} else if (typeof x === 'bigint') {
|
||||||
|
return x.toString() + 'n';
|
||||||
|
} else if (typeof x === 'symbol') {
|
||||||
|
return x.toString();
|
||||||
}
|
}
|
||||||
return inspect(x);
|
return inspect(x);
|
||||||
}
|
}
|
||||||
|
@ -35,17 +35,17 @@ describe('format', () => {
|
|||||||
const primitives = [
|
const primitives = [
|
||||||
'str',
|
'str',
|
||||||
57,
|
57,
|
||||||
BigInt(10),
|
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
// eslint-disable-next-line no-undefined
|
// eslint-disable-next-line no-undefined
|
||||||
undefined,
|
undefined
|
||||||
Symbol('Sym')
|
|
||||||
];
|
];
|
||||||
expect(format(primitives)).toBe(
|
expect(format(primitives)).toBe(
|
||||||
`[ 'str', 57, 10n, true, false, null, undefined, Symbol(Sym) ]`
|
`[ 'str', 57, true, false, null, undefined ]`
|
||||||
);
|
);
|
||||||
|
expect(format(BigInt(10))).toBe(`10n`);
|
||||||
|
expect(format(Symbol('Sym'))).toBe(`Symbol(Sym)`);
|
||||||
});
|
});
|
||||||
it(`outputs NaN as 'NaN'`, () => {
|
it(`outputs NaN as 'NaN'`, () => {
|
||||||
expect(format(NaN)).toBe('NaN');
|
expect(format(NaN)).toBe('NaN');
|
||||||
|
Reference in New Issue
Block a user