www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 5be84a5d59e9bc0b206e5520530445d0cfc5c94e
parent 19a6b08b5169808f93d3de94b6c5f67461109163
Author: aurimasv <aurimas.dev@gmail.com>
Date:   Mon, 12 Mar 2012 20:33:59 -0500

add maxLevels to varDump to avoid infinite loops

Diffstat:
Mchrome/content/zotero/xpcom/utilities.js | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js @@ -1014,17 +1014,25 @@ Zotero.Utilities = { * * Adapted from http://binnyva.blogspot.com/2005/10/dump-function-javascript-equivalent-of.html */ - "varDump":function(arr,level) { + "varDump":function(arr,level,maxLevel) { var dumped_text = ""; if (!level){ level = 0; } + + if (!maxLevel) { + maxLevel = 4; + } // The padding given at the beginning of the line. var level_padding = ""; for (var j=0;j<level+1;j++){ level_padding += " "; } + + if (level > maxLevel){ + return dumped_text + level_padding + "...\n"; + } if (typeof(arr) == 'object') { // Array/Hashes/Objects for (var item in arr) { @@ -1032,7 +1040,7 @@ Zotero.Utilities = { if (typeof(value) == 'object') { // If it is an array, dumped_text += level_padding + "'" + item + "' ...\n"; - dumped_text += arguments.callee(value,level+1); + dumped_text += arguments.callee(value,level+1,maxLevel); } else { if (typeof value == 'function'){