@visulima/string 3.0.0-alpha.7 → 3.0.0-alpha.9

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 (42) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENSE.md +54 -0
  3. package/README.md +8 -2
  4. package/dist/align-text.js +7 -5
  5. package/dist/case/camel-case.js +7 -7
  6. package/dist/case/capital-case.js +3 -3
  7. package/dist/case/flip-case.js +1 -1
  8. package/dist/case/identify-case.js +2 -1
  9. package/dist/case/index.d.ts +1 -1
  10. package/dist/case/index.js +1 -1
  11. package/dist/case/kebab-case.js +3 -3
  12. package/dist/case/pascal-case.js +3 -3
  13. package/dist/case/sentence-case.js +7 -7
  14. package/dist/case/split-by-case.js +46 -30
  15. package/dist/case/title-case.js +3 -5
  16. package/dist/case/train-case.js +1 -1
  17. package/dist/closest-string.js +4 -5
  18. package/dist/compare-similarity.js +2 -2
  19. package/dist/get-string-truncated-width.js +2 -114
  20. package/dist/index.d.ts +7 -2
  21. package/dist/index.js +10 -5
  22. package/dist/outdent.js +6 -14
  23. package/dist/packem_shared/{closestN-Cvsw0Fue.js → closestN-DUsjgiXb.js} +4 -3
  24. package/dist/packem_shared/{constants-D5qaproB.js → constants-BsZS5f0z.js} +1 -1
  25. package/dist/packem_shared/direction-C9gfWWTK.js +16 -0
  26. package/dist/packem_shared/eastAsianWidthType-SD3YniiT.js +20 -0
  27. package/dist/packem_shared/indent-D3DSCa6s.js +33 -0
  28. package/dist/packem_shared/isFullwidthCodePoint-IFXZxNjq.js +10 -0
  29. package/dist/packem_shared/{joinSegments-BStLas0c.js → joinSegments-CvxSgKz0.js} +1 -1
  30. package/dist/packem_shared/lookup-BE8lEqy4.js +104 -0
  31. package/dist/packem_shared/{normalize-german-eszett-DEB8-ZPT.js → normalize-german-eszett-4p3yKEzn.js} +2 -1
  32. package/dist/packem_shared/redent-DSb1IJWn.js +8 -0
  33. package/dist/packem_shared/{replaceString-BVlxk27d.js → replaceString-Ce8X2ZQ-.js} +11 -9
  34. package/dist/packem_shared/stripIndent-D_TRjxZ_.js +20 -0
  35. package/dist/packem_shared/{transliterate-DGlx-woj.js → transliterate-CKt9VK7D.js} +10 -10
  36. package/dist/slice.js +9 -7
  37. package/dist/slugify.js +1 -1
  38. package/dist/truncate.js +28 -30
  39. package/dist/utilities.js +6 -8
  40. package/dist/word-wrap.js +20 -18
  41. package/package.json +1 -4
  42. package/dist/packem_shared/direction-BVhR8MOQ.js +0 -10
