From 33214ee924e6e05413ac1f6faf6cd6f77422d4d4 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 29 Jul 2013 19:06:22 -0500 Subject: [PATCH] cleanup new dump method. --- lib/program.js | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/lib/program.js b/lib/program.js index 0ccb3e0..f370b0f 100644 --- a/lib/program.js +++ b/lib/program.js @@ -79,20 +79,11 @@ Program.prototype.__proto__ = EventEmitter.prototype; Program.prototype.dump = function(file) { var self = this , _write = this.output.write - , decoder = new (require('string_decoder')).StringDecoder('utf8') - , stringify = stringifyLess; + , decoder = new (require('string_decoder')).StringDecoder('utf8'); this.logger = require('fs').createWriteStream(file); - function stringifyJson(data) { - return JSON.stringify(caret(data)) - .replace(/\\u00([0-9a-f])/gi, '\\x$1') - .slice(1, -1); - } - - function stringifyLess(data) { - // Could wrap in: \x1b[7m\x1b[m - // for inverse in `less -R`. + function stringify(data) { return caret(data .replace(/\r/g, '\\r') .replace(/\n/g, '\\n') @@ -109,14 +100,6 @@ Program.prototype.dump = function(file) { }); } - function stringifyMinimal(data) { - return data - //.replace(/\x1b/g, '^[') - .replace(/\r/g, '\\r') - .replace(/\n/g, '\\n') - .replace(/\t/g, '\\t'); - } - function caret(data) { return data.replace(/[\0\x80\x1b-\x1f\x7f\x01-\x1a]/g, function(ch) { switch (ch) { @@ -144,8 +127,8 @@ Program.prototype.dump = function(file) { break; default: ch = ch.charCodeAt(0); + // From ('A' - 64) to ('Z' - 64). if (ch >= 1 && ch <= 26) { - //if (ch >= 'A'.charCodeAt(0) - 64 && ch <= 'Z'.charCodeAt(0) - 64) { ch = String.fromCharCode(ch + 64); } else { return String.fromCharCode(ch);