ansi-rainbow
Advanced tools
Comparing version 0.0.8 to 0.0.9
60
index.js
@@ -7,12 +7,12 @@ var ansi = require('ansi-styles') | ||
var Pony = function() { | ||
this._colors = [ | ||
this._colors = [ | ||
'red', | ||
'green', | ||
'green', | ||
'yellow', | ||
'blue', | ||
'magenta', | ||
'cyan', | ||
'blue', | ||
'magenta', | ||
'cyan', | ||
'white', | ||
'black' | ||
] | ||
] | ||
@@ -30,4 +30,4 @@ this._colors_num = this._colors.length | ||
this._next = 0 | ||
this._prev = -1 | ||
this._next = 0 | ||
this._prev = -1 | ||
@@ -136,22 +136,20 @@ this.options = {color_space: false, gap: 1, space_color: null} | ||
}, | ||
nextColor: function(s, colors) { | ||
nextColor: function(s, colors) { | ||
var l = colors.length - 1 | ||
var l = colors.length - 1 | ||
if(this._prev >= l) { | ||
this._prev = 0, this._next = 1 | ||
if(this._prev >= l) { | ||
this._prev = 0, this._next = 1 | ||
s = ansi[colors[0]].open + s + ansi[colors[0]].close | ||
} else { | ||
s = ansi[colors[this._next]].open + s + ansi[colors[this._next]].close | ||
s = ansi[colors[0]].open + s + ansi[colors[0]].close | ||
} else { | ||
s = ansi[colors[this._next]].open + s + ansi[colors[this._next]].close | ||
this._next++ | ||
this._prev++ | ||
} | ||
this._prev++ | ||
} | ||
this._current_gap++ | ||
return s | ||
}, | ||
return s | ||
}, | ||
currentColor: function(s, colors) { | ||
@@ -175,9 +173,9 @@ var l = colors.length - 1 | ||
}, | ||
output: function(input, colors) { | ||
var l = input.length, output = '', i = 0, gap = this.options.gap, s | ||
output: function(input, colors) { | ||
var l = input.length, output = '', i = 0, gap = this.options.gap, s | ||
this._current_gap = gap | ||
this._current_gap = 1 | ||
for (i; i < l; i++) { | ||
this._current_gap = this._current_gap > gap ? gap : this._current_gap | ||
this._current_gap = this._current_gap > gap ? 1 : this._current_gap | ||
s = input.charAt(i) | ||
@@ -196,11 +194,11 @@ | ||
} | ||
} | ||
} | ||
//reset state | ||
this._next = 0, this._prev = -1 | ||
//reset state | ||
this._next = 0, this._prev = -1 | ||
return output | ||
} | ||
return output | ||
} | ||
} | ||
module.exports = new Pony() |
{ | ||
"name": "ansi-rainbow", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "One of the most advanced ansi string rainbow stylizer tool", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11437