aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/colors/lib/extendStringPrototype.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/colors/lib/extendStringPrototype.js')
-rw-r--r--deps/npm/node_modules/colors/lib/extendStringPrototype.js81
1 files changed, 44 insertions, 37 deletions
diff --git a/deps/npm/node_modules/colors/lib/extendStringPrototype.js b/deps/npm/node_modules/colors/lib/extendStringPrototype.js
index 0d486147ee..67374a1c22 100644
--- a/deps/npm/node_modules/colors/lib/extendStringPrototype.js
+++ b/deps/npm/node_modules/colors/lib/extendStringPrototype.js
@@ -1,42 +1,51 @@
var colors = require('./colors');
-module['exports'] = function() {
+module['exports'] = function () {
+
//
// Extends prototype of native string object to allow for "foo".red syntax
//
- var addProperty = function(color, func) {
+ var addProperty = function (color, func) {
String.prototype.__defineGetter__(color, func);
};
- addProperty('strip', function() {
+ var sequencer = function sequencer (map, str) {
+ return function () {
+ var exploded = this.split(""), i = 0;
+ exploded = exploded.map(map);
+ return exploded.join("");
+ }
+ };
+
+ addProperty('strip', function () {
return colors.strip(this);
});
- addProperty('stripColors', function() {
+ addProperty('stripColors', function () {
return colors.strip(this);
});
- addProperty('trap', function() {
+ addProperty("trap", function(){
return colors.trap(this);
});
- addProperty('zalgo', function() {
+ addProperty("zalgo", function(){
return colors.zalgo(this);
});
- addProperty('zebra', function() {
+ addProperty("zebra", function(){
return colors.zebra(this);
});
- addProperty('rainbow', function() {
+ addProperty("rainbow", function(){
return colors.rainbow(this);
});
- addProperty('random', function() {
+ addProperty("random", function(){
return colors.random(this);
});
- addProperty('america', function() {
+ addProperty("america", function(){
return colors.america(this);
});
@@ -44,8 +53,8 @@ module['exports'] = function() {
// Iterate through all default styles and colors
//
var x = Object.keys(colors.styles);
- x.forEach(function(style) {
- addProperty(style, function() {
+ x.forEach(function (style) {
+ addProperty(style, function () {
return colors.stylize(this, style);
});
});
@@ -56,28 +65,25 @@ module['exports'] = function() {
// on String that you should not overwrite.
//
var stringPrototypeBlacklist = [
- '__defineGetter__', '__defineSetter__', '__lookupGetter__',
- '__lookupSetter__', 'charAt', 'constructor', 'hasOwnProperty',
- 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString',
- 'valueOf', 'charCodeAt', 'indexOf', 'lastIndexOf', 'length',
- 'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice',
- 'split', 'substring', 'toLocaleLowerCase', 'toLocaleUpperCase',
- 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight',
+ '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'charAt', 'constructor',
+ 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf', 'charCodeAt',
+ 'indexOf', 'lastIndexof', 'length', 'localeCompare', 'match', 'replace', 'search', 'slice', 'split', 'substring',
+ 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight'
];
- Object.keys(theme).forEach(function(prop) {
+ Object.keys(theme).forEach(function (prop) {
if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
- console.log('warn: '.red + ('String.prototype' + prop).magenta +
- ' is probably something you don\'t want to override. ' +
- 'Ignoring style name');
- } else {
+ console.log('warn: '.red + ('String.prototype' + prop).magenta + ' is probably something you don\'t want to override. Ignoring style name');
+ }
+ else {
if (typeof(theme[prop]) === 'string') {
colors[prop] = colors[theme[prop]];
- addProperty(prop, function() {
+ addProperty(prop, function () {
return colors[theme[prop]](this);
});
- } else {
- addProperty(prop, function() {
+ }
+ else {
+ addProperty(prop, function () {
var ret = this;
for (var t = 0; t < theme[prop].length; t++) {
ret = colors[theme[prop][t]](ret);
@@ -89,18 +95,19 @@ module['exports'] = function() {
});
}
- colors.setTheme = function(theme) {
+ colors.setTheme = function (theme) {
if (typeof theme === 'string') {
- console.log('colors.setTheme now only accepts an object, not a string. ' +
- 'If you are trying to set a theme from a file, it is now your (the ' +
- 'caller\'s) responsibility to require the file. The old syntax ' +
- 'looked like colors.setTheme(__dirname + ' +
- '\'/../themes/generic-logging.js\'); The new syntax looks like '+
- 'colors.setTheme(require(__dirname + ' +
- '\'/../themes/generic-logging.js\'));');
- return;
+ try {
+ colors.themes[theme] = require(theme);
+ applyTheme(colors.themes[theme]);
+ return colors.themes[theme];
+ } catch (err) {
+ console.log(err);
+ return err;
+ }
} else {
applyTheme(theme);
}
};
-};
+
+}; \ No newline at end of file