normalizeConsoleFormat() — react Function Reference
Architecture documentation for the normalizeConsoleFormat() function in normalizeConsoleFormat.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 3bfa494c_3228_0a0e_6545_aa3d6c422c23["normalizeConsoleFormat()"] e338eb30_b125_7ab9_0a2c_4b6694754e96["normalizeConsoleFormat.js"] 3bfa494c_3228_0a0e_6545_aa3d6c422c23 -->|defined in| e338eb30_b125_7ab9_0a2c_4b6694754e96 style 3bfa494c_3228_0a0e_6545_aa3d6c422c23 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/shared/normalizeConsoleFormat.js lines 13–56
export default function normalizeConsoleFormat(
formatString: string,
args: $ReadOnlyArray<mixed>,
firstArg: number,
): string {
let j = firstArg;
let normalizedString = '';
let last = 0;
for (let i = 0; i < formatString.length - 1; i++) {
if (formatString.charCodeAt(i) !== 37 /* "%" */) {
continue;
}
switch (formatString.charCodeAt(++i)) {
case 79 /* "O" */:
case 99 /* "c" */:
case 100 /* "d" */:
case 102 /* "f" */:
case 105 /* "i" */:
case 111 /* "o" */:
case 115 /* "s" */: {
if (j < args.length) {
// We have a matching argument.
j++;
} else {
// We have more format specifiers than arguments.
// So we need to escape this to print the literal.
normalizedString += formatString.slice(last, (last = i)) + '%';
}
}
}
}
normalizedString += formatString.slice(last, formatString.length);
// Pad with extra format specifiers for the rest.
while (j < args.length) {
if (normalizedString !== '') {
normalizedString += ' ';
}
// Not every environment has the same default.
// This seems to be what Chrome DevTools defaults to.
normalizedString += typeof args[j] === 'string' ? '%s' : '%o';
j++;
}
return normalizedString;
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does normalizeConsoleFormat() do?
normalizeConsoleFormat() is a function in the react codebase, defined in packages/shared/normalizeConsoleFormat.js.
Where is normalizeConsoleFormat() defined?
normalizeConsoleFormat() is defined in packages/shared/normalizeConsoleFormat.js at line 13.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free