MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix formatWithOptions style argument

+35 -1
+3 -1
src/modules/util.c
··· 181 181 util_sb_append_json(js, &sb, v); 182 182 } else if (spec == 'o' || spec == 'O') { 183 183 util_sb_append_jsval(js, &sb, v); 184 - } else if (spec == 'c') // style placeholder: consume arg, emit nothing 184 + } else if (spec == 'c') { 185 + // style placeholder: consume arg, emit nothing. 186 + } 185 187 186 188 i++; 187 189 }
+32
tests/repro_obug_format.mjs
··· 1 + import { formatWithOptions } from 'node:util'; 2 + import process from 'node:process'; 3 + 4 + function humanize(value) { 5 + if (value >= 1000) return `${(value / 1000).toFixed(1)}s`; 6 + return `${value}ms`; 7 + } 8 + 9 + function writeDebugLine(namespace, args, diff) { 10 + const prefix = ` \u001B[32;1m${namespace} \u001B[0m`; 11 + args[0] = prefix + args[0].split('\n').join(`\n${prefix}`); 12 + args.push(`\u001B[32m+${humanize(diff)}\u001B[0m`); 13 + return formatWithOptions({}, ...args); 14 + } 15 + 16 + const raw = formatWithOptions({}, '%s %s : %s', 'fn', '/', '/foo.png'); 17 + const debugLine = writeDebugLine('repro:test', ['%s %s : %s', 'fn', '/', '/foo.png'], 0); 18 + 19 + console.log('raw:'); 20 + console.log(raw); 21 + console.log('debug:'); 22 + console.log(debugLine); 23 + 24 + if (raw !== 'fn / : /foo.png') { 25 + throw new Error(`util.formatWithOptions mismatch: ${JSON.stringify(raw)}`); 26 + } 27 + 28 + if (!debugLine.includes('fn / : /foo.png')) { 29 + throw new Error(`obug-style line mismatch: ${JSON.stringify(debugLine)}`); 30 + } 31 + 32 + process.exit(0);