@visulima/string 3.0.0-alpha.8 → 3.0.0

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 (121) hide show
  1. package/CHANGELOG.md +326 -0
  2. package/LICENSE.md +119 -0
  3. package/README.md +88 -4
  4. package/dist/align-text.d.ts +35 -0
  5. package/dist/align-text.js +2 -32
  6. package/dist/case/camel-case.d.ts +17 -3
  7. package/dist/case/camel-case.js +1 -55
  8. package/dist/case/capital-case.d.ts +14 -3
  9. package/dist/case/capital-case.js +1 -47
  10. package/dist/case/constant-case.d.ts +14 -3
  11. package/dist/case/constant-case.js +1 -7
  12. package/dist/case/dot-case.d.ts +14 -3
  13. package/dist/case/dot-case.js +1 -7
  14. package/dist/case/flat-case.d.ts +12 -3
  15. package/dist/case/flat-case.js +1 -7
  16. package/dist/case/flip-case.d.ts +16 -3
  17. package/dist/case/flip-case.js +1 -82
  18. package/dist/case/identify-case.d.ts +15 -3
  19. package/dist/case/identify-case.js +1 -65
  20. package/dist/case/index.d.ts +9 -4
  21. package/dist/case/index.js +1 -20
  22. package/dist/case/kebab-case.d.ts +25 -3
  23. package/dist/case/kebab-case.js +1 -55
  24. package/dist/case/lower-first.d.ts +13 -3
  25. package/dist/case/lower-first.js +1 -9
  26. package/dist/case/no-case.d.ts +14 -3
  27. package/dist/case/no-case.js +1 -7
  28. package/dist/case/pascal-case.d.ts +17 -3
  29. package/dist/case/pascal-case.js +1 -48
  30. package/dist/case/pascal-snake-case.d.ts +14 -3
  31. package/dist/case/pascal-snake-case.js +1 -28
  32. package/dist/case/path-case.d.ts +14 -3
  33. package/dist/case/path-case.js +1 -7
  34. package/dist/case/sentence-case.d.ts +14 -3
  35. package/dist/case/sentence-case.js +1 -54
  36. package/dist/case/snake-case.d.ts +14 -3
  37. package/dist/case/snake-case.js +1 -7
  38. package/dist/case/split-by-case.d.ts +29 -3
  39. package/dist/case/split-by-case.js +1 -747
  40. package/dist/case/title-case.d.ts +12 -3
  41. package/dist/case/title-case.js +1 -42
  42. package/dist/case/train-case.d.ts +14 -3
  43. package/dist/case/train-case.js +1 -40
  44. package/dist/case/upper-first.d.ts +13 -3
  45. package/dist/case/upper-first.js +1 -9
  46. package/dist/closest-string.d.ts +32 -0
  47. package/dist/closest-string.js +1 -23
  48. package/dist/compare-similarity.d.ts +37 -0
  49. package/dist/compare-similarity.js +1 -12
  50. package/dist/count-occurrences.d.ts +9 -0
  51. package/dist/count-occurrences.js +1 -0
  52. package/dist/direction.d.ts +7 -0
  53. package/dist/direction.js +1 -0
  54. package/dist/east-asian-width.d.ts +52 -0
  55. package/dist/east-asian-width.js +1 -0
  56. package/dist/excerpt.d.ts +25 -0
  57. package/dist/excerpt.js +53 -0
  58. package/dist/get-string-truncated-width.d.ts +151 -0
  59. package/dist/get-string-truncated-width.js +1 -444
  60. package/dist/get-string-width.d.ts +58 -0
  61. package/dist/get-string-width.js +1 -5
  62. package/dist/indent.d.ts +87 -0
  63. package/dist/indent.js +1 -0
  64. package/dist/index.d.ts +12 -15
  65. package/dist/index.js +1 -39
  66. package/dist/is-fullwidth-code-point.d.ts +7 -0
  67. package/dist/is-fullwidth-code-point.js +1 -0
  68. package/dist/levenshtein.d.ts +25 -0
  69. package/dist/levenshtein.js +1 -0
  70. package/dist/native-string-types.d.ts +239 -0
  71. package/dist/outdent.d.ts +74 -0
  72. package/dist/outdent.js +1 -117
  73. package/dist/packem_shared/_isFullWidth-Dqc3MWgl.js +1 -0
  74. package/dist/packem_shared/closest-C6YDQs4m.js +1 -0
  75. package/dist/packem_shared/constants-aPzGW29R.js +1 -0
  76. package/dist/packem_shared/dedent-CPjAYUXh.js +1 -0
  77. package/dist/packem_shared/eastAsianWidth-DJV8Kqd-.js +1 -0
  78. package/dist/packem_shared/generate-cache-key-BqU1Cqwm.js +1 -0
  79. package/dist/packem_shared/indent-cz8WMI0e.js +1 -0
  80. package/dist/packem_shared/joinSegments-CaHT-45s.js +1 -0
  81. package/dist/packem_shared/lru-cache-BtMSrYQJ.js +1 -0
  82. package/dist/packem_shared/normalize-german-eszett-hNMwtGjd.js +1 -0
  83. package/dist/packem_shared/redent-ByOoJ6fN.js +1 -0
  84. package/dist/packem_shared/types.d-CmNvyl4l.d.ts +360 -0
  85. package/dist/packem_shared/types.d-fhe030jX.d.ts +402 -0
  86. package/dist/replace-string.d.ts +10 -0
  87. package/dist/replace-string.js +1 -0
  88. package/dist/slice.d.ts +42 -0
  89. package/dist/slice.js +1 -413
  90. package/dist/slugify.d.ts +10 -1
  91. package/dist/slugify.js +1 -46
  92. package/dist/test/utils.d.ts +17 -0
  93. package/dist/test/utils.js +13 -88
  94. package/dist/test/vitest.d.ts +3 -0
  95. package/dist/test/vitest.js +1 -5
  96. package/dist/transliterate.d.ts +10 -0
  97. package/dist/transliterate.js +5 -0
  98. package/dist/truncate.d.ts +43 -0
  99. package/dist/truncate.js +1 -114
  100. package/dist/utilities.d.ts +28 -2
  101. package/dist/utilities.js +1 -54
  102. package/dist/word-similarity-sort.d.ts +34 -0
  103. package/dist/word-similarity-sort.js +1 -22
  104. package/dist/word-wrap.d.ts +44 -0
  105. package/dist/word-wrap.js +8 -637
  106. package/package.json +70 -39
  107. package/dist/packem_shared/LRUCache-3r3SovvR.js +0 -46
  108. package/dist/packem_shared/closest-IHuSvnSn.js +0 -139
  109. package/dist/packem_shared/closestN-Cvsw0Fue.js +0 -24
  110. package/dist/packem_shared/constants-D5qaproB.js +0 -95
  111. package/dist/packem_shared/countOccurrences-CS9XprQN.js +0 -22
  112. package/dist/packem_shared/direction-BVhR8MOQ.js +0 -10
  113. package/dist/packem_shared/excerpt-COsVNttN.js +0 -1502
  114. package/dist/packem_shared/generate-cache-key-DdayDfjV.js +0 -6
  115. package/dist/packem_shared/joinSegments-BStLas0c.js +0 -44
  116. package/dist/packem_shared/lru-cache.d-BsP6kbVJ.d.ts +0 -13
  117. package/dist/packem_shared/normalize-german-eszett-DEB8-ZPT.js +0 -7
  118. package/dist/packem_shared/replaceString-BVlxk27d.js +0 -190
  119. package/dist/packem_shared/transliterate-DGlx-woj.js +0 -47756
  120. package/dist/packem_shared/types.d-BVNv675q.d.ts +0 -61
  121. package/dist/packem_shared/types.d-DfgbcNKh.d.ts +0 -57
