From 8046bf032c8cd4b6971006e660d249581a51d916 Mon Sep 17 00:00:00 2001 From: Marak Date: Thu, 9 Oct 2014 11:56:30 +0200 Subject: [PATCH] [fix] #87 Add stripColors method for backwards compat --- lib/colors.js | 3 ++- lib/extendStringPrototype.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/colors.js b/lib/colors.js index 156879f..59898de 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -42,10 +42,11 @@ if (typeof colors.enabled === "undefined") { colors.enabled = colors.supportsColor; } -colors.strip = function(str){ +colors.stripColors = colors.strip = function(str){ return ("" + str).replace(/\x1B\[\d+m/g, ''); }; + var stylize = colors.stylize = function stylize (str, style) { return ansiStyles[style].open + str + ansiStyles[style].close; } diff --git a/lib/extendStringPrototype.js b/lib/extendStringPrototype.js index 241157d..b6b5b03 100644 --- a/lib/extendStringPrototype.js +++ b/lib/extendStringPrototype.js @@ -26,6 +26,10 @@ module['exports'] = function () { return colors.strip(this); }); + addProperty('stripColors', function () { + return colors.strip(this); + }); + addProperty("trap", function(){ return colors.trap(this); });