Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[js] add a helper to dump objects to json for debugging purposes
  • Loading branch information
pmurias committed Sep 24, 2015
1 parent 6b3c7b0 commit 2111ca0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/vm/js/nqp-runtime/runtime.js
Expand Up @@ -347,3 +347,17 @@ exports.wrapObj = function(obj) {
return obj;
}
};

/* For debugging purposes */
exports.dumpObj = function(obj) {
var seen = [];

return JSON.stringify(obj, function(key, value) {
if (key == '_SC') return undefined;
for (var i = 0; i < seen.length; i++) {
if (seen[i] === value) return "circular";
}
seen.push(value);
return value;
}, " ");
};

0 comments on commit 2111ca0

Please sign in to comment.