Compatibility
How linegauge's four drop-ins are graded — each incumbent's own test suite, unedited — the current grades, and the differences that remain.
linegauge (its default export), linegauge/wrap, linegauge/strip and linegauge/slice
are graded, not described as compatible. Each is run against its incumbent's own test
suite, by
compat-oracle,
in CI.
✓ yes · ◐ partial, with what is missing · ✗ no · — does not apply. Every mark links to its evidence: our test or grade, or the incumbent’s source at the version compat-oracle grades.
Compatibility
Passes string-width's own test suite
linegauge's default export is graded by string-width 8.3.0's own tests, unedited, so changing the import keeps string-width's answers.
string-width- string-width: yesits own suite, the control run
Passes wrap-ansi's own test suite
linegauge/wrapis graded by wrap-ansi 10.0.2's own tests, unedited.string-width- string-width: does not applya different API
Passes strip-ansi's own test suite
linegauge/stripis graded by strip-ansi 7.2.0's own tests, unedited.linegauge- linegauge: yes8 / 8 of its own tests
string-width- string-width: does not applya different API
Passes slice-ansi's own test suite
linegauge/sliceis graded by slice-ansi 9.0.1's own tests, unedited.string-width- string-width: does not applya different API
The counts are compat-oracle's baselines, the pass count each drop-in is held to. The family's compatibility page is generated from the oracle's last run and is the authority for the current figures, beside every other drop-in in the family.
| incumbent | graded version | drop-in | cases |
|---|---|---|---|
| string-width | 8.3.0 | import stringWidth from 'linegauge' | 233 / 233 |
| wrap-ansi | 10.0.2 | import wrapAnsi from 'linegauge/wrap' | 85 / 85 |
| strip-ansi | 7.2.0 | import stripAnsi from 'linegauge/strip' | 8 / 8 |
| slice-ansi | 9.0.1 | import sliceAnsi from 'linegauge/slice' | 104 / 104 |
How a suite is graded
- The incumbent's repository is cloned at the release tag of the graded version and its test
file copied into
packages/compat-oracle/vendor/. No incumbent ships its tests to npm, so a tarball could not be used. Each copy'sPROVENANCEfile names the tag, the commit and the command that reproduces it. - The only edit is the import that reaches the library: it is rewritten to a shim generated per run. Assertions, fixtures and helpers are upstream's, byte for byte.
- A control run points the shim at the real incumbent first. That proves the harness before it grades anything of ours, and the control's total is what every rate is measured against.
- The target run points the same shim at linegauge's path.
Beyond the suites
Each path is also graded differentially in linegauge's own tests, against the real
incumbent installed beside it: wrap.test.ts compares wrap with wrap-ansi on thirty named
inputs under six option sets and on two hundred generated ones, slice.test.ts compares every
[start, end) of its corpus with slice-ansi, and strip.test.ts compares sixteen sequence
shapes with strip-ansi. truncate, which has no drop-in path, is compared case by case with
cli-truncate.
Known differences
- The ellipsis of
truncateis never styled. cli-truncate paints it in the text's colour at two of its three positions and not the third;truncateputs it after the closing sequence at all three. There is nolinegauge/cli-truncate, so no import moves onto this by accident (Slicing and truncating). - A width plugin changes every answer. With nothing registered — the default — every path
gives Unicode's answer, which is what the suites grade. Registering a
widthsplugin is how you ask for a different one (Width plugins).
Types and CommonJS
Each path's default export is the incumbent's default, and its options type is exported under
the incumbent's name — Options from linegauge and from linegauge/wrap — so a TypeScript
program migrates by its import alone. require('linegauge') returns the namespace, whose
default is width, and an overrides entry can move a transitive string-width onto it:
{ "overrides": { "string-width": "npm:linegauge@^0.5" } }Why linegauge
linegauge against string-width, wrap-ansi, strip-ansi and slice-ansi, one capability per row, every cell linked to the test, grade or source that proves it.
Coming from string-width
A string-width alternative with zero dependencies: linegauge's default export is string-width, graded 233 / 233 by its own suite — plus wrap-ansi, strip-ansi and slice-ansi paths, grapheme-correct over Intl.Segmenter and pure, so a pipe and a terminal get the same columns.