
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
ANSI stream control of position, style, and color via fluent API.
ansi2 sends ANSI escape codes to a writable stream to:
npm install --save ansi2
// wrap a writable stream
var ansi = require('ansi2')(process.stdout)
// write a string to stream.
// it's affected by the current color/style/position.
// default styling + color:
ansi.write('boring default text')
// reset the foreground, background, and styling.
ansi.reset()
// Or, reset only the foreground:
ansi.resetFg()
// Or, reset only the background:
ansi.resetBg()
// all functions are chainable:
ansi.reset().blue().blackBg().write('blah').reset().write('\n')
// convenience method helps reset before writing a newline
// to avoid repeatedly writing: .reset().write('\n')
ansi.bold().blue('some bold blue text').newline()
.underline().green('some underlined green text').newline()
Available colors as functions:
Use the "bright" versions of those by adding suffix "Bright" to the function name.
Apply the color to the background by adding suffix "Bg" to the function name.
Apply both suffixes for a bright background (add suffix "BrightBg").
Other color functions accept RGB values and CSS style hex codes:
rgb(r, g, b)
- Also has a background version as rgbBg(r, g, b)
hex(string)
- Also has a background version as hexBg(string)
. May have a hash symbol prefix, or not.Color functions called with an argument will change the color and then write the string.
ansi.blue().write('blue text')
// Or, use a shorthand, provide the text to the color function:
ansi.blue('blue text')
// still using blue for foreground.
// change the background now.
// standard colors have a "background" version
// by adding 'Bg' to their function name.
ansi.blackBg().write('blue on black text')
// or specify colors via RGB or hex values.
// all these change the color to red.
ansi.rgb(255, 0, 0)
ansi.hex('FF0000')
ansi.hex('#FF0000')
Available styles as functions:
Reset the style by adding suffix "Reset" to the function name.
Style functions called with an argument will change the style and then write the string.
ansi.bold().write('bold text')
// Or, use a shorthand, provide the text to the color function:
ansi.bold('bold text')
ansi.italic()
// then, undo the bold styling only, retaining italic.
ansi.boldReset()
Available position functions:
// example using default, this will move up one line:
ansi.up()
// example specifying amount to move, this moves up 5 lines:
ansi.up(5)
// moves to the top left:
ansi.goto()
// moves to line 5 column 7:
ansi.goto(7, 5) // think (x, y)
// erase current line and then write new content:
ansi.restartLine().write('new text overwriting current line')
// or, restart back at a certain column to overwrite only the later part:
ansi.write('label: some text') // shows whole string
.restartLine(7).write('new text') // shows: label: new text
FAQs
ansi2
The npm package ansi2 receives a total of 735 weekly downloads. As such, ansi2 popularity was classified as not popular.
We found that ansi2 demonstrated a healthy version release cadence and project activity because the last version was released less than 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
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.