Skip to content

Commit d69a607

Browse files
save file
1 parent e55635c commit d69a607

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,9 @@
679679
//:
680680

681681

682+
function datatype(v){return Object.prototype.toString.call(v).slice(8,-1).toLowerCase()}
683+
684+
682685
function format(args){
683686

684687
if (typeof args[0] !== "string") return args;
@@ -731,32 +734,34 @@
731734

732735
format.fn = function(val,seen=new WeakSet()){
733736

734-
if (val === null) return 'null';
735-
if (val === undefined) return 'undefined';
737+
if(val === null)return 'null';
738+
if(val === undefined)return 'undefined';
736739

737740
// Prevent circular references
738-
if (typeof val === 'object' || typeof val === 'function') {
739-
if (seen.has(val)) return '[Circular]';
741+
if(typeof val==='object' || typeof val==='function'){
742+
if(seen.has(val))return '[Circular]';
740743
seen.add(val);
741744
}
742745

743746
// Primitive types
744-
switch (typeof val) {
745-
746-
case 'number': return String(val);
747-
case 'string': return val;
748-
case 'boolean': return String(val);
749-
case 'bigint': return val.toString() + 'n';
750-
case 'symbol': return val.toString();
751-
case 'function': return `[Function${val.name ? ': ' + val.name : ''}]`;
747+
switch(typeof val){
748+
749+
case 'number' : return String(val);
750+
case 'string' : return val;
751+
case 'boolean' : return String(val);
752+
case 'bigint' : return val.toString() + 'n';
753+
case 'symbol' : return val.toString();
754+
case 'function' : return `[Function${val.name ? ': '+val.name : ''}]`;
752755

753756
}//switch
754757

755-
if(Array.isArray(val)){
758+
var type = datatype(val);
759+
760+
if(type=='array'){
756761
return '['+val.map(v=>fn(v,seen)).join(', ')+']';
757762
}
758763

759-
if(val instanceof Date){
764+
if(type=='date'){//val instanceof Date){
760765
return `Date("${val.toISOString()}")`;
761766
}
762767

0 commit comments

Comments
 (0)