Permalink
Browse files

first commit

  • Loading branch information...
constantology committed Feb 29, 2012
0 parents commit 296e23da4020be903fc281cfcf4b1294daecfd2d
Showing with 98 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +5 −0 .npmignore
  3. +9 −0 LICENSE
  4. +46 −0 README.md
  5. +14 −0 ansi-pansi.js
  6. +20 −0 package.json
@@ -0,0 +1,4 @@
+.DS_Store
+
+.idea/
+npm-debug.log
@@ -0,0 +1,5 @@
+.DS_Store
+.git*
+.idea/
+
+npm-debug.log
@@ -0,0 +1,9 @@
+(The MIT License)
+
+Copyright (c) 2011 christos "constantology" constandinou http://muigui.com
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,46 @@
+# ansi pansi
+
+Basic ansi formatting, foreground and background colours for use with CLIs.
+
+## installation
+
+```
+
+ npm install ansi-pansi
+
+```
+
+## usage
+
+```javascript
+
+ var ansiformat = require( 'ansi-pansi' );
+
+ console.log( ansiformat( 'foo', 'bold blue bg_yellow' ) );
+ // prints => 'foo' to the console in blue, bold on a yellow background.
+
+```
+
+## formatting and colour options
+You can use the below codes concatenated with either a plus `+` or a space ` ` character as shown in the example above.
+
+### formatting
+`bold`, `italic`, `underline`, `blink`, `reverse`, `hidden`.
+
+### foreground colours
+`black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
+
+### background colours
+`bg_black`, `bg_red`, `bg_green`, `bg_yellow`, `bg_blue`, `bg_magenta`, `bg_cyan`, `bg_white`
+
+## License
+
+(The MIT License)
+
+Copyright © 2012 christos "constantology" constandinou http://muigui.com
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,14 @@
+var code = {
+ reset : 0,
+// formatting
+ bold : 1, italic : 3, underline : 4, blink : 5, reverse : 7, hidden : 8,
+// foreground colours
+ black : 30, red : 31, green : 32, yellow : 33, blue : 34, magenta : 35, cyan : 36, white : 37,
+// background colours
+ bg_black : 40, bg_red : 41, bg_green : 42, bg_yellow : 43, bg_blue : 44, bg_magenta : 45, bg_cyan : 46, bg_white : 47
+};
+
+exports = function ansi_pansi( str, colour ) {
+ var f = colour.split( /[\s\+]/ ).reduce( function( s, a ) { return ( a in code ) ? s += code[a] + ';' : s; }, '' );
+ return ( f.length ? '\033[' + f + 'm' : f ) + str + '\033[0m';
+};
@@ -0,0 +1,20 @@
+{
+ "author" : {
+ "name" : "constantology",
+ "email" : "constantology@gmail.com",
+ "url" : "http://muigui.com"
+ },
+ "description" : "Basic ansi formatting, foreground and background colours for use with CLIs.",
+ "keywords" : ["ansi", "color", "colour", "cli", "console"],
+ "licenses" : [ {
+ "type" : "MIT",
+ "url" : "https://raw.github.com/constantology/ansi-pansi/master/LICENSE"
+ } ],
+ "main" : "./ansi-pansi.js",
+ "name" : "ansi-pansi",
+ "repository" : {
+ "type" : "git",
+ "url" : "git@github.com:constantology/ansi-pansi.git"
+ },
+ "version" : "0.0.1"
+}

0 comments on commit 296e23d

Please sign in to comment.