What is sisteransi?
The sisteransi npm package provides utilities for manipulating ANSI escape codes, which are used to control text formatting, color, and other output options on text terminals.
What are sisteransi's main functionalities?
Text Formatting
This feature allows you to format text with styles such as bold, italic, and underline using ANSI escape codes.
const sisteransi = require('sisteransi');
console.log(sisteransi.bold('This is bold text'));
console.log(sisteransi.italic('This is italic text'));
console.log(sisteransi.underline('This is underlined text'));
Text Color
This feature allows you to change the color of the text using ANSI escape codes. You can set the text to various colors like red, green, and blue.
const sisteransi = require('sisteransi');
console.log(sisteransi.red('This is red text'));
console.log(sisteransi.green('This is green text'));
console.log(sisteransi.blue('This is blue text'));
Background Color
This feature allows you to change the background color of the text using ANSI escape codes. You can set the background to various colors like red, green, and blue.
const sisteransi = require('sisteransi');
console.log(sisteransi.bgRed('This text has a red background'));
console.log(sisteransi.bgGreen('This text has a green background'));
console.log(sisteransi.bgBlue('This text has a blue background'));
Other packages similar to sisteransi
chalk
Chalk is a popular npm package for styling terminal strings. It provides a simple and intuitive API for applying text styles and colors. Compared to sisteransi, Chalk is more widely used and has a larger community, but both packages offer similar functionalities for text styling and coloring.
ansi-colors
Ansi-colors is another npm package for styling terminal text with ANSI escape codes. It offers a wide range of text formatting and coloring options. Compared to sisteransi, ansi-colors is known for its performance and lightweight nature, making it a good choice for projects where performance is critical.
kleur
Kleur is a very lightweight and fast library for terminal string styling. It provides a minimalistic API for applying text styles and colors. Compared to sisteransi, Kleur focuses on being extremely lightweight and fast, making it suitable for performance-sensitive applications.
sister ANSI
Ansi escape codes faster than you can say "Bam bam".
Installation
npm install sisteransi
Usage
const ansi = require('sisteransi');
const p = str => process.stdout.write(str);
p(ansi.cursor.to(2, 1));
p(ansi.cursor.up(2)+ansi.cursor.down(1));
API
cursor
to(x, y)
Set the absolute position of the cursor. x0
y0
is the top left of the screen.
move(x, y)
Set the position of the cursor relative to its current position.
up(count = 1)
Move cursor up a specific amount of rows. Default is 1
.
down(count = 1)
Move cursor down a specific amount of rows. Default is 1
.
forward(count = 1)
Move cursor forward a specific amount of rows. Default is 1
.
backward(count = 1)
Move cursor backward a specific amount of rows. Default is 1
.
nextLine(count = 1)
Move cursor to the next line a specific amount of lines. Default is 1
.
prevLine(count = 1)
Move cursor to the previous a specific amount of lines. Default is 1
.
left
Move cursor to the left side.
hide
Hide cursor.
show
Show cursor.
save
Save cursor position.
restore
Restore cursor position.
scroll
up(count = 1)
Scroll display up a specific amount of lines. Default to 1
.
down(count = 1)
Scroll display down a specific amount of lines. Default to 1
.
erase
screen
Erase the screen and move the cursor the top left position.
up(count = 1)
Erase the screen from the current line up to the top of the screen. Default to 1
.
down(count = 2)
Erase the screen from the current line down to the bottom of the screen. Default to 1
.
line
Erase the entire current line.
lineEnd
Erase from the current cursor position to the end of the current line.
lineStart
Erase from the current cursor position to the start of the current line.
lines(count)
Erase from the current cursor position up the specified amount of rows.
Credit
This is a fork of ansi-escapes.
License
MIT © Terkel Gjervig