Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Basic ansi formatting, foreground and background colours for use with CLIs.
npm install ansi-pansi
var ansi = require( 'ansi-pansi' ),
foo = ansi( 'foo' );
console.log( foo.bold().blue().background().yellow().toString() );
// logs in bold, blue text on a yellow background => foo
console.log( foo.reset().concat( '\nbar' ).italic().text().white().background().red().toString() );
// logs in bold, blue text on a yellow background => foo
// logs in italic, white text on a red background => bar
ansi.clear(); // same as executing – $> clear – from the command line
The following convenience methods are available on the AnsiPansi
instance returned by the ansi
method.
Concatenated the passed string
to the current String. Any formatting options already set are still valid.
var ansi = require( 'ansi-pansi' ),
foo = ansi( 'foo' );
foo.red().bold(); // red and bold formatting is applied to 'foo'
foo.concat( 'bar' ); // red and bold formatting is ALSO applied to 'bar'
Resets the formatting on the current instance, so any new Strings which are concatenated to it will not have any previous formatting applied.
var ansi = require( 'ansi-pansi' ),
foo = ansi( 'foo' );
foo.red().bold(); // red and bold formatting is applied to 'foo'
foo.concat( 'bar' ); // red and bold formatting is ALSO applied to 'bar'
foo.reset().concat( 'lorem ipsum' ); // no formatting currently applied to 'lorem ipsum'
Returns the ANSI formatted String created.
var ansi = require( 'ansi-pansi' ),
foo = ansi( 'foo' );
foo.red().bold().concat( 'bar' );
foo.concat( 'lorem ipsum' ).italic().blue();
foo.toString(); // returns => '\u001b[0m\u001b[1;31mfoo bar\u001b[0m \u001b[3;34mlorem ipsum\u001b[0m\u001b[m'
All the options below are methods on the AnsiPansi
instance returned by calling ansi
.
**NOTE: ** Not all formatting across all CLIs.
bold
, faint
, italic
, underline
, blink
, blinkfast
, invert
, hide
, strike
background
, text
NOTE: All colours are automaticallu assigned to text
unless you call background
first. Once a background colour is set, text
is called to allow setting the text colour.
var ansi = require( 'ansi-pansi' ),
str = ansi( 'lorem ipsum ' ); // string
str.background().red().white() // format above text to be white on a red background
str.concat( ' dolor sit amet' ).red().background().white() // concatenate text and format it with red text on a white background
black
, red
, green
, yellow
, blue
, magenta
, cyan
, white
NOTE: When assigning a colour it will automatically be assigned as the text
colour unless you call background
first.
(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.
FAQs
Basic ansi formatting, foreground and background colours for use with CLIs.
The npm package ansi-pansi receives a total of 6 weekly downloads. As such, ansi-pansi popularity was classified as not popular.
We found that ansi-pansi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.