Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4444305
repro_obug_format.mjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
971 B
Referenced Files
None
Subscribers
None
repro_obug_format.mjs
View Options
import { formatWithOptions } from 'node:util';
import process from 'node:process';
function humanize(value) {
if (value >= 1000) return `${(value / 1000).toFixed(1)}s`;
return `${value}ms`;
}
function writeDebugLine(namespace, args, diff) {
const prefix = ` \u001B[32;1m${namespace} \u001B[0m`;
args[0] = prefix + args[0].split('\n').join(`\n${prefix}`);
args.push(`\u001B[32m+${humanize(diff)}\u001B[0m`);
return formatWithOptions({}, ...args);
}
const raw = formatWithOptions({}, '%s %s : %s', 'fn', '/', '/foo.png');
const debugLine = writeDebugLine('repro:test', ['%s %s : %s', 'fn', '/', '/foo.png'], 0);
console.log('raw:');
console.log(raw);
console.log('debug:');
console.log(debugLine);
if (raw !== 'fn / : /foo.png') {
throw new Error(`util.formatWithOptions mismatch: ${JSON.stringify(raw)}`);
}
if (!debugLine.includes('fn / : /foo.png')) {
throw new Error(`obug-style line mismatch: ${JSON.stringify(debugLine)}`);
}
process.exit(0);
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Sat, May 2, 10:16 AM (1 d, 23 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
543256
Default Alt Text
repro_obug_format.mjs (971 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment