1.0.0 • Published 4 years ago

@stgdp/ansi-codes v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@stgdp/ansi-codes

Get useful ANSI codes for use in your console

npm Version Build Status License Dependency Status

ansi-codes is a Node.js module that supplies you with useful ANSI escape codes to format your terminal. Change the text color, background color, make the text bold, italic, underline and more.

Installation

With npm

npm install @stgdp/ansi-codes

With yarn

yarn add @stgdp/ansi-codes

Usage

const ansiCodes = require( "@stgdp/ansi-codes" )

var format = ansiCodes.modifiers.bold + ansiCodes.bg.red + ansiCodes.fg.white

// Produces a bold console log with red background and white text
console.log( `${format}I'm formatted!${ansiCodes.reset.all} )

Reference

All codes listed below are available without the escape prefix and suffix within ansiCodes.codes for further customisations

Colors

Foreground ansiCodes.fgBackground ansiCodes.bgBright Foreground ansiCodes.fg.brightBright Background ansiCodes.bg.bright
blackblackblackblack
redredredred
greengreengreengreen
yellowyellowyellowyellow
blueblueblueblue
magentamagentamagentamagenta
cyancyancyancyan
whitewhitewhitewhite

Misc

Modifiers ansiCodes.modifierReset ansiCodes.resetEscapes ansiCodes.escape
boldallprefix
dimboldsuffix
italicdim
underlineitalic
inverseunderline
hiddeninverse
strikehidden
framestrike
encirclefg
overlinebg
frame
encircle
overline

License

MIT License

Copyright (c) 2020 Andrew Palfrey <apalfrey@apalfrey.me>

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.