linegauge 0.3.2 → 0.3.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/dist/width.js +10 -6
  2. package/package.json +2 -2
package/dist/width.js CHANGED
@@ -89,15 +89,19 @@ function isWide(codePoint) {
89
89
  function isAmbiguous(codePoint) {
90
90
  return inTable(AMBIGUOUS, codePoint);
91
91
  }
92
- const classes = {};
92
+ let zeroWidthClass;
93
+ let leadingClass;
94
+ let rgiClass;
95
+ let spacingClass;
96
+ let pictographicClass;
93
97
  const INVISIBLE_CLASSES = ['\\p{Default_Ignorable_Code_Point}', '\\p{Control}', '\\p{Format}', '\\p{Nonspacing_Mark}', '\\p{Enclosing_Mark}', '\\p{Surrogate}'];
94
98
  const INVISIBLE_ALTERNATION = INVISIBLE_CLASSES.join('|');
95
99
  const INVISIBLE_SET = INVISIBLE_CLASSES.join('');
96
- const ZERO_WIDTH_CLUSTER = () => (classes['zeroWidth'] ??= new RegExp(`^(?:${INVISIBLE_ALTERNATION})+$`, 'v'));
97
- const LEADING_NON_PRINTING = () => (classes['leading'] ??= new RegExp(`^[${INVISIBLE_SET}]+`, 'v'));
98
- const RGI_EMOJI = () => (classes['rgi'] ??= new RegExp('^\\p{RGI_Emoji}$', 'v'));
99
- const SPACING_MARK = () => (classes['spacing'] ??= new RegExp('^\\p{Spacing_Mark}$', 'v'));
100
- const EXTENDED_PICTOGRAPHIC = () => (classes['pictographic'] ??= new RegExp('^\\p{Extended_Pictographic}$', 'u'));
100
+ const ZERO_WIDTH_CLUSTER = () => (zeroWidthClass ??= new RegExp(`^(?:${INVISIBLE_ALTERNATION})+$`, 'v'));
101
+ const LEADING_NON_PRINTING = () => (leadingClass ??= new RegExp(`^[${INVISIBLE_SET}]+`, 'v'));
102
+ const RGI_EMOJI = () => (rgiClass ??= new RegExp('^\\p{RGI_Emoji}$', 'v'));
103
+ const SPACING_MARK = () => (spacingClass ??= new RegExp('^\\p{Spacing_Mark}$', 'v'));
104
+ const EXTENDED_PICTOGRAPHIC = () => (pictographicClass ??= new RegExp('^\\p{Extended_Pictographic}$', 'u'));
101
105
  const UNQUALIFIED_KEYCAP = /^[\d#*]\u20E3$/u;
102
106
  const ZWJ = '\u200D';
103
107
  const EMOJI_ZWJ_PICTOGRAPHS = 2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linegauge",
3
- "version": "0.3.2",
3
+ "version": "0.3.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",
@@ -75,6 +75,6 @@
75
75
  "unicode"
76
76
  ],
77
77
  "devDependencies": {
78
- "vitest": "^5.0.0"
78
+ "vitest": "^5.0.1"
79
79
  }
80
80
  }