mirror of
https://github.com/flynx/colors.js.git
synced 2025-11-01 04:20:12 +00:00
added some documentation to colors.js, replaced hard tabs with soft tabs, adjusted identation for sytle purposes, bumped version to 0.3.0. want to research package.json formats a bit more
This commit is contained in:
parent
96f8cd5626
commit
88509012ab
@ -23,6 +23,7 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// prototypes the string object to have additional method calls that add terminal colors
|
||||||
['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'].forEach(function (style) {
|
['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'].forEach(function (style) {
|
||||||
Object.defineProperty(String.prototype, style, {
|
Object.defineProperty(String.prototype, style, {
|
||||||
get: function () {
|
get: function () {
|
||||||
@ -31,6 +32,8 @@ THE SOFTWARE.
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// prototypes string with method "rainbow"
|
||||||
|
// rainbow will apply a the color spectrum to a string, changing colors every letter
|
||||||
Object.defineProperty(String.prototype, 'rainbow', {
|
Object.defineProperty(String.prototype, 'rainbow', {
|
||||||
get: function () {
|
get: function () {
|
||||||
var rainbowcolors = ['red','yellow','green','blue','magenta']; //RoY G BiV
|
var rainbowcolors = ['red','yellow','green','blue','magenta']; //RoY G BiV
|
||||||
@ -39,7 +42,8 @@ Object.defineProperty(String.prototype, 'rainbow', {
|
|||||||
exploded = exploded.map(function(letter) {
|
exploded = exploded.map(function(letter) {
|
||||||
if (letter==" ") {
|
if (letter==" ") {
|
||||||
return letter;
|
return letter;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return stylize(letter,rainbowcolors[i++ % rainbowcolors.length]);
|
return stylize(letter,rainbowcolors[i++ % rainbowcolors.length]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
var sys = require('sys');
|
var sys = require('sys');
|
||||||
var colors = require('./colors');
|
var colors = require('./colors');
|
||||||
|
|
||||||
sys.puts('Colors are fun!'.rainbow);
|
sys.puts('Rainbows are fun!'.rainbow);
|
||||||
sys.puts('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
|
sys.puts('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
|
||||||
sys.puts('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
|
sys.puts('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
|
||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "colors",
|
"name": "colors",
|
||||||
"description": "get colors in your node.js console like what",
|
"description": "get colors in your node.js console like what",
|
||||||
"version": "0.2.0",
|
"version": "0.3.0",
|
||||||
"author": "Marak Squires",
|
"author": "Marak Squires",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -10,7 +10,5 @@
|
|||||||
"engine": [
|
"engine": [
|
||||||
"node >=0.1.90"
|
"node >=0.1.90"
|
||||||
],
|
],
|
||||||
"main": "colors" ,
|
"main": "colors"
|
||||||
"licenses": [{ "type": "MIT" }]
|
|
||||||
"contributers": ["Alexis Sellier", "Justin Campbell"]
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user