colors 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 1289344911102-0.9609897416085005/._MIT-LICENSE.txt +0 -0
- 1289344911102-0.9609897416085005/._ReadMe.md +0 -0
- 1289344911102-0.9609897416085005/._colors.js +0 -0
- 1289344911102-0.9609897416085005/._example.js +0 -0
- 1289344911102-0.9609897416085005/._package.json +0 -0
- 1289344911102-0.9609897416085005/MIT-LICENSE.txt +20 -0
- 1289344911102-0.9609897416085005/ReadMe.md +30 -0
- 1289344911102-0.9609897416085005/colors.js +75 -0
- 1289344911102-0.9609897416085005/example.js +6 -0
- 1289344911102-0.9609897416085005/package.json +14 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Marak Squires http://github.com/marak/say.js/
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<h1>colors.js - get color and style in your node.js console like what</h1>
|
2
|
+
|
3
|
+
<img src="http://i.imgur.com/goJdO.png" border = "0"/>
|
4
|
+
|
5
|
+
var sys = require('sys');
|
6
|
+
var colors = require('./colors');
|
7
|
+
|
8
|
+
sys.puts('hello'.green); // outputs green text
|
9
|
+
sys.puts('i like cake and pies'.underline.red) // outputs red underlined text
|
10
|
+
sys.puts('inverse the color'.inverse); // inverses the color
|
11
|
+
sys.puts('OMG Rainbows!'.rainbow); // rainbow (ignores spaces)
|
12
|
+
|
13
|
+
<h2>colors and styles!</h2>
|
14
|
+
- bold
|
15
|
+
- italic
|
16
|
+
- underline
|
17
|
+
- inverse
|
18
|
+
- yellow
|
19
|
+
- cyan
|
20
|
+
- white
|
21
|
+
- magenta
|
22
|
+
- green
|
23
|
+
- red
|
24
|
+
- grey
|
25
|
+
- blue
|
26
|
+
|
27
|
+
|
28
|
+
### Authors
|
29
|
+
|
30
|
+
#### Alexis Sellier (cloudhead) , Marak Squires , Justin Campbell
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/*
|
2
|
+
colors.js
|
3
|
+
|
4
|
+
Copyright (c) 2010 Alexis Sellier (cloudhead) , Marak Squires
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
23
|
+
|
24
|
+
*/
|
25
|
+
|
26
|
+
// prototypes the string object to have additional method calls that add terminal colors
|
27
|
+
['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'].forEach(function (style) {
|
28
|
+
Object.defineProperty(String.prototype, style, {
|
29
|
+
get: function () {
|
30
|
+
return stylize(this, style);
|
31
|
+
}
|
32
|
+
});
|
33
|
+
});
|
34
|
+
|
35
|
+
// prototypes string with method "rainbow"
|
36
|
+
// rainbow will apply a the color spectrum to a string, changing colors every letter
|
37
|
+
Object.defineProperty(String.prototype, 'rainbow', {
|
38
|
+
get: function () {
|
39
|
+
var rainbowcolors = ['red','yellow','green','blue','magenta']; //RoY G BiV
|
40
|
+
var exploded = this.split("");
|
41
|
+
var i=0;
|
42
|
+
exploded = exploded.map(function(letter) {
|
43
|
+
if (letter==" ") {
|
44
|
+
return letter;
|
45
|
+
}
|
46
|
+
else {
|
47
|
+
return stylize(letter,rainbowcolors[i++ % rainbowcolors.length]);
|
48
|
+
}
|
49
|
+
});
|
50
|
+
return exploded.join("");
|
51
|
+
}
|
52
|
+
});
|
53
|
+
|
54
|
+
function stylize(str, style) {
|
55
|
+
var styles = {
|
56
|
+
//styles
|
57
|
+
'bold' : [1, 22],
|
58
|
+
'italic' : [3, 23],
|
59
|
+
'underline' : [4, 24],
|
60
|
+
'inverse' : [7, 27],
|
61
|
+
//grayscale
|
62
|
+
'white' : [37, 39],
|
63
|
+
'grey' : [90, 39],
|
64
|
+
'black' : [90, 39],
|
65
|
+
//colors
|
66
|
+
'blue' : [34, 39],
|
67
|
+
'cyan' : [36, 39],
|
68
|
+
'green' : [32, 39],
|
69
|
+
'magenta' : [35, 39],
|
70
|
+
'red' : [31, 39],
|
71
|
+
'yellow' : [33, 39]
|
72
|
+
};
|
73
|
+
return '\033[' + styles[style][0] + 'm' + str +
|
74
|
+
'\033[' + styles[style][1] + 'm';
|
75
|
+
};
|
@@ -0,0 +1,6 @@
|
|
1
|
+
var sys = require('sys');
|
2
|
+
var colors = require('./colors');
|
3
|
+
|
4
|
+
sys.puts('Rainbows are fun!'.rainbow);
|
5
|
+
sys.puts('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
|
6
|
+
sys.puts('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"name": "colors",
|
3
|
+
"description": "get colors in your node.js console like what",
|
4
|
+
"version": "0.3.0",
|
5
|
+
"author": "Marak Squires",
|
6
|
+
"repository": {
|
7
|
+
"type": "git",
|
8
|
+
"url": "http://github.com/Marak/colors.js.git"
|
9
|
+
},
|
10
|
+
"engine": [
|
11
|
+
"node >=0.1.90"
|
12
|
+
],
|
13
|
+
"main": "colors"
|
14
|
+
}
|