@@ -1,55 +1 @@
1
- import { R as RE_FAST_ANSI } from '../packem_shared/constants-D5qaproB.js';
2
- import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
3
- import { splitByCase } from './split-by-case.js';
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';
7
-
8
- const defaultCacheStore = new LRUCache(1e3);
9
- const kebabCase = (value, options) => {
10
- if (typeof value !== "string") {
11
- return "";
12
- }
13
- const shouldCache = options?.cache ?? false;
14
- const cacheStore = options?.cacheStore ?? defaultCacheStore;
15
- let cacheKey;
16
- if (shouldCache) {
17
- cacheKey = generateCacheKey(value, options);
18
- }
19
- if (shouldCache && cacheKey && cacheStore.has(cacheKey)) {
20
- return cacheStore.get(cacheKey);
21
- }
22
- const words = splitByCase(value, {
23
- handleAnsi: options?.handleAnsi,
24
- handleEmoji: options?.handleEmoji,
25
- knownAcronyms: options?.knownAcronyms,
26
- locale: options?.locale,
27
- normalize: options?.normalize,
28
- separators: void 0,
29
- stripAnsi: options?.stripAnsi,
30
- stripEmoji: options?.stripEmoji
31
- });
32
- const processed = words.map((word) => {
33
- if (options?.handleAnsi && RE_FAST_ANSI.test(word)) {
34
- return word;
35
- }
36
- if (options?.toUpperCase) {
37
- if (options.locale) {
38
- return word.toLocaleUpperCase(options.locale);
39
- }
40
- return word.toUpperCase();
41
- }
42
- const split = options?.locale?.startsWith("de") ? normalizeGermanEszett(word) : word;
43
- if (options?.locale) {
44
- return split.toLocaleLowerCase(options.locale);
45
- }
46
- return split.toLowerCase();
47
- });
48
- const result = joinSegments(processed, options?.joiner ?? "-");
49
- if (shouldCache && cacheKey) {
50
- cacheStore.set(cacheKey, result);
51
- }
52
- return result;
53
- };
54
-
55
- export { kebabCase };
1
+ import{c}from"../packem_shared/constants-aPzGW29R.js";import{i as m}from"../packem_shared/lru-cache-BtMSrYQJ.js";import{splitByCase as p}from"./split-by-case.js";import{n as f}from"../packem_shared/generate-cache-key-BqU1Cqwm.js";import h from"../packem_shared/joinSegments-CaHT-45s.js";import{a as A}from"../packem_shared/normalize-german-eszett-hNMwtGjd.js";const d=new m(1e3),L=(s,o)=>{if(typeof s!="string")return"";const n=o?.cache??!1,e=o?.cacheStore??d;let r;if(n&&(r=f(s,o)),n&&r&&e.has(r))return e.get(r);const l=p(s,{handleAnsi:o?.handleAnsi,handleEmoji:o?.handleEmoji,knownAcronyms:o?.knownAcronyms,locale:o?.locale,normalize:o?.normalize,separators:void 0,stripAnsi:o?.stripAnsi,stripEmoji:o?.stripEmoji}).map(t=>{if(o?.handleAnsi&&c.test(t))return t;if(o?.toUpperCase)return o.locale?t.toLocaleUpperCase(o.locale):t.toUpperCase();const a=o?.locale?.startsWith("de")?A(t):t;return o?.locale?a.toLocaleLowerCase(o.locale):a.toLowerCase()}),i=h(l,o?.joiner??"-");return n&&r&&e.set(r,i),i};export{L as kebabCase};
@@ -1,5 +1,15 @@
1
- import { L as LocaleOptions, e as LowerFirst } from "../packem_shared/types.d-DfgbcNKh.js";
2
- import "../packem_shared/types.d-BVNv675q.js";
3
- import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
1
+ import { L as LocaleOptions, e as LowerFirst } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Converts first character to lower case.
5
+ * @param value The string to convert.
6
+ * @param options Options for case conversion.
7
+ * @returns The string with its first character converted to lowercase.
8
+ * @example
9
+ * ```typescript
10
+ * lowerFirst("Hello world!") // => "hello world!"
11
+ * lowerFirst("İSTANBUL", { locale: "tr" }) // => "istanbul"
12
+ * ```
13
+ */
4
14
  declare const lowerFirst: <T extends string = string>(value?: T, options?: LocaleOptions) => LowerFirst<T>;
