Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sty

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sty

Color and more for the console

  • 0.6.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.5K
decreased by-25.33%
Maintainers
0
Weekly downloads
 
Created
Source

Sty – Colorization and more for Node.js console output

Installation

You've got Node.js and npm, right? Then:

npm install sty

You'll also want CoffeeScript:

npm install coffee-script

Quick start

Using CoffeeScript:

sty = require 'sty'
console.log "#{sty.red 'WARNING:'} Color is #{sty.green 'awesome!'}"

Nesting works as you'd expect:

console.log "#{sty.bgblack sty.bold "#{sty.red 'U'}S#{sty.cyan 'A'}"}"

You can also use some pseudo-HTML, through sty.parse:

console.log sty.parse 'You are being <b>attacked</b> by the <b><yellow>great dragon</yellow>!</b>'

Forget valid XML; you can move tags around freely:

console.log sty.parse '<b>W<u>h</b>o</u>a'

Tags that aren't supported by sty are ignored (that is, sty.parse '<foo>' is just '<foo>').

If you find yourself using console.log sty.parse a lot, you should probably try styout.

Advanced usage

If you want to use ANSI codes directly, each is a valid sty function name; so, for instance, sty[1] is identical to sty.bold. You can also use these numbers as HTML tags, prefixed by a or A; for instance, you can get a blink effect with <A5>:

console.log sty.parse 'I saw the best minds of my generation destroyed by madness, starving hysterical naked.'

More documentation

For a complete list of every function/tag name in sty, run demo.coffee (coffee demo.coffee) after installation.

Disabling Sty

Sty automatically disables fancy output when the console doesn't support it (that is, when Node's tty.isatty(process.stdout) is false). You can also manually use sty.disable() and sty.enable() to switch styling on/off.

License and credits

Copyright (c) 2010 Trevor Burnham and made available under the MIT license:

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.

This distribution includes a slightly modified version of Bob Righter's node-xml, also under the MIT license.

Thanks go to Chris Lloyd for colored.js, which inspired this project.

Keywords

FAQs

Package last updated on 05 Apr 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc