aboutsummaryrefslogtreecommitdiff
path: root/src/utility.js
diff options
context:
space:
mode:
authorAlon Zakai <azakai@mozilla.com>2010-11-27 14:51:58 -0800
committerAlon Zakai <azakai@mozilla.com>2010-11-27 14:51:58 -0800
commitc3f19a35f46dfc0879862212140867cb1998cc65 (patch)
treeaa1f77aed8ee4609424c872025dc349b1bfcb437 /src/utility.js
parent1286f8332f1254768a9a2a40e8b1c89b4e8ed944 (diff)
simplify dump(), avoid memory issues
Diffstat (limited to 'src/utility.js')
-rw-r--r--src/utility.js13
1 files changed, 1 insertions, 12 deletions
diff --git a/src/utility.js b/src/utility.js
index fd8a1bce..391efb14 100644
--- a/src/utility.js
+++ b/src/utility.js
@@ -8,19 +8,8 @@ function safeQuote(x) {
function dump(item) {
var CHUNK = 500;
function lineify(text) {
- var ret = '';
- while (text.length > 0) {
- if (text.length < CHUNK) {
- ret += text;
- return ret;
- }
- var subText = text.substring(CHUNK-20, CHUNK);
- var index = CHUNK-19+Math.max(subText.indexOf(','), subText.indexOf(']'), subText.indexOf('}'), 21);
- ret += text.substr(0,index) + '\n';
- text = '// ' + text.substr(index);
- }
+ return text.replace(/.{80}/g, '$&\n');
}
-
try {
return lineify(JSON.stringify(item));
} catch(e) {