Skip to content

Commit de80fa3

Browse files
save file
1 parent 9673dc3 commit de80fa3

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

utils/editors/js-console/html/output-console/v2.0/output-console-v2.0.html

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,8 @@
614614
window.console.groupCollapsed.apply(window.console,args);
615615
}
616616

617-
var div = disp.apply(null,arguments);
617+
vat out = formatConsoleArgs(arguments);
618+
var div = disp.apply(null,out);
618619
return div;
619620

620621
}//groupCollapsed
@@ -674,6 +675,39 @@
674675
//:
675676

676677

678+
function formatConsoleArgs(args) {
679+
680+
if (typeof args[0] !== "string") return args;
681+
682+
let fmt = args[0];
683+
let out = [];
684+
let argIndex = 1;
685+
686+
out.push(fmt.replace(/%[sdifoO]/g, (match) => {
687+
const val = args[argIndex++];
688+
switch (match) {
689+
case "%s": return String(val);
690+
case "%d":
691+
case "%i": return parseInt(val, 10);
692+
case "%f": return parseFloat(val);
693+
case "%o":
694+
case "%O":
695+
return JSON.stringify(val, null, 2); // or your own inspector
696+
default:
697+
return match;
698+
}
699+
}));
700+
701+
// Append any remaining args
702+
while (argIndex < args.length) {
703+
out.push(args[argIndex++]);
704+
}
705+
706+
return out;
707+
708+
}
709+
710+
677711
function build(args){
678712

679713
var str = '';

0 commit comments

Comments
 (0)