Skip to content

Commit

Permalink
backport #3844
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jan 12, 2024
1 parent 6ac702a commit 0c4c63b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion compat/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const StrictMode = Fragment;
* @template Arg
* @template Result
* @param {(arg: Arg) => Result} callback function that runs before the flush
* @param {Arg} [arg] Optional arugment that can be passed to the callback
* @param {Arg} [arg] Optional argument that can be passed to the callback
* @returns
*/
const flushSync = (callback, arg) => callback(arg);
Expand Down
2 changes: 1 addition & 1 deletion debug/src/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function initDebug() {
try {
oldCatchError(error, vnode, oldVNode);

// when an error was handled by an ErrorBoundary we will nontheless emit an error
// when an error was handled by an ErrorBoundary we will nonetheless emit an error
// event on the window object. This is to make up for react compatibility in dev mode
// and thus make the Next.js dev overlay work.
if (typeof error.then != 'function') {
Expand Down
24 changes: 12 additions & 12 deletions test/polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (!function f() {}.name) {
chai.use((chai, util) => {
const Assertion = chai.Assertion;

Assertion.addMethod('equalNode', function(expectedNode, message) {
Assertion.addMethod('equalNode', function (expectedNode, message) {
const obj = this._obj;
message = message || 'equalNode';

Expand Down Expand Up @@ -52,7 +52,7 @@ chai.use((chai, util) => {

//
// The following code overwrites karma's internal logging feature to
// support a much prettier and humand readable represantation of
// support a much prettier and humand readable representation of
// console logs in our terminal. This includes indentation, coloring
// and support for Map and Set objects.
//
Expand All @@ -76,15 +76,15 @@ patchConsole('info');
* @returns {[string]}
*/
function serializeConsoleArgs(args) {
const flat = args.map(arg => serialize(arg, 'flat', 0, new Set()));
const flat = args.map((arg) => serialize(arg, 'flat', 0, new Set()));
// We don't have access to the users terminal width, so we'll try to
// format everything into one line if possible and assume a terminal
// width of 80 chars
if (kl.stripColors(flat.join(', ')).length <= 80) {
return [flat.join(', ')];
}

const serialized = args.map(arg => serialize(arg, 'default', 0, new Set()));
const serialized = args.map((arg) => serialize(arg, 'default', 0, new Set()));
return ['\n' + serialized.join(',\n') + '\n'];
}

Expand Down Expand Up @@ -113,25 +113,25 @@ function serialize(value, mode, indent, seen) {
return kl.bold('null');
} else if (Array.isArray(value)) {
seen.add(value);
const values = value.map(v => serialize(v, mode, indent + 1, seen));
const values = value.map((v) => serialize(v, mode, indent + 1, seen));
if (mode === 'flat') {
return `[ ${values.join(', ')} ]`;
}

const space = applyIndent(indent);
const pretty = values.map(v => applyIndent(indent + 1) + v).join(',\n');
const pretty = values.map((v) => applyIndent(indent + 1) + v).join(',\n');
return `[\n${pretty}\n${space}]`;
} else if (value instanceof Set) {
const values = [];
value.forEach(v => {
value.forEach((v) => {
values.push(serialize(v, mode, indent, seen));
});

if (mode === 'flat') {
return `Set(${value.size}) { ${values.join(', ')} }`;
}

const pretty = values.map(v => applyIndent(indent + 1) + v).join(',\n');
const pretty = values.map((v) => applyIndent(indent + 1) + v).join(',\n');
return `Set(${value.size}) {\n${pretty}\n${applyIndent(indent)}}`;
} else if (value instanceof Map) {
const values = [];
Expand All @@ -143,12 +143,12 @@ function serialize(value, mode, indent, seen) {
});

if (mode === 'flat') {
const pretty = values.map(v => `${v[0]} => ${v[1]}`).join(', ');
const pretty = values.map((v) => `${v[0]} => ${v[1]}`).join(', ');
return `Map(${value.size}) { ${pretty} }`;
}

const pretty = values
.map(v => {
.map((v) => {
return applyIndent(indent + 1) + `${v[0]} => ${v[1]}`;
})
.join(', ');
Expand Down Expand Up @@ -184,7 +184,7 @@ function serialize(value, mode, indent, seen) {

seen.add(value);

const props = Object.keys(value).map(key => {
const props = Object.keys(value).map((key) => {
const v = serialize(value[key], mode, indent + 1, seen);
return `${key}: ${v}`;
});
Expand All @@ -196,7 +196,7 @@ function serialize(value, mode, indent, seen) {
return `{ ${pretty} }`;
}

const pretty = props.map(p => applyIndent(indent + 1) + p).join(',\n');
const pretty = props.map((p) => applyIndent(indent + 1) + p).join(',\n');
return `{\n${pretty}\n${applyIndent(indent)}}`;
}

Expand Down

0 comments on commit 0c4c63b

Please sign in to comment.