5
15
  export { lowerFirst as default };
@@ -1,9 +1 @@
1
- const lowerFirst = (value, options) => {
2
- if (typeof value !== "string" || value === "") {
3
- return "";
4
- }
5
- const firstChar = options?.locale ? value[0].toLocaleLowerCase(options.locale) : value[0].toLowerCase();
6
- return firstChar + value.slice(1);
7
- };
8
-
9
- export { lowerFirst as default };
1
+ const a=(e,o)=>typeof e!="string"||e===""?"":(o?.locale?e[0].toLocaleLowerCase(o.locale):e[0].toLowerCase())+e.slice(1);export{a as default};
@@ -1,5 +1,16 @@
1
- import { C as CaseOptions, N as NoCase } from "../packem_shared/types.d-DfgbcNKh.js";
2
- import "../packem_shared/types.d-BVNv675q.js";
3
- import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
1
+ import { b as CaseOptions, N as NoCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Converts a string to no case (space separated words).
5
+ * @example
6
+ * ```typescript
7
+ * noCase("foo bar") // => "foo bar"
8
+ * noCase("foo-bar") // => "foo bar"
9
+ * noCase("foo_bar") // => "foo bar"
10
+ * noCase("XMLHttpRequest") // => "xml http request"
11
+ * noCase("AJAXRequest") // => "ajax request"
12
+ * noCase("QueryXML123String") // => "query xml 123 string"
13
+ * ```
14
+ */
4
15
  declare const noCase: <T extends string = string>(value?: T, options?: CaseOptions) => NoCase<T>;
5
16
  export { noCase as default };
@@ -1,7 +1 @@
1
- import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
2
- import { kebabCase } from './kebab-case.js';
3
-
4
- const defaultCacheStore = new LRUCache(1e3);
5
- const noCase = (value, options) => kebabCase(value, { cacheStore: defaultCacheStore, ...options, joiner: " " });
6
-
7
- export { noCase as default };
1
+ import{i as r}from"../packem_shared/lru-cache-BtMSrYQJ.js";import{kebabCase as a}from"./kebab-case.js";const t=new r(1e3),c=(e,o)=>a(e,{cacheStore:t,...o,joiner:" "});export{c as default};
@@ -1,5 +1,19 @@
1
- import { C as CaseOptions, P as PascalCase } from "../packem_shared/types.d-DfgbcNKh.js";
2
- import "../packem_shared/types.d-BVNv675q.js";
3
- import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
1
+ import { b as CaseOptions, P as PascalCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Converts a string to PascalCase.
5
+ * @param value The string to convert.
6
+ * @param options Options for case conversion.
7
+ * @returns The string in PascalCase.
8
+ * @example
9
+ * ```typescript
10
+ * pascalCase('foo bar') // 'FooBar'
11
+ * pascalCase('foo-bar') // 'FooBar'
12
+ * pascalCase('foo_bar') // 'FooBar'
13
+ * pascalCase('XMLHttpRequest') // 'XmlHttpRequest'
14
+ * pascalCase('AJAXRequest') // 'AjaxRequest'
15
+ * pascalCase('QueryXML123String') // 'QueryXml123String'
16
+ * ```
17
+ */
4
18
  declare const pascalCase: <T extends string = string>(value?: T, options?: CaseOptions) => PascalCase<T>;
5
19
  export { pascalCase as default };
@@ -1,48 +1 @@
1
- import { R as RE_FAST_ANSI } from '../packem_shared/constants-D5qaproB.js';
2
- import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
3
- import { splitByCase } from './split-by-case.js';
4
- import upperFirst from './upper-first.js';
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';
8
-
9
- const defaultCacheStore = new LRUCache(1e3);
10
- const pascalCase = (value, options) => {
11
- if (typeof value !== "string" || !value) {
12
- return "";
13
- }
14
- const shouldCache = options?.cache ?? false;
15
- const cacheStore = options?.cacheStore ?? defaultCacheStore;
16
- let cacheKey;
17
- if (shouldCache) {
18
- cacheKey = generateCacheKey(value, options);
19
- }
20
- if (shouldCache && cacheKey && cacheStore.has(cacheKey)) {
21
- return cacheStore.get(cacheKey);
22
- }
23
- const result = joinSegments(
24
- splitByCase(value, {
25
- handleAnsi: options?.handleAnsi,
26
- handleEmoji: options?.handleEmoji,
27
- knownAcronyms: options?.knownAcronyms,
28
- locale: options?.locale,
29
- normalize: options?.normalize,
30
- separators: void 0,
31
- stripAnsi: options?.stripAnsi,
32
- stripEmoji: options?.stripEmoji
33
- }).map((word) => {
34
- if (options?.handleAnsi && RE_FAST_ANSI.test(word)) {
35
- return word;
36
- }
37
- const split = options?.locale?.startsWith("de") ? normalizeGermanEszett(word) : word;
38
- return upperFirst(options?.locale ? split.toLocaleLowerCase(options.locale) : split.toLowerCase(), { locale: options?.locale });
39
- }),
40
- ""
41
- );
42
- if (shouldCache && cacheKey) {
43
- cacheStore.set(cacheKey, result);
44
- }
45
- return result;
46
- };
47
-
48
- export { pascalCase as default };
1
+ import{c as e}from"../packem_shared/constants-aPzGW29R.js";import{i as m}from"../packem_shared/lru-cache-BtMSrYQJ.js";import{splitByCase as c}from"./split-by-case.js";import p from"./upper-first.js";import{n as f}from"../packem_shared/generate-cache-key-BqU1Cqwm.js";import h from"../packem_shared/joinSegments-CaHT-45s.js";import{a as A}from"../packem_shared/normalize-german-eszett-hNMwtGjd.js";const d=new m(1e3),L=(t,o)=>{if(typeof t!="string"||!t)return"";const n=o?.cache??!1,i=o?.cacheStore??d;let r;if(n&&(r=f(t,o)),n&&r&&i.has(r))return i.get(r);const a=h(c(t,{handleAnsi:o?.handleAnsi,handleEmoji:o?.handleEmoji,knownAcronyms:o?.knownAcronyms,locale:o?.locale,normalize:o?.normalize,separators:void 0,stripAnsi:o?.stripAnsi,stripEmoji:o?.stripEmoji}).map(s=>{if(o?.handleAnsi&&e.test(s))return s;const l=o?.locale?.startsWith("de")?A(s):s;return p(o?.locale?l.toLocaleLowerCase(o.locale):l.toLowerCase(),{locale:o?.locale})}),"");return n&&r&&i.set(r,a),a};export{L as default};
@@ -1,5 +1,16 @@
1
- import { C as CaseOptions, f as PascalSnakeCase } from "../packem_shared/types.d-DfgbcNKh.js";
2
- import "../packem_shared/types.d-BVNv675q.js";
3
- import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
1
+ import { b as CaseOptions, f as PascalSnakeCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Converts a string to Pascal_Snake_Case.
5
+ * @example
6
+ * ```typescript
7
+ * pascalSnakeCase("foo bar") // => "Foo_Bar"
8
+ * pascalSnakeCase("foo-bar") // => "Foo_Bar"
9
+ * pascalSnakeCase("foo_bar") // => "Foo_Bar"
10
+ * pascalSnakeCase("XMLHttpRequest") // => "Xml_Http_Request"
11
+ * pascalSnakeCase("AJAXRequest") // => "Ajax_Request"
12
+ * pascalSnakeCase("QueryXML123String") // => "Query_Xml_123_String"
13
+ * ```
14
+ */
4
15
  declare const pascalSnakeCase: <T extends string = string>(value?: T, options?: CaseOptions) => PascalSnakeCase<T>;
5
16
  export { pascalSnakeCase as default };
@@ -1,28 +1 @@
1
- import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
2
- import noCase from './no-case.js';
3
- import upperFirst from './upper-first.js';
4
- import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
5
-
6
- const defaultCacheStore = new LRUCache(1e3);
7
- const pascalSnakeCase = (value, options) => {
8
- if (typeof value !== "string") {
9
- return "";
10
- }
11
- const shouldCache = options?.cache ?? false;
12
- const cacheStore = options?.cacheStore ?? defaultCacheStore;
13
- let cacheKey;
14
- if (shouldCache) {
15
- cacheKey = generateCacheKey(value, options);
16
- }
17
- if (shouldCache && cacheKey && cacheStore.has(cacheKey)) {
18
- return cacheStore.get(cacheKey);
19
- }
20
- const words = noCase(value, { ...options, cache: false }).split(" ");
21
- const result = words.map((word) => upperFirst(word, { locale: options?.locale })).join("_");
22
- if (shouldCache && cacheKey) {
23
- cacheStore.set(cacheKey, result);
24
- }
25
- return result;
26
- };
27
-
28
- export { pascalSnakeCase as default };
1
+ import{i as n}from"../packem_shared/lru-cache-BtMSrYQJ.js";import l from"./no-case.js";import m from"./upper-first.js";import{n as p}from"../packem_shared/generate-cache-key-BqU1Cqwm.js";const s=new n(1e3),d=(r,t)=>{if(typeof r!="string")return"";const o=t?.cache??!1,c=t?.cacheStore??s;let e;if(o&&(e=p(r,t)),o&&e&&c.has(e))return c.get(e);const f=l(r,{...t,cache:!1}).split(" ").map(i=>m(i,{locale:t?.locale})).join("_");return o&&e&&c.set(e,f),f};export{d as default};
@@ -1,5 +1,16 @@
1
- import { C as CaseOptions, g as PathCase } from "../packem_shared/types.d-DfgbcNKh.js";
2
- import "../packem_shared/types.d-BVNv675q.js";
3
- import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
1
+ import { b as CaseOptions, g as PathCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Converts a string to path/case.
5
+ * @example
6
+ * ```typescript
7
+ * pathCase("foo bar") // => "foo/bar"
8
+ * pathCase("foo-bar") // => "foo/bar"
9
+ * pathCase("foo_bar") // => "foo/bar"
10
+ * pathCase("XMLHttpRequest") // => "xml/http/request"
11
+ * pathCase("AJAXRequest") // => "ajax/request"
12
+ * pathCase("QueryXML123String") // => "query/xml/123/string"
13
+ * ```
14
+ */
4
15
  declare const pathCase: <T extends string = string>(value?: T, options?: CaseOptions) => PathCase<T>;
5
16
  export { pathCase as default };
@@ -1,7 +1 @@
1
- import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
2
- import { kebabCase } from './kebab-case.js';
3
-
4
- const defaultCacheStore = new LRUCache(1e3);
5
- const pathCase = (value, options) => kebabCase(value, { cacheStore: defaultCacheStore, ...options, joiner: "/" });
6
-
7
- export { pathCase as default };
1
+ import{i as r}from"../packem_shared/lru-cache-BtMSrYQJ.js";import{kebabCase as t}from"./kebab-case.js";const a=new r(1e3),c=(e,o)=>t(e,{cacheStore:a,...o,joiner:"/"});export{c as default};
@@ -1,5 +1,16 @@
1
- import { C as CaseOptions, S as SentenceCase } from "../packem_shared/types.d-DfgbcNKh.js";
2
- import "../packem_shared/types.d-BVNv675q.js";
3
- import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
1
+ import { b as CaseOptions, S as SentenceCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Converts a string to Sentence case.
5
+ * @example
6
+ * ```typescript
7
+ * sentenceCase("foo bar") // => "Foo bar"
8
+ * sentenceCase("foo-bar") // => "Foo bar"
9
+ * sentenceCase("foo_bar") // => "Foo bar"
10
+ * sentenceCase("XMLHttpRequest") // => "Xml http request"
11
+ * sentenceCase("AJAXRequest") // => "Ajax request"
12
+ * sentenceCase("QueryXML123String") // => "Query xml 123 string"
13
+ * ```
14
+ */
4
15
  declare const sentenceCase: <T extends string = string>(value?: T, options?: CaseOptions) => SentenceCase<T>;
5
16
  export { sentenceCase as default };
@@ -1,54 +1 @@
1
- import { R as RE_FAST_ANSI } from '../packem_shared/constants-D5qaproB.js';
2
- import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
3
- import { splitByCase } from './split-by-case.js';
4
- import upperFirst from './upper-first.js';
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';
8
-
9
- const defaultCacheStore = new LRUCache(1e3);
10
- const sentenceCase = (value, options) => {
11
- if (typeof value !== "string") {
12
- return "";
13
- }
14
- const shouldCache = options?.cache ?? false;
15
- const cacheStore = options?.cacheStore ?? defaultCacheStore;
16
- let cacheKey;
17
- if (shouldCache) {
18
- cacheKey = generateCacheKey(value, options);
19
- }
20
- if (shouldCache && cacheKey && cacheStore.has(cacheKey)) {
21
- return cacheStore.get(cacheKey);
22
- }
23
- let firstWord = true;
24
- const result = joinSegments(
25
- splitByCase(value, {
26
- handleAnsi: options?.handleAnsi,
27
- handleEmoji: options?.handleEmoji,
28
- knownAcronyms: options?.knownAcronyms,
29
- locale: options?.locale,
30
- normalize: options?.normalize,
31
- separators: void 0,
32
- stripAnsi: options?.stripAnsi,
33
- stripEmoji: options?.stripEmoji
34
- }).map((word) => {
35
- if (options?.handleAnsi && RE_FAST_ANSI.test(word)) {
36
- return word;
37
- }
38
- word = options?.locale?.startsWith("de") ? normalizeGermanEszett(word) : word;
39
- word = options?.locale ? word.toLocaleLowerCase(options.locale) : word.toLowerCase();
40
- if (firstWord) {
41
- firstWord = false;
42
- return upperFirst(word, options);
43
- }
44
- return word;
45
- }),
46
- " "
47
- );
48
- if (shouldCache && cacheKey) {
49
- cacheStore.set(cacheKey, result);
50
- }
51
- return result;
52
- };
53
-
54
- export { sentenceCase as default };
1
+ import{c}from"../packem_shared/constants-aPzGW29R.js";import{i as p}from"../packem_shared/lru-cache-BtMSrYQJ.js";import{splitByCase as f}from"./split-by-case.js";import h from"./upper-first.js";import{n as A}from"../packem_shared/generate-cache-key-BqU1Cqwm.js";import d from"../packem_shared/joinSegments-CaHT-45s.js";import{a as u}from"../packem_shared/normalize-german-eszett-hNMwtGjd.js";const w=new p(1e3),k=(s,o)=>{if(typeof s!="string")return"";const i=o?.cache??!1,a=o?.cacheStore??w;let r;if(i&&(r=A(s,o)),i&&r&&a.has(r))return a.get(r);let n=!0;const e=d(f(s,{handleAnsi:o?.handleAnsi,handleEmoji:o?.handleEmoji,knownAcronyms:o?.knownAcronyms,locale:o?.locale,normalize:o?.normalize,separators:void 0,stripAnsi:o?.stripAnsi,stripEmoji:o?.stripEmoji}).map(t=>{if(o?.handleAnsi&&c.test(t))return t;const l=o?.locale?.startsWith("de")?u(t):t,m=o?.locale?l.toLocaleLowerCase(o.locale):l.toLowerCase();return n?(n=!1,h(m,o)):m})," ");return i&&r&&a.set(r,e),e};export{k as default};
@@ -1,5 +1,16 @@
1
- import { C as CaseOptions, h as SnakeCase } from "../packem_shared/types.d-DfgbcNKh.js";
2
- import "../packem_shared/types.d-BVNv675q.js";
3
- import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
1
+ import { b as CaseOptions, h as SnakeCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Converts a string to snake_case.
5
+ * @example
6
+ * ```typescript
7
+ * snakeCase("fooBar") // => "foo_bar"
8
+ * snakeCase("foo bar") // => "foo_bar"
9
+ * snakeCase("foo-bar") // => "foo_bar"
10
+ * snakeCase("XMLHttpRequest") // => "xml_http_request"
11
+ * snakeCase("AJAXRequest") // => "ajax_request"
12
+ * snakeCase("QueryXML123String") // => "query_xml_123_string"
13
+ * ```
14
+ */
4
15
  declare const snakeCase: <T extends string = string>(value?: T, options?: CaseOptions) => SnakeCase<T>;
5
16
  export { snakeCase as default };
@@ -1,7 +1 @@
1
- import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
2
- import { kebabCase } from './kebab-case.js';
3
-
4
- const defaultCacheStore = new LRUCache(1e3);
5
- const snakeCase = (value, options) => kebabCase(value, { cacheStore: defaultCacheStore, ...options, joiner: "_" });
6
-
7
- export { snakeCase as default };
1
+ import{i as r}from"../packem_shared/lru-cache-BtMSrYQJ.js";import{kebabCase as t}from"./kebab-case.js";const a=new r(1e3),n=(e,o)=>t(e,{cacheStore:a,...o,joiner:"_"});export{n as default};
@@ -1,14 +1,40 @@
1
- import { L as LocaleOptions, i as SplitByCase } from "../packem_shared/types.d-DfgbcNKh.js";
2
- import "../packem_shared/types.d-BVNv675q.js";
3
- import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
1
+ import { L as LocaleOptions, i as SplitByCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /** Options for the `splitByCase` function. */
4
4
  interface SplitOptions extends LocaleOptions {
5
+ /** Whether to handle ANSI escape sequences. (default: false) */
5
6
  handleAnsi?: boolean;
7
+ /** Whether to handle emoji sequences. (default: false) */
6
8
  handleEmoji?: boolean;
9
+ /** A list of known acronyms to preserve casing for. */
7
10
  knownAcronyms?: ReadonlyArray<string>;
11
+ /** Whether to normalize case (convert all‑upper tokens not in knownAcronyms to title case). */
8
12
  normalize?: boolean;
13
+ /** List of additional separators to split on. */
9
14
  separators?: ReadonlyArray<string> | RegExp;
15
+ /** Whether to strip ANSI escape sequences. (default: false) */
10
16
  stripAnsi?: boolean;
17
+ /** Whether to strip emoji sequences. (default: false) */
11
18
  stripEmoji?: boolean;
12
19
  }
20
+ /**
21
+ * Splits a string into segments based on various criteria including case changes,
22
+ * separators, Unicode scripts, ANSI codes, and emojis.
23
+ *
24
+ * This is the core splitting logic used by various case conversion functions.
25
+ * @template T - The specific literal type of the input string, if known.
26
+ * @param input The string to split.
27
+ * @param options Configuration options for splitting behavior.
28
+ * @returns An array of string segments.
29
+ * @example
30
+ * ```typescript
31
+ * splitByCase("fooBarBaz") // => ["foo", "Bar", "Baz"]
32
+ * splitByCase("foo_bar-baz") // => ["foo", "bar", "baz"]
33
+ * splitByCase("HTMLElement") // => ["HTML", "Element"]
34
+ * splitByCase("HTMLElement", { knownAcronyms: ["HTML"] }) // => ["HTML", "Element"]
35
+ * splitByCase("\u001B[31mhello\u001B[0mWorld", { handleAnsi: true }) // => ["\u001B[31m", "hello", "\u001B[0m", "World"]
36
+ * splitByCase("hello🌍world", { handleEmoji: true }) // => ["hello", "🌍", "world"]
37
+ * ```
38
+ */
13
39
  declare const splitByCase: <T extends string = string>(input: T, options?: SplitOptions) => SplitByCase<T>;
14
40
  export { SplitOptions, splitByCase };