linegauge/v8
Every export of linegauge/v8, with its signature and doc comment: lineCount, measure, width, width, plus 2 types.
linegauge/v8 — string-width 8.3.0's drop-in, for a project pinned to string-width@8.
import width from 'linegauge/v8';
import { lineCount, measure, width } from 'linegauge/v8';Functions
default
The default export, declared as width.
How many terminal columns input occupies once its escape sequences are removed.
function width(input: string, options?: WidthOptions): number;| Parameter | Type |
|---|---|
input | string |
options (optional) | WidthOptions |
Returns number
lineCount
Lines a string occupies in a terminal columns wide — the measurement the frame loop
actually asks for. An empty line still occupies one.
function lineCount(text: string, columns: number): number;| Parameter | Type |
|---|---|
text | string |
columns | number |
Returns number
measure
Columns a string of plain text occupies — no escape scan. The wrapper below has already split its input into text runs and complete sequences, so rescanning would only give a malformed sequence a second chance to be mistaken for one.
function measure(text: string, ambiguousIsWide?: boolean): number;| Parameter | Type |
|---|---|
text | string |
ambiguousIsWide (optional) | boolean |
Returns number
width
How many terminal columns input occupies once its escape sequences are removed.
function width(input: string, options?: WidthOptions): number;| Parameter | Type |
|---|---|
input | string |
options (optional) | WidthOptions |
Returns number
Interfaces
Options
What width accepts beyond the string. Graded against string-width's own suite, so the
names and the defaults are its names and its defaults, not ours.
interface WidthOptions {
/**
* Treat East Asian Ambiguous characters as one column. **Default `true`** — the incumbent's
* default, and right for a Latin terminal: `±`, `×`, `÷`, the box-drawing set, Greek and
* Cyrillic all occupy one column there.
*/
ambiguousIsNarrow?: boolean;
/**
* Count escape sequences as the characters they are made of instead of removing them.
*/
countAnsiEscapeCodes?: boolean;
}WidthOptions
What width accepts beyond the string. Graded against string-width's own suite, so the
names and the defaults are its names and its defaults, not ours.
interface WidthOptions {
/**
* Treat East Asian Ambiguous characters as one column. **Default `true`** — the incumbent's
* default, and right for a Latin terminal: `±`, `×`, `÷`, the box-drawing set, Greek and
* Cyrillic all occupy one column there.
*/
ambiguousIsNarrow?: boolean;
/**
* Count escape sequences as the characters they are made of instead of removing them.
*/
countAnsiEscapeCodes?: boolean;
}linegauge/plugin
Every export of linegauge/plugin, with its signature and doc comment: setOverrides, overrides, problems, validate, register, CONTRACT and 1 more, plus 3 types.
FAQ
Short answers about linegauge — terminal width, emoji, CJK, ambiguous characters, Nerd Fonts, non-strings, CommonJS and overrides — each with where to read more.