[Pkg-javascript-commits] [node-colors] 01/08: New upstream version 1.1.2

Marcelo Jorge Vieira metal at moszumanska.debian.org
Sun Aug 27 23:39:05 UTC 2017


This is an automated email from the git hooks/post-receive script.

metal pushed a commit to branch master
in repository node-colors.

commit 797d97cb55aff8487d5a69bb9e65ca649fbd4da1
Author: Marcelo Jorge Vieira <metal at alucinados.com>
Date:   Sun Aug 27 19:56:48 2017 -0300

    New upstream version 1.1.2
---
 MIT-LICENSE.txt => LICENSE   |   0
 ReadMe.md                    |  21 ++++++++++++++++-----
 lib/colors.js                |  11 +++++++++++
 lib/custom/zalgo.js          |  14 +++++++-------
 lib/extendStringPrototype.js |  11 +++--------
 lib/index.js                 |   2 +-
 package.json                 |  11 +++++++++--
 screenshots/colors.png       | Bin 79787 -> 22110 bytes
 8 files changed, 47 insertions(+), 23 deletions(-)

diff --git a/MIT-LICENSE.txt b/LICENSE
similarity index 100%
rename from MIT-LICENSE.txt
rename to LICENSE
diff --git a/ReadMe.md b/ReadMe.md
index beb5b14..0326aab 100644
--- a/ReadMe.md
+++ b/ReadMe.md
@@ -1,8 +1,8 @@
-# colors.js
+# colors.js [![Build Status](https://travis-ci.org/Marak/colors.js.svg?branch=master)](https://travis-ci.org/Marak/colors.js)
 
 ## get color and style in your node.js console
 
-<img src="https://github.com/Marak/colors.js/raw/master/screenshots/colors.png"/>
+![Demo](https://raw.githubusercontent.com/Marak/colors.js/master/screenshots/colors.png)
 
 ## Installation
 
@@ -25,8 +25,6 @@
 
 ### background colors
 
-
-
   - bgBlack
   - bgRed
   - bgGreen
@@ -162,6 +160,19 @@ console.log(colors.error("this is an error"));
 
 // outputs yellow text
 console.log(colors.warn("this is a warning"));
+
+```
+
+You can also combine them:
+
+```javascript
+var colors = require('colors');
+
+colors.setTheme({
+  custom: ['red', 'underline']
+});
+
+console.log('test'.custom);
 ```
 
-*Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*
\ No newline at end of file
+*Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*
diff --git a/lib/colors.js b/lib/colors.js
index 59898de..790ffd4 100644
--- a/lib/colors.js
+++ b/lib/colors.js
@@ -48,6 +48,10 @@ colors.stripColors = colors.strip = function(str){
 
 
 var stylize = colors.stylize = function stylize (str, style) {
+  if (!colors.enabled) {
+    return str+'';
+  }
+
   return ansiStyles[style].open + str + ansiStyles[style].close;
 }
 
@@ -115,6 +119,13 @@ function applyTheme (theme) {
   for (var style in theme) {
     (function(style){
       colors[style] = function(str){
+        if (typeof theme[style] === 'object'){
+          var out = str;
+          for (var i in theme[style]){
+            out = colors[theme[style][i]](out);
+          }
+          return out;
+        }
         return colors[theme[style]](str);
       };
     })(style)
diff --git a/lib/custom/zalgo.js b/lib/custom/zalgo.js
index 4dc20c8..1538c3b 100644
--- a/lib/custom/zalgo.js
+++ b/lib/custom/zalgo.js
@@ -58,10 +58,10 @@ module['exports'] = function zalgo(text, options) {
   function heComes(text, options) {
     var result = '', counts, l;
     options = options || {};
-    options["up"] = options["up"] || true;
-    options["mid"] = options["mid"] || true;
-    options["down"] = options["down"] || true;
-    options["size"] = options["size"] || "maxi";
+    options["up"] =   typeof options["up"]   !== 'undefined' ? options["up"]   : true;
+    options["mid"] =  typeof options["mid"]  !== 'undefined' ? options["mid"]  : true;
+    options["down"] = typeof options["down"] !== 'undefined' ? options["down"] : true;
+    options["size"] = typeof options["size"] !== 'undefined' ? options["size"] : "maxi";
     text = text.split('');
     for (l in text) {
       if (is_char(l)) {
@@ -72,12 +72,12 @@ module['exports'] = function zalgo(text, options) {
       switch (options.size) {
       case 'mini':
         counts.up = randomNumber(8);
-        counts.min = randomNumber(2);
+        counts.mid = randomNumber(2);
         counts.down = randomNumber(8);
         break;
       case 'maxi':
         counts.up = randomNumber(16) + 3;
-        counts.min = randomNumber(4) + 1;
+        counts.mid = randomNumber(4) + 1;
         counts.down = randomNumber(64) + 3;
         break;
       default:
@@ -100,5 +100,5 @@ module['exports'] = function zalgo(text, options) {
     return result;
   }
   // don't summon him
-  return heComes(text);
+  return heComes(text, options);
 }
diff --git a/lib/extendStringPrototype.js b/lib/extendStringPrototype.js
index b6b5b03..67374a1 100644
--- a/lib/extendStringPrototype.js
+++ b/lib/extendStringPrototype.js
@@ -1,5 +1,4 @@
-var colors = require('./colors'),
-    styles = require('./styles');
+var colors = require('./colors');
 
 module['exports'] = function () {
 
@@ -18,10 +17,6 @@ module['exports'] = function () {
       }
   };
 
-  var stylize = function stylize (str, style) {
-    return styles[style].open + str + styles[style].close;
-  }
-
   addProperty('strip', function () {
     return colors.strip(this);
   });
@@ -60,7 +55,7 @@ module['exports'] = function () {
   var x = Object.keys(colors.styles);
   x.forEach(function (style) {
     addProperty(style, function () {
-      return stylize(this, style);
+      return colors.stylize(this, style);
     });
   });
 
@@ -91,7 +86,7 @@ module['exports'] = function () {
           addProperty(prop, function () {
             var ret = this;
             for (var t = 0; t < theme[prop].length; t++) {
-              ret = exports[theme[prop][t]](ret);
+              ret = colors[theme[prop][t]](ret);
             }
             return ret;
           });
diff --git a/lib/index.js b/lib/index.js
index 96d2b84..fd0956d 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -9,4 +9,4 @@ module['exports'] = colors;
 //   colors.red("foo")
 //
 //
-var extendStringPrototype = require('./extendStringPrototype')();
\ No newline at end of file
+require('./extendStringPrototype')();
\ No newline at end of file
diff --git a/package.json b/package.json
index dc6ce6b..c365064 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
     "name": "colors",
     "description": "get colors in your node.js console",
-    "version": "1.0.3",
+    "version": "1.1.2",
     "author": "Marak Squires",
     "homepage": "https://github.com/Marak/colors.js",
     "bugs": "https://github.com/Marak/colors.js/issues",
@@ -17,5 +17,12 @@
     "engines": {
         "node": ">=0.1.90"
     },
-    "main": "./lib/index"
+    "main": "lib",
+    "files": [
+        "examples",
+        "lib",
+        "LICENSE",
+        "safe.js",
+        "themes"
+    ]
 }
diff --git a/screenshots/colors.png b/screenshots/colors.png
index 7200a62..6352ae5 100644
Binary files a/screenshots/colors.png and b/screenshots/colors.png differ

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-colors.git



More information about the Pkg-javascript-commits mailing list