pax_global_header00006660000000000000000000000064122473735600014523gustar00rootroot0000000000000052 comment=50db53e34e9f98391fee72cca2c233216c8bad11 ansistyles-0.1.3/000077500000000000000000000000001224737356000137225ustar00rootroot00000000000000ansistyles-0.1.3/.gitignore000066400000000000000000000001411224737356000157060ustar00rootroot00000000000000lib-cov *.seed *.log *.csv *.dat *.out *.pid *.gz pids logs results npm-debug.log node_modules ansistyles-0.1.3/.npmignore000066400000000000000000000000271224737356000157200ustar00rootroot00000000000000.npmignore .travis.yml ansistyles-0.1.3/.travis.yml000066400000000000000000000000531224737356000160310ustar00rootroot00000000000000language: node_js node_js: - 0.6 - 0.8 ansistyles-0.1.3/LICENSE000066400000000000000000000020661224737356000147330ustar00rootroot00000000000000Copyright 2013 Thorsten Lorenz. All rights reserved. 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. ansistyles-0.1.3/README.md000066400000000000000000000042011224737356000151760ustar00rootroot00000000000000# ansistyles [![build status](https://secure.travis-ci.org/thlorenz/ansistyles.png)](http://next.travis-ci.org/thlorenz/ansistyles) Functions that surround a string with ansistyle codes so it prints in style. In case you need colors, like `red`, have a look at [ansicolors](https://github.com/thlorenz/ansicolors). ## Installation npm install ansistyles ## Usage ```js var styles = require('ansistyles'); console.log(styles.bright('hello world')); // prints hello world in 'bright' white console.log(styles.underline('hello world')); // prints hello world underlined console.log(styles.inverse('hello world')); // prints hello world black on white ``` ## Combining with ansicolors Get the ansicolors module: npm install ansicolors ```js var styles = require('ansistyles') , colors = require('ansicolors'); console.log( // prints hello world underlined in blue on a green background colors.bgGreen(colors.blue(styles.underline('hello world'))) ); ``` ## Tests Look at the [tests](https://github.com/thlorenz/ansistyles/blob/master/test/ansistyles.js) to see more examples and/or run them via: npm explore ansistyles && npm test ## More Styles As you can see from [here](https://github.com/thlorenz/ansistyles/blob/master/ansistyles.js#L4-L15), more styles are available, but didn't have any effect on the terminals that I tested on Mac Lion and Ubuntu Linux. I included them for completeness, but didn't show them in the examples because they seem to have no effect. ### reset A style reset function is also included, please note however that this is not nestable. Therefore the below only underlines `hell` only, but not `world`. ```js console.log(styles.underline('hell' + styles.reset('o') + ' world')); ``` It is essentially the same as: ```js console.log(styles.underline('hell') + styles.reset('') + 'o world'); ``` ## Alternatives **ansistyles** tries to meet simple use cases with a very simple API. However, if you need a more powerful ansi formatting tool, I'd suggest to look at the [features](https://github.com/TooTallNate/ansi.js#features) of the [ansi module](https://github.com/TooTallNate/ansi.js). ansistyles-0.1.3/ansistyles.js000066400000000000000000000017221224737356000164600ustar00rootroot00000000000000'use strict'; /* * Info: http://www.termsys.demon.co.uk/vtansi.htm#colors * Following caveats * bright - brightens the color (bold-blue is same as brigthtBlue) * dim - nothing on Mac or Linux * italic - nothing on Mac or Linux * underline - underlines string * blink - nothing on Mac or linux * inverse - background becomes foreground and vice versa * * In summary, the only styles that work are: * - bright, underline and inverse * - the others are only included for completeness */ var styleNums = { reset : [0, 22] , bright : [1, 22] , dim : [2, 22] , italic : [3, 23] , underline : [4, 24] , blink : [5, 25] , inverse : [7, 27] } , styles = {} ; Object.keys(styleNums).forEach(function (k) { styles[k] = function (s) { var open = styleNums[k][0] , close = styleNums[k][1]; return '\u001b[' + open + 'm' + s + '\u001b[' + close + 'm'; }; }); module.exports = styles; ansistyles-0.1.3/package.json000066400000000000000000000011011224737356000162010ustar00rootroot00000000000000{ "name": "ansistyles", "version": "0.1.3", "description": "Functions that surround a string with ansistyle codes so it prints in style.", "main": "ansistyles.js", "scripts": { "test": "node test/ansistyles.js" }, "repository": { "type": "git", "url": "git://github.com/thlorenz/ansistyles.git" }, "keywords": [ "ansi", "style", "terminal", "console" ], "author": "Thorsten Lorenz (thlorenz.com)", "license": "MIT", "readmeFilename": "README.md", "gitHead": "27bf1bc65231bcc7fd109bf13b13601b51f8cd04" } ansistyles-0.1.3/test/000077500000000000000000000000001224737356000147015ustar00rootroot00000000000000ansistyles-0.1.3/test/ansistyles.js000066400000000000000000000010401224737356000174300ustar00rootroot00000000000000'use strict'; /*jshint asi: true */ var assert = require('assert') , styles = require('../') function inspect(obj, depth) { console.log(require('util').inspect(obj, false, depth || 5, true)); } assert.equal(styles.reset('reset'), '\u001b[0mreset\u001b[22m', 'reset') assert.equal(styles.underline('underlined'), '\u001b[4munderlined\u001b[24m', 'underline') assert.equal(styles.bright('bright'), '\u001b[1mbright\u001b[22m', 'bright') assert.equal(styles.inverse('inversed'), '\u001b[7minversed\u001b[27m', 'inverse') console.log('OK');