linegauge
Every export of linegauge, with its signature and doc comment: lineCount, measure, width, width, strip, widest and 3 more, plus 4 types.
linegauge — how much of a terminal line a string occupies, and how to fold it.
import width from 'linegauge';
import { lineCount, measure, width, … } from 'linegauge';Functions
default
The default export, declared as width.
How many terminal columns input occupies once its escape sequences are removed — string-width
9's answer, under its option names and defaults (WidthOptions). Non-strings measure 0.
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, each measured by width. 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.
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 — string-width
9's answer, under its option names and defaults (WidthOptions). Non-strings measure 0.
function width(input: string, options?: WidthOptions): number;| Parameter | Type |
|---|---|
input | string |
options (optional) | WidthOptions |
Returns number
Re-exported
Documented on the page of the entry point that declares them.
| Export | Kind | Documented in |
|---|---|---|
slice | function | linegauge/slice |
strip | function | linegauge/strip |
truncate | function | linegauge/truncate |
widest | function | linegauge/widest |
wrap | function | linegauge/wrap |
Options | interface | linegauge/v8 |
TruncateOptions | interface | linegauge/truncate |
WidthOptions | interface | linegauge/v8 |
WrapOptions | interface | linegauge/wrap |