package/CHANGELOG.md CHANGED
@@ -1,3 +1,42 @@
1
+ ## @visulima/string [3.0.0-alpha.9](https://github.com/visulima/visulima/compare/@visulima/string@3.0.0-alpha.8...@visulima/string@3.0.0-alpha.9) (2026-04-08)
2
+
3
+ ### Features
4
+
5
+ * **string): native indent implementation; refactor(tui:** replace indent-string and is-fullwidth-code-point ([1368488](https://github.com/visulima/visulima/commit/136848850242ddeae91320dd21d6fdeb0760768c))
6
+ * **string:** add east-asian-width, isFullwidthCodePoint exports and fix utilities ([b44e0c5](https://github.com/visulima/visulima/commit/b44e0c5b4e5cff7b39d9148516f7ed510bb35bb6))
7
+ * **string:** add indent, strip-indent, dedent, redent, isFullwidthCodePoint, and east-asian-width helpers ([5441f3c](https://github.com/visulima/visulima/commit/5441f3c883256165b36c0d9580bbb44cc36e9a62))
8
+
9
+ ### Bug Fixes
10
+
11
+ * resolve failing tests across multiple packages ([2b4b6f0](https://github.com/visulima/visulima/commit/2b4b6f04169b60fdc4cf77b293015436a272c0fb))
12
+ * **string:** properly fix eslint errors in code ([184b6a3](https://github.com/visulima/visulima/commit/184b6a30bb3d49185f64a0a6d88f693bd61644f9))
13
+ * **string:** remove remaining eslint suppressions with proper code fixes ([c2e183e](https://github.com/visulima/visulima/commit/c2e183ed1cdb8fe54d46c5376eca0208a9b65b0f))
14
+ * **string:** resolve eslint errors ([18f4366](https://github.com/visulima/visulima/commit/18f43665e335b66f2960b4ebffc510efe9df9b6e))
15
+
16
+ ### Miscellaneous Chores
17
+
18
+ * **data-manipulation:** remove empty dependency objects from package.json ([c0e8f76](https://github.com/visulima/visulima/commit/c0e8f7689a2da413f771494f6ecb07babc4b5e06))
19
+ * **string:** add tsconfig.eslint.json for type-aware linting ([b29661d](https://github.com/visulima/visulima/commit/b29661dc2cf32823f4aff40ac3c7b6a3e12b678e))
20
+ * **string:** apply prettier formatting ([ed0e3a1](https://github.com/visulima/visulima/commit/ed0e3a15ff5d387ae4897eb0d4ed8a0a864951c2))
21
+ * **string:** migrate .prettierrc.cjs to prettier.config.js ([750ddba](https://github.com/visulima/visulima/commit/750ddba531071ff5b4d74a5e13799630c8d55c27))
22
+ * update bundled dependency licenses ([6ace4c6](https://github.com/visulima/visulima/commit/6ace4c69d41fc1fd0a744fbca8ca219ba631b4ab))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * **@visulima/colorize:** upgraded to 2.0.0-alpha.8
28
+
29
+ ## @visulima/string [3.0.0-alpha.8](https://github.com/visulima/visulima/compare/@visulima/string@3.0.0-alpha.7...@visulima/string@3.0.0-alpha.8) (2026-03-26)
30
+
31
+ ### Features
32
+
33
+ * **web:** auto-generate packages page from workspace metadata ([623e520](https://github.com/visulima/visulima/commit/623e5207693a7fe720f5f2f179593a3654c880e3))
34
+
35
+
36
+ ### Dependencies
37
+
38
+ * **@visulima/colorize:** upgraded to 2.0.0-alpha.7
39
+
1
40
  ## @visulima/string [3.0.0-alpha.7](https://github.com/visulima/visulima/compare/@visulima/string@3.0.0-alpha.6...@visulima/string@3.0.0-alpha.7) (2026-03-26)
2
41
 
3
42
  ### Bug Fixes
package/LICENSE.md CHANGED
@@ -159,6 +159,23 @@ Repository: https://github.com/mdevils/html-entities.git
159
159
 
160
160
  ---------------------------------------
161
161
 
162
+ ## indent-string
163
+ License: MIT
164
+ By: Sindre Sorhus
165
+ Repository: sindresorhus/indent-string
166
+
167
+ > MIT License
168
+ >
169
+ > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
170
+ >
171
+ > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
172
+ >
173
+ > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
174
+ >
175
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
176
+
177
+ ---------------------------------------
178
+
162
179
  ## lodash-es
163
180
  License: MIT
164
181
  By: John-David Dalton, Mathias Bynens
@@ -334,6 +351,23 @@ Repository: git+https://github.com/codsen/codsen.git
334
351
 
335
352
  ---------------------------------------
336
353
 
354
+ ## redent
355
+ License: MIT
356
+ By: Sindre Sorhus
357
+ Repository: sindresorhus/redent
358
+
359
+ > MIT License
360
+ >
361
+ > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
362
+ >
363
+ > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
364
+ >
365
+ > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
366
+ >
367
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
368
+
369
+ ---------------------------------------
370
+
337
371
  ## rfdc
338
372
  License: MIT
339
373
  By: David Mark Clements
@@ -447,6 +481,23 @@ Repository: git+https://github.com/codsen/codsen.git
447
481
 
448
482
  ---------------------------------------
449
483
 
484
+ ## strip-indent
485
+ License: MIT
486
+ By: Sindre Sorhus
487
+ Repository: sindresorhus/strip-indent
488
+
489
+ > MIT License
490
+ >
491
+ > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
492
+ >
493
+ > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
494
+ >
495
+ > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
496
+ >
497
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
498
+
499
+ ---------------------------------------
500
+
450
501
  ## tiny-invariant
451
502
  License: MIT
452
503
  By: Alex Reardon
@@ -479,11 +530,14 @@ Repository: https://github.com/alexreardon/tiny-invariant.git
479
530
  <!-- TYPE_DEPENDENCIES -->
480
531
 
481
532
  # Licenses of bundled types
533
+
482
534
  The published @visulima/string artifact additionally contains code with the following licenses:
483
535
  MIT
484
536
 
485
537
  # Bundled types:
538
+
486
539
  ## fastest-levenshtein
540
+
487
541
  License: MIT
488
542
  By: Kasper U. Weihe
489
543
  Repository: git+https://github.com/ka-weihe/fastest-levenshtein.git
package/README.md CHANGED
@@ -55,8 +55,11 @@
55
55
  - Split by separators (foo-bar → ["foo", "bar"])
56
56
  - Preserve known acronyms (XMLHttpRequest → ["XML", "Http", "Request"])
57
57
  - **Text Indentation**:
58
- - `outdent`: Remove leading indentation while preserving relative indentation
59
- - Handles template literals and string inputs
58
+ - `indent`: Add indentation to each line in a string
59
+ - `stripIndent`: Strip common leading whitespace from all lines
60
+ - `dedent`: Strip indent and trim leading/trailing blank lines
61
+ - `redent`: Strip redundant indentation and re-indent
62
+ - `outdent`: Remove indentation from template literals
60
63
  - Normalizes newlines across platforms
61
64
  - Configurable trimming behavior
62
65
  - **String Analysis**:
@@ -66,6 +69,9 @@
66
69
  - **String Width Calculation**:
67
70
  - `getStringWidth`: Calculate visual width of strings with Unicode support
68
71
  - `getStringTruncatedWidth`: Width calculation with smart truncation
72
+ - `isFullwidthCodePoint`: Check if a code point is fullwidth
73
+ - `eastAsianWidth`: Get character width (1 or 2) for a code point
74
+ - `eastAsianWidthType`: Get East Asian Width category for a code point
69
75
  - Handles CJK characters, emojis, ANSI codes, and more
70
76
  - Configurable character width settings
71
77
  - Support for zero-width and combining characters
@@ -11,14 +11,16 @@ const alignText = (text, options = {}) => {
11
11
  const pad = options.pad ?? " ";
12
12
  const widthDiffFunction = align === "right" ? fullDiff : halfDiff;
13
13
  let returnString = false;
14
- if (!Array.isArray(text)) {
14
+ let lines;
15
+ if (Array.isArray(text)) {
16
+ lines = text;
17
+ } else {
15
18
  returnString = true;
16
- text = String(text).split(split);
19
+ lines = text.split(split);
17
20
  }
18
21
  let width;
19
22
  let maxWidth = 0;
20
- text = text.map((input) => {
21
- input = String(input);
23
+ const result = lines.map((input) => {
22
24
  width = getStringWidth(input, options.stringWidthOptions);
23
25
  maxWidth = Math.max(width, maxWidth);
24
26
  return {
@@ -26,7 +28,7 @@ const alignText = (text, options = {}) => {
26
28
  width
27
29
  };
28
30
  }).map((object) => Array.from({ length: widthDiffFunction(maxWidth, object.width) + 1 }).join(pad) + object.str);
29
- return returnString ? text.join(split) : text;
31
+ return returnString ? result.join(split) : result;
30
32
  };
31
33
 
32
34
  export { alignText };
@@ -1,11 +1,11 @@
1
- import { R as RE_FAST_ANSI } from '../packem_shared/constants-D5qaproB.js';
1
+ import { R as RE_FAST_ANSI } from '../packem_shared/constants-BsZS5f0z.js';
2
2
  import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
3
3
  import lowerFirst from './lower-first.js';
4
4
  import { splitByCase } from './split-by-case.js';
5
5
  import upperFirst from './upper-first.js';
6
6
  import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
7
- import joinSegments from '../packem_shared/joinSegments-BStLas0c.js';
8
- import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-DEB8-ZPT.js';
7
+ import joinSegments from '../packem_shared/joinSegments-CvxSgKz0.js';
8
+ import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-4p3yKEzn.js';
9
9
 
10
10
  const defaultCacheStore = new LRUCache(1e3);
11
11
  const camelCase = (value, options) => {
@@ -36,13 +36,13 @@ const camelCase = (value, options) => {
36
36
  if (options?.handleAnsi && RE_FAST_ANSI.test(word)) {
37
37
  return word;
38
38
  }
39
- word = options?.locale?.startsWith("de") ? normalizeGermanEszett(word) : word;
40
- word = options?.locale ? word.toLocaleLowerCase(options.locale) : word.toLowerCase();
39
+ const normalized = options?.locale?.startsWith("de") ? normalizeGermanEszett(word) : word;
40
+ const lowered = options?.locale ? normalized.toLocaleLowerCase(options.locale) : normalized.toLowerCase();
41
41
  if (firstWord) {
42
42
  firstWord = false;
43
- return lowerFirst(word, options);
43
+ return lowerFirst(lowered, options);
44
44
  }
45
- return upperFirst(word, options);
45
+ return upperFirst(lowered, options);
46
46
  }),
47
47
  ""
48
48
  );
@@ -1,10 +1,10 @@
1
- import { R as RE_FAST_ANSI } from '../packem_shared/constants-D5qaproB.js';
1
+ import { R as RE_FAST_ANSI } from '../packem_shared/constants-BsZS5f0z.js';
2
2
  import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
3
3
  import { splitByCase } from './split-by-case.js';
4
4
  import upperFirst from './upper-first.js';
5
5
  import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
6
- import joinSegments from '../packem_shared/joinSegments-BStLas0c.js';
7
- import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-DEB8-ZPT.js';
6
+ import joinSegments from '../packem_shared/joinSegments-CvxSgKz0.js';
7
+ import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-4p3yKEzn.js';
8
8
 
9
9
  const defaultCacheStore = new LRUCache(1e3);
10
10
  const capitalCase = (value, options) => {
@@ -20,7 +20,7 @@ const __cjs_getBuiltinModule = (module) => {
20
20
  const {
21
21
  stripVTControlCharacters
22
22
  } = __cjs_getBuiltinModule("node:util");
23
- import { s as stripEmoji } from '../packem_shared/constants-D5qaproB.js';
23
+ import { s as stripEmoji } from '../packem_shared/constants-BsZS5f0z.js';
24
24
  import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
25
25
  import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
26
26
 
@@ -8,6 +8,7 @@ const IS_UPPERCASE = /^[A-Z][A-Z0-9]*$/;
8
8
  const WHITESPACE_REGEX = /\s+/;
9
9
  const IS_NUMERIC = /^\d+$/;
10
10
  const IS_CAMEL_CASE_LIKE = /^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)+$/;
11
+ const IS_LOWERCASE_START = /^[a-z]/;
11
12
  const CONTAINS_PUNCTUATION_MID_WORD = /[.!?;:,](?!\s|$)/;
12
13
  const identifyCase = (value) => {
13
14
  if (typeof value !== "string") {
@@ -47,7 +48,7 @@ const identifyCase = (value) => {
47
48
  if (words.length > 1 && IS_NUMERIC.test(words[0]) && IS_PASCAL_CASE.test(words[1])) {
48
49
  return "title";
49
50
  }
50
- if (words.length > 1 && IS_PASCAL_CASE.test(words[0]) && /^[a-z]/.test(words[1])) {
51
+ if (words.length > 1 && IS_PASCAL_CASE.test(words[0]) && IS_LOWERCASE_START.test(words[1])) {
51
52
  return "sentence";
52
53
  }
53
54
  if (IS_PASCAL_CASE.test(value)) {
@@ -20,5 +20,5 @@ export { default as trainCase } from "./train-case.js";
20
20
  export { type a as CamelCase, type b as CapitalCase, type C as CaseOptions, type c as ConstantCase, type D as DotCase, type F as FlatCase, type d as FlipCase, type I as IdentifyCase, type K as KebabCase, type L as LocaleOptions, type e as LowerFirst, type N as NoCase, type P as PascalCase, type f as PascalSnakeCase, type g as PathCase, type S as SentenceCase, type h as SnakeCase, type i as SplitByCase, type T as TitleCase, type j as TrainCase, type U as UpperFirst } from "../packem_shared/types.d-DfgbcNKh.js";
21
21
  export { default as upperFirst } from "./upper-first.js";
22
22
  import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
23
- declare const joinSegments: <T extends string = string>(segments: string[], joiner: string) => T;
23
+ declare const joinSegments: (segments: string[], joiner: string) => string;
24
24
  export { joinSegments };
@@ -17,4 +17,4 @@ export { splitByCase } from './split-by-case.js';
17
17
  export { default as titleCase } from './title-case.js';
18
18
  export { default as trainCase } from './train-case.js';
19
19
  export { default as upperFirst } from './upper-first.js';
20
- export { default as joinSegments } from '../packem_shared/joinSegments-BStLas0c.js';
20
+ export { default as joinSegments } from '../packem_shared/joinSegments-CvxSgKz0.js';
@@ -1,9 +1,9 @@
1
- import { R as RE_FAST_ANSI } from '../packem_shared/constants-D5qaproB.js';
1
+ import { R as RE_FAST_ANSI } from '../packem_shared/constants-BsZS5f0z.js';
2
2
  import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
3
3
  import { splitByCase } from './split-by-case.js';
4
4
  import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
5
- import joinSegments from '../packem_shared/joinSegments-BStLas0c.js';
6
- import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-DEB8-ZPT.js';
5
+ import joinSegments from '../packem_shared/joinSegments-CvxSgKz0.js';
6
+ import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-4p3yKEzn.js';
7
7
 
8
8
  const defaultCacheStore = new LRUCache(1e3);
9
9
  const kebabCase = (value, options) => {
@@ -1,10 +1,10 @@
1
- import { R as RE_FAST_ANSI } from '../packem_shared/constants-D5qaproB.js';
1
+ import { R as RE_FAST_ANSI } from '../packem_shared/constants-BsZS5f0z.js';
2
2
  import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
3
3
  import { splitByCase } from './split-by-case.js';
4
4
  import upperFirst from './upper-first.js';
5
5
  import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
6
- import joinSegments from '../packem_shared/joinSegments-BStLas0c.js';
7
- import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-DEB8-ZPT.js';
6
+ import joinSegments from '../packem_shared/joinSegments-CvxSgKz0.js';
7
+ import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-4p3yKEzn.js';
8
8
 
9
9
  const defaultCacheStore = new LRUCache(1e3);
10
10
  const pascalCase = (value, options) => {
@@ -1,10 +1,10 @@
1
- import { R as RE_FAST_ANSI } from '../packem_shared/constants-D5qaproB.js';
1
+ import { R as RE_FAST_ANSI } from '../packem_shared/constants-BsZS5f0z.js';
2
2
  import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
3
3
  import { splitByCase } from './split-by-case.js';
4
4
  import upperFirst from './upper-first.js';
5
5
  import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
6
- import joinSegments from '../packem_shared/joinSegments-BStLas0c.js';
7
- import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-DEB8-ZPT.js';
6
+ import joinSegments from '../packem_shared/joinSegments-CvxSgKz0.js';
7
+ import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-4p3yKEzn.js';
8
8
 
9
9
  const defaultCacheStore = new LRUCache(1e3);
10
10
  const sentenceCase = (value, options) => {
@@ -35,13 +35,13 @@ const sentenceCase = (value, options) => {
35
35
  if (options?.handleAnsi && RE_FAST_ANSI.test(word)) {
36
36
  return word;
37
37
  }
38
- word = options?.locale?.startsWith("de") ? normalizeGermanEszett(word) : word;
39
- word = options?.locale ? word.toLocaleLowerCase(options.locale) : word.toLowerCase();
38
+ const normalized = options?.locale?.startsWith("de") ? normalizeGermanEszett(word) : word;
39
+ const lowered = options?.locale ? normalized.toLocaleLowerCase(options.locale) : normalized.toLowerCase();
40
40
  if (firstWord) {
41
41
  firstWord = false;
42
- return upperFirst(word, options);
42
+ return upperFirst(lowered, options);
43
43
  }
44
- return word;
44
+ return lowered;
45
45
  }),
46
46
  " "
47
47
  );
@@ -20,16 +20,17 @@ const __cjs_getBuiltinModule = (module) => {
20
20
  const {
21
21
  stripVTControlCharacters
22
22
  } = __cjs_getBuiltinModule("node:util");
23
- import { j as RE_EMOJI, s as stripEmoji, R as RE_FAST_ANSI, k as RE_CYRILLIC, l as RE_LATIN, m as RE_GREEK, n as RE_GREEK_LATIN_SPLIT, o as RE_UZBEK_LATIN_MODIFIER, p as RE_KATAKANA, q as RE_KANJI, r as RE_HIRAGANA, t as RE_HANGUL, u as RE_HEBREW, v as RE_ARABIC, w as RE_SEPARATORS, x as RE_DEVANAGARI, y as RE_BENGALI, z as RE_GUJARATI, A as RE_GURMUKHI, B as RE_KANNADA, C as RE_TAMIL, D as RE_TELUGU, E as RE_MALAYALAM, F as RE_SINHALA, G as RE_THAI, H as RE_LAO, I as RE_TIBETAN, J as RE_MYANMAR, K as RE_ETHIOPIC, L as RE_KHMER, M as RE_ORIYA } from '../packem_shared/constants-D5qaproB.js';
23
+ import { i as RE_EMOJI, s as stripEmoji, R as RE_FAST_ANSI, l as RE_CYRILLIC, m as RE_LATIN, n as RE_GREEK, o as RE_GREEK_LATIN_SPLIT, p as RE_UZBEK_LATIN_MODIFIER, q as RE_KATAKANA, r as RE_KANJI, t as RE_HIRAGANA, u as RE_HANGUL, v as RE_HEBREW, w as RE_ARABIC, x as RE_SEPARATORS, y as RE_DEVANAGARI, z as RE_BENGALI, A as RE_GUJARATI, B as RE_GURMUKHI, C as RE_KANNADA, D as RE_TAMIL, E as RE_TELUGU, F as RE_MALAYALAM, G as RE_SINHALA, H as RE_THAI, I as RE_LAO, J as RE_TIBETAN, K as RE_MYANMAR, L as RE_ETHIOPIC, M as RE_KHMER, N as RE_ORIYA } from '../packem_shared/constants-BsZS5f0z.js';
24
24
  import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
25
25
 
26
26
  const regexCache = new LRUCache(1e3);
27
+ const RE_ESCAPE_SPECIAL = /[.*+?^${}()|[\]\\]/g;
27
28
  const getSeparatorsRegex = (separators) => {
28
29
  const key = separators.join("");
29
30
  if (regexCache.has(key)) {
30
31
  return regexCache.get(key);
31
32
  }
32
- const pattern = separators.map((s) => s.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)).join("|");
33
+ const pattern = separators.map((s) => s.replaceAll(RE_ESCAPE_SPECIAL, String.raw`\$&`)).join("|");
33
34
  const regex = new RegExp(pattern, "g");
34
35
  regexCache.set(key, regex);
35
36
  return regex;
@@ -53,6 +54,7 @@ const splitByEmoji = (text) => {
53
54
  return segments.filter(Boolean);
54
55
  };
55
56
 
57
+ const RE_SLOVENIAN_SPECIAL = /[ČŠŽĐ]/i;
56
58
  const isUpperCode = new Uint8Array(128);
57
59
  const isLowerCode = new Uint8Array(128);
58
60
  const isDigitCode = new Uint8Array(128);
@@ -69,8 +71,9 @@ const handleScriptTransitions = (s, scriptDetectors, caseSensitive, locale, cust
69
71
  return [];
70
72
  }
71
73
  let hasDetectedScript = false;
72
- for (const detector of Object.values(scriptDetectors)) {
73
- if (detector(s[0])) {
74
+ const detectorValues = Object.values(scriptDetectors);
75
+ for (const detectorValue of detectorValues) {
76
+ if (detectorValue(s[0])) {
74
77
  hasDetectedScript = true;
75
78
  break;
76
79
  }
@@ -82,7 +85,9 @@ const handleScriptTransitions = (s, scriptDetectors, caseSensitive, locale, cust
82
85
  const result = [];
83
86
  let currentSegment = chars[0];
84
87
  let previousType = "other";
85
- for (const [type, detector] of Object.entries(scriptDetectors)) {
88
+ const scriptEntries = Object.entries(scriptDetectors);
89
+ for (const scriptEntry of scriptEntries) {
90
+ const [type, detector] = scriptEntry;
86
91
  if (detector(chars[0])) {
87
92
  previousType = type;
88
93
  break;
@@ -92,7 +97,8 @@ const handleScriptTransitions = (s, scriptDetectors, caseSensitive, locale, cust
92
97
  for (let index = 1; index < chars.length; index++) {
93
98
  const char = chars[index];
94
99
  let currentType = "other";
95
- for (const [type, detector] of Object.entries(scriptDetectors)) {
100
+ for (const scriptEntry of scriptEntries) {
101
+ const [type, detector] = scriptEntry;
96
102
  if (detector(char)) {
97
103
  currentType = type;
98
104
  break;
@@ -308,28 +314,36 @@ const splitCamelCaseLocale = (s, locale, knownAcronyms) => {
308
314
  if (!RE_GREEK.test(s) && !RE_LATIN.test(s)) {
309
315
  return [s];
310
316
  }
311
- const parts = s.match(RE_GREEK_LATIN_SPLIT) ?? [s];
317
+ const parts = [];
318
+ RE_GREEK_LATIN_SPLIT.lastIndex = 0;
319
+ let greekExecMatch;
320
+ while ((greekExecMatch = RE_GREEK_LATIN_SPLIT.exec(s)) !== null) {
321
+ parts.push(greekExecMatch[0]);
322
+ }
323
+ if (parts.length === 0) {
324
+ parts.push(s);
325
+ }
312
326
  const result2 = [];
313
327
  const width = parts.length;
314
328
  if (width === 1) {
315
329
  const part = parts[0];
316
330
  if (!part || !RE_GREEK.test(part[0]) || part.length === 1) {
317
- return [part || s];
331
+ return [part ?? s];
318
332
  }
319
333
  }
320
- for (const part of parts) {
321
- if (!part) {
334
+ for (const greekPart of parts) {
335
+ if (!greekPart) {
322
336
  continue;
323
337
  }
324
- if (!RE_GREEK.test(part[0]) || part.length === 1) {
325
- result2.push(part);
338
+ if (!RE_GREEK.test(greekPart[0]) || greekPart.length === 1) {
339
+ result2.push(greekPart);
326
340
  continue;
327
341
  }
328
- const partLength = part.length;
329
- let word = part[0];
330
- let previousIsUpper2 = part[0] === part[0].toLocaleUpperCase(locale);
342
+ const partLength = greekPart.length;
343
+ let word = greekPart[0];
344
+ let previousIsUpper2 = greekPart[0] === greekPart[0].toLocaleUpperCase(locale);
331
345
  for (let index = 1; index < partLength; index++) {
332
- const char = part[index];
346
+ const char = greekPart[index];
333
347
  const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
334
348
  if (!previousIsUpper2 && isUpperCaseChar) {
335
349
  result2.push(word);
@@ -367,9 +381,10 @@ const splitCamelCaseLocale = (s, locale, knownAcronyms) => {
367
381
  // latin -> japanese
368
382
  );
369
383
  const result2 = [];
370
- for (const segment of baseSegments) {
384
+ for (const baseSegment of baseSegments) {
385
+ const segment = baseSegment;
371
386
  if (segment.length === 1 && particles.has(segment) && result2.length > 0) {
372
- result2[result2.length - 1] += segment;
387
+ result2[result2.length - 1] = result2.at(-1) + segment;
373
388
  } else {
374
389
  result2.push(segment);
375
390
  }
@@ -394,7 +409,7 @@ const splitCamelCaseLocale = (s, locale, knownAcronyms) => {
394
409
  for (let index = 1; index < width_2; index++) {
395
410
  const char = chars2[index];
396
411
  const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
397
- const isSpecialChar = /[ČŠŽĐ]/i.test(char);
412
+ const isSpecialChar = RE_SLOVENIAN_SPECIAL.test(char);
398
413
  const nextIsUpper = index < width_2 - 1 && chars2[index + 1] === chars2[index + 1].toLocaleUpperCase(locale);
399
414
  if (!previousIsUpper2 && isUpperCaseChar || isSpecialChar && nextIsUpper) {
400
415
  result2.push(currentSegment2);
@@ -566,7 +581,7 @@ const splitCamelCaseLocale = (s, locale, knownAcronyms) => {
566
581
  result.push(currentSegment, acronym);
567
582
  acronymLength = acronym.length;
568
583
  currentSegment = "";
569
- const lastAcronymChar = acronym[acronym.length - 1];
584
+ const lastAcronymChar = acronym.at(-1);
570
585
  if (lastAcronymChar) {
571
586
  previousIsUpper = lastAcronymChar === lastAcronymChar.toLocaleUpperCase(locale);
572
587
  }
@@ -593,20 +608,21 @@ const splitCamelCaseLocale = (s, locale, knownAcronyms) => {
593
608
  const processTextWithAnsiEmoji = (text, locale, knownAcronyms) => {
594
609
  const result = [];
595
610
  const segments = RE_FAST_ANSI.test(text) ? text.split(RE_FAST_ANSI).filter(Boolean) : [text];
596
- for (const seg of segments) {
611
+ for (const segment of segments) {
612
+ const seg = segment;
597
613
  if (RE_FAST_ANSI.test(seg)) {
598
614
  result.push(seg);
599
615
  } else {
600
616
  const subs = RE_EMOJI.test(seg) ? splitByEmoji(seg).filter(Boolean) : [seg];
601
- for (const sub of subs) {
602
- if (RE_EMOJI.test(sub)) {
603
- result.push(sub);
617
+ for (const emojiSub of subs) {
618
+ if (RE_EMOJI.test(emojiSub)) {
619
+ result.push(emojiSub);
604
620
  } else {
605
621
  if (locale) {
606
622
  const normalizedLocale = locale.toLowerCase().split("-")[0];
607
- result.push(...splitCamelCaseLocale(sub, normalizedLocale, knownAcronyms));
623
+ result.push(...splitCamelCaseLocale(emojiSub, normalizedLocale, knownAcronyms));
608
624
  } else {
609
- result.push(...splitCamelCaseFast(sub, knownAcronyms));
625
+ result.push(...splitCamelCaseFast(emojiSub, knownAcronyms));
610
626
  }
611
627
  }
612
628
  }
@@ -718,13 +734,13 @@ const splitByCase = (input, options = {}) => {
718
734
  parts.push(...standardParts);
719
735
  }
720
736
  let tokens = [];
721
- for (const part of parts) {
737
+ for (const splitPart of parts) {
722
738
  if (handleAnsi || handleEmoji) {
723
- tokens.push(...processTextWithAnsiEmoji(part, locale, acronymSet));
739
+ tokens.push(...processTextWithAnsiEmoji(splitPart, locale, acronymSet));
724
740
  } else if (locale) {
725
- tokens.push(...splitCamelCaseLocale(part, locale, acronymSet));
741
+ tokens.push(...splitCamelCaseLocale(splitPart, locale, acronymSet));
726
742
  } else {
727
- tokens.push(...splitCamelCaseFast(part, acronymSet));
743
+ tokens.push(...splitCamelCaseFast(splitPart, acronymSet));
728
744
  }
729
745
  }
730
746
  if (normalize) {
@@ -2,7 +2,7 @@ import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
2
2
  import { splitByCase } from './split-by-case.js';
3
3
  import upperFirst from './upper-first.js';
4
4
  import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
5
- import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-DEB8-ZPT.js';
5
+ import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-4p3yKEzn.js';
6
6
 
7
7
  const defaultCacheStore = new LRUCache(1e3);
8
8
  function titleCase(value, options) {
@@ -28,10 +28,8 @@ function titleCase(value, options) {
28
28
  stripAnsi: options?.stripAnsi,
29
29
  stripEmoji: options?.stripEmoji
30
30
  }).map((word) => {
31
- if (options?.locale?.startsWith("de")) {
32
- word = normalizeGermanEszett(word);
33
- }
34
- return upperFirst(options?.locale ? word.toLocaleLowerCase(options.locale) : word.toLowerCase(), { locale: options?.locale });
31
+ const normalized = options?.locale?.startsWith("de") ? normalizeGermanEszett(word) : word;
32
+ return upperFirst(options?.locale ? normalized.toLocaleLowerCase(options.locale) : normalized.toLowerCase(), { locale: options?.locale });
35
33
  }).join(" ");
36
34
  if (shouldCache && cacheKey) {
37
35
  cacheStore.set(cacheKey, result);
@@ -2,7 +2,7 @@ import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
2
2
  import { splitByCase } from './split-by-case.js';
3
3
  import upperFirst from './upper-first.js';
4
4
  import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
5
- import joinSegments from '../packem_shared/joinSegments-BStLas0c.js';
5
+ import joinSegments from '../packem_shared/joinSegments-CvxSgKz0.js';
6
6
 
7
7
  const defaultCacheStore = new LRUCache(1e3);
8
8
  const trainCase = (value, options) => {
@@ -5,13 +5,12 @@ const closestString = (givenWord, possibleWords, options) => {
5
5
  throw new TypeError("When using closestString(), the possibleWords array must contain at least one word");
6
6
  }
7
7
  const { caseSensitive, compareFn: compareFunction = distance } = { ...options };
8
- if (!caseSensitive) {
9
- givenWord = givenWord.toLowerCase();
10
- }
8
+ const normalizedGivenWord = caseSensitive ? givenWord : givenWord.toLowerCase();
11
9
  let nearestWord = possibleWords[0] ?? void 0;
12
10
  let closestStringDistance = Infinity;
13
- for (const each of possibleWords) {
14
- const distance = caseSensitive ? compareFunction(givenWord, each) : compareFunction(givenWord, each.toLowerCase());
11
+ for (const possibleWord of possibleWords) {
12
+ const each = possibleWord;
13
+ const distance = caseSensitive ? compareFunction(normalizedGivenWord, each) : compareFunction(normalizedGivenWord, each.toLowerCase());
15
14
  if (distance < closestStringDistance) {
16
15
  nearestWord = each;
17
16
  closestStringDistance = distance;
@@ -5,8 +5,8 @@ const compareSimilarity = (givenWord, options) => {
5
5
  if (options?.caseSensitive) {
6
6
  return (a, b) => compareFunction(givenWord, a) - compareFunction(givenWord, b);
7
7
  }
8
- givenWord = givenWord.toLowerCase();
9
- return (a, b) => compareFunction(givenWord, a.toLowerCase()) - compareFunction(givenWord, b.toLowerCase());
8
+ const normalizedGivenWord = givenWord.toLowerCase();
9
+ return (a, b) => compareFunction(normalizedGivenWord, a.toLowerCase()) - compareFunction(normalizedGivenWord, b.toLowerCase());
10
10
  };
11
11
 
12
12
  export { compareSimilarity };