linegauge 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +15 -11
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -89,10 +89,11 @@ The incumbent is the specification. `width` runs against `string-width`, `wrap`
89
89
 
90
90
  | | |
91
91
  | :-- | :-- |
92
- | `width(text, { countAnsiEscapeCodes })` | terminal columns the text occupies |
92
+ | `width(text, { ambiguousIsNarrow, countAnsiEscapeCodes })` | terminal columns the text occupies |
93
93
  | `wrap(text, columns, options)` | fold to a width, styles preserved across rows |
94
94
  | `truncate(text, columns, { position, ellipsis })` | cut to a budget, ellipsis counted inside it |
95
95
  | `slice(text, start, end)` | the columns `[start, end)`, self-contained |
96
+ | `strip(text)` | the text with its escape sequences removed (`linegauge/strip`) |
96
97
  | `widest(lines)` | the width of the widest line of any iterable |
97
98
  | `lineCount(text, columns)` | rows the text occupies at that width |
98
99
  | `measure(text)` | columns of plain text, no escape scan |
@@ -102,18 +103,21 @@ with whatever a template produced.
102
103
 
103
104
  ## Design notes
104
105
 
105
- **Ambiguous-width characters count narrow**, which is what a terminal does unless told it is
106
- rendering an East Asian locale. `string-width` makes that an option; nothing above this has
107
- ever needed the other answer, so it is not one here.
106
+ **Ambiguous-width characters count narrow by default**, which is what a terminal does unless
107
+ it is rendering with a CJK font. `width(text, { ambiguousIsNarrow: false })` counts them two
108
+ columns wide for that context — string-width's option, under its name and with its default.
109
+ Nothing can detect which a terminal is doing, so it is the caller's decision.
108
110
 
109
111
  **Not a terminal emulator.** Semicolon-delimited SGR, colon-delimited extended colour and
110
112
  OSC 8 hyperlinks are understood. Every other complete CSI or OSC command is carried through
111
113
  as an opaque zero-width unit, and anything that only looks like an introducer stays plain
112
114
  text.
113
115
 
114
- **Still at the Design→Build gate:** an exported `strip`, and the ASCII fast path — a byte
115
- scan when the string has no non-ASCII code unit, so the segmenter is reached only when it
116
- earns its cost.
116
+ **`strip` is exported**, from the root and as the `linegauge/strip` subpath whose default
117
+ export is the strip-ansi drop-in. `width` measures what it leaves.
118
+
119
+ **An ASCII fast path.** A string of printable ASCII is measured by a scan of its code units,
120
+ so the segmenter is reached only when it earns its cost.
117
121
 
118
122
  ## Plugins
119
123
 
@@ -147,9 +151,9 @@ The two things that genuinely vary are already handled without a registry:
147
151
  to pass; nothing here reads `process`. That is a parameter, not a plugin.
148
152
 
149
153
  The family's plugin contract records this refusal next to the other layers' keys (R5a), so
150
- "no key" is one of the contract's answers rather than a hole in it. If a real second answer
151
- ever arrives — an ambiguous-width policy some terminal actually needs — it lands as an option
152
- with a differential test behind it, because the graders have to see it.
154
+ "no key" is one of the contract's answers rather than a hole in it. The one real second
155
+ answer so far — the ambiguous-width policy a CJK terminal needs — landed that way: as
156
+ `ambiguousIsNarrow`, an option with tests behind it, not a registration.
153
157
 
154
158
  ## Benchmarks
155
159
 
@@ -169,7 +173,7 @@ its own suite — which this package passes. The runner reports that as a failur
169
173
  to the incumbent an unexpected pass means a stale annotation; it is counted here as the
170
174
  pass it is, and marked rather than left to look like the ones beside it.
171
175
 
172
- Weight, installed and tree-inclusive: **85,762 bytes** against **194,329** for the incumbents it replaces — a ratio of **0.4413**.
176
+ Weight, installed and tree-inclusive: **86,081 bytes** against **194,329** for the incumbents it replaces — a ratio of **0.4430**.
173
177
  ## Where it sits
174
178
 
175
179
  Plugins register under the `widths` key, against the one schema the whole family shares.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linegauge",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "A printer's line gauge \u2014 the steel rule marked in picas and points. Measuring, wrapping, truncating and slicing styled terminal text without the edge fraying \u2014 grapheme-correct over Intl.Segmenter. Drop-in paths for string-width, wrap-ansi, strip-ansi and slice-ansi. Zero dependencies.",
5
5
  "license": "MIT",
6
6
  "type": "module",