Permalink
Browse files

trim function should trim all types of ANSI codes

  • Loading branch information...
medikoo committed Feb 20, 2013
1 parent 531ddca commit 9540a70ec9229792708224601ad6f069d789d2e4
Showing with 6 additions and 2 deletions.
  1. +2 −1 lib/trim.js
  2. +4 −1 test/trim.js
View
@@ -2,6 +2,7 @@
'use strict';
-var r = new RegExp('\x1b\\[\\d{1,2}m', 'g');
+var r = new RegExp('\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|' +
+ '\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)', 'g');
module.exports = function (str) { return str.replace(r, ''); };
View
@@ -3,5 +3,8 @@
var clc = require('../lib');
module.exports = function (t, a) {
- a(t(clc.red('raz') + 'dwa' + clc.bold('trzy')), 'razdwatrzy');
+ a(t(clc.red('raz') + 'dwa' + clc.bold('trzy')), 'razdwatrzy', "Colors");
+ a(t(clc.xterm(202)('raz') + clc.bgXterm(230)('dwa')), "razdwa", "xTerm");
+ a(t(clc.reset).trim(), '', "Reset");
+ a(t(clc.moveTo(1, 32) + 'raz' + clc.bol(1) + 'dwa'), 'razdwa', "Move around");
};

0 comments on commit 9540a70

Please sign in to comment.