Ansi escape codes faster than you can say "Bam bam".
npm install sisteransi
Note:
sisteransi2.0 is ESM-only and needs Node.js >= 20.importworks on any Node 20+, and CommonJS canrequire()it on Node 20.19+ (whererequire(esm)is unflagged). Stay on the1.xline only if you're on older Node. (Contributing? The test suite runs the TypeScript source directly via Node's type stripping, so local development needs Node.js >= 22.)
import { cursor } from 'sisteransi';
// or grab everything: import * as ansi from 'sisteransi';
const p = str => process.stdout.write(str);
// move cursor to 2, 1
p(cursor.to(2, 1));
// up two, down one
p(cursor.up(2) + cursor.down(1));Set the absolute position of the cursor. x0 y0 is the top left of the screen.
Set the position of the cursor relative to its current position.
Move cursor up a specific amount of rows. Default is 1.
Move cursor down a specific amount of rows. Default is 1.
Move cursor forward a specific amount of rows. Default is 1.
Move cursor backward a specific amount of rows. Default is 1.
Move cursor to the next line a specific amount of lines. Default is 1.
Move cursor to the previous a specific amount of lines. Default is 1.
Move cursor to the left side.
Hide cursor.
Show cursor.
Save cursor position.
Restore cursor position.
Scroll display up a specific amount of lines. Default to 1.
Scroll display down a specific amount of lines. Default to 1.
Erase the screen and move the cursor the top left position.
Erase the screen from the current line up to the top of the screen. Default to 1.
Erase the screen from the current line down to the bottom of the screen. Default to 1.
Erase the entire current line.
Erase from the current cursor position to the end of the current line.
Erase from the current cursor position to the start of the current line.
Erase from the current cursor position up the specified amount of rows.
Clear the terminal screen. (Viewport)
This is a fork of ansi-escapes.
MIT © Terkel Gjervig