10 examples of 'javascript dump object' in JavaScript

Every line of 'javascript dump object' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
29return (function dump(obj, key) {
30 if (key)
31 return escapeString(obj + '');
32 else if (typeof obj === 'number')
33 return obj.toString();
34 else if (typeof obj === 'boolean')
35 return obj ? 'true' : 'false';
36 else if (typeof obj === 'string')
37 return escapeString(obj);
38 else if (obj === null)
39 return 'null';
40 else if (obj instanceof Array) {
41 var result = [];
42 for (var i = 0, n = obj.length; i != n; i++) {
43 result.push(dump(obj[i], false));
44 };
45 return '[' + result.join(', ') + ']';
46 }
47 else {
48 var result = [];
49 for (var key in obj) {
50 result.push(dump(key, true) + ': ' + dump(obj[key], false));
51 }
52 return '{' + result.join(', ') + '}';
53 }
54})(obj, false);
17function dumpValue(v) {
18 var i, n;
19 var tmp = [];
20
21 if (v === undefined) {
22 return 'undefined';
23 } else if (v === null) {
24 return 'null';
25 }
26
27 n = Math.floor(v.length);
28 for (i = 0; i < n; i++) {
29 if (v.hasOwnProperty(i)) {
30 tmp.push(v[i]);
31 } else {
32 tmp.push('nonexistent');
33 }
34 }
35 return typeof v + ' ' + v.length + ' ' + tmp.join(',');
36}
34function jquery_dump($obj) {
35 var dumphtml = [];
36 if(jQuery.browser.msie) {
37 for(var i = 0; i < $obj.length; i++) {
38 dumphtml.push('[' + i + '] ');
39 dumphtml.push($obj[i].outerHTML.replace(/^[\r\n\t]+/, ''));
40 dumphtml.push("\n");
41 }
42 } else {
43 for(var i = 0; i < $obj.length; i++) {
44 dumphtml.push('[' + i + '] '
45 + '<' + $obj[i].nodeName.toLowerCase());
46 for(var j = 0; j < $obj[i].attributes.length; j++) {
47 dumphtml.push(' ' + $obj[i].attributes[j].nodeName + '="'
48 + $obj[i].attributes[j].nodeValue + '"');
49 }
50 dumphtml.push('>' + $obj[i].innerHTML);
51 dumphtml.push('<\/' + $obj[i].nodeName.toLowerCase() + '>');
52 dumphtml.push("\n");
53 }
54 }
55 alert(dumphtml.join(''));
56}
10function dump_obj_r (obj, name, indent, depth) {
11 if (depth > MAX_DUMP_DEPTH) {
12 return indent + name + ": \n";
13 }
14 if (typeof obj == "object") {
15 var child = null;
16 var output = indent + name + "\n";
17 indent += "\t";
18 for (var item in obj) {
19 try {
20 child = obj[item];
21 } catch (e) {
22 child = "";
23 }
24 if (typeof child == "object") {
25 output += dump_obj_r(child, item, indent, depth + 1);
26 } else {
27 output += indent + item + ": " + child + "\n";
28 }
29 }
30 return output;
31 } else {
32 return obj;
33 }
34}
25function dump(x) {
26 Object.getOwnPropertyNames(x).forEach(function (k) {
27 print(typeof k, k, typeof x[k], x[k]);
28 });
29}
2function dumpObject(obj) {
3 if (typeof obj === "string") {
4 console.log(obj);
5 } else {
6 for (var current in obj) {
7 console.log("" + current + ": " + obj[current]);
8 }
9 }
10}
118function dumpObject(obj, lines = [], isLast = true, prefix = '') {
119 const localPrefix = isLast ? '└─' : '├─';
120 lines.push(`${prefix}${prefix ? localPrefix : ''}${obj.name || '*no-name*'} [${obj.type}]`);
121 const dataPrefix = obj.children.length
122 ? (isLast ? ' │ ' : '│ │ ')
123 : (isLast ? ' ' : '│ ');
124 lines.push(`${prefix}${dataPrefix} pos: ${dumpVec3(obj.position)}`);
125 lines.push(`${prefix}${dataPrefix} rot: ${dumpVec3(obj.rotation)}`);
126 lines.push(`${prefix}${dataPrefix} scl: ${dumpVec3(obj.scale)}`);
127 const newPrefix = prefix + (isLast ? ' ' : '│ ');
128 const lastNdx = obj.children.length - 1;
129 obj.children.forEach((child, ndx) => {
130 const isLast = ndx === lastNdx;
131 dumpObject(child, lines, isLast, newPrefix);
132 });
133 return lines;
134}
64function dump(d2array) {
65
66 var str = "<table>";
67 str += "<caption>dump</caption>";
68
69 for (var i = 0, rowLen = d2array.length; i &lt; rowLen; i++) {
70 var row = d2array[i];
71 str += "<tr>";
72
73 for (var j = 0, cellLen = row.length; j &lt; cellLen; j++) {
74 str += "<td>" + row[j] + "</td>";
75 }
76
77 str + "</tr>";
78 }
79
80 return str + "</table>";
81}
841function outputObject(obj, iIndent) {
842 var indentAdd = 0;
843 var objName = name( obj );
844 if ( objName != "" ) {
845 this.logger.info( indent.call( this,iIndent) + "children:" );
846 this.logger.info( indent.call( this,iIndent+1) + objName + ":");
847 this.logger.info( indent.call( this,iIndent+2) + "extends: http://vwf.example.com/node3.vwf");
848 indentAdd = 2;
849 }
850}
29function dump(o) {
30 if (global.system.verbosity &gt;= Verbosity.dump) {
31 console.log("%o", o);
32 }
33}

Related snippets