@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,10 +1,45 @@
1
1
  import { StringWidthOptions } from "./get-string-width.js";
2
2
  import "./get-string-truncated-width.js";
3
+ /**
4
+ * Options for controlling the text alignment.
5
+ */
3
6
  type AlignTextOptions = {
7
+ /**
8
+ * The alignment direction.
9
+ * @default "center"
10
+ */
4
11
  align?: "center" | "left" | "right";
12
+ /**
13
+ * Character used for padding when aligning text.
14
+ * @default " "
15
+ */
5
16
  pad?: string;
17
+ /**
18
+ * The character to split the input string by, if it's a single string.
19
+ * @default "\n"
20
+ */
6
21
  split?: string;
22
+ /**
23
+ * Options to pass to `getStringWidth` for calculating the width of each line.
24
+ */
7
25
  stringWidthOptions?: StringWidthOptions;
8
26
  };
27
+ /**
28
+ * Aligns text (including multi-line strings with ANSI escape codes) to the left, center, or right.
29
+ * @example
30
+ * ```typescript
31
+ * alignText("Hello\nWorld!", { align: "right" });
32
+ * // => " Hello\nWorld!"
33
+ *
34
+ * alignText(["Beep", "Boop\nBop"], { align: "center" });
35
+ * // => [
36
+ * // " Beep",
37
+ * // "Boop\n Bop"
38
+ * // ]
39
+ * ```
40
+ * @param text The string or array of strings to align.
41
+ * @param options Options for controlling the alignment.
42
+ * @returns The aligned string or array of strings, matching the input type.
43
+ */
9
44
  declare const alignText: (text: string[] | string, options?: AlignTextOptions) => string[] | string;
10
45
  export { AlignTextOptions, alignText };
@@ -1,32 +1,2 @@
1
- import { getStringWidth } from './get-string-width.js';
2
-
3
- const halfDiff = (maxWidth, currentWidth) => Math.floor((maxWidth - currentWidth) / 2);
4
- const fullDiff = (maxWidth, currentWidth) => maxWidth - currentWidth;
5
- const alignText = (text, options = {}) => {
6
- const align = options.align ?? "center";
7
- if (align === "left") {
8
- return text;
9
- }
10
- const split = options.split ?? "\n";
11
- const pad = options.pad ?? " ";
12
- const widthDiffFunction = align === "right" ? fullDiff : halfDiff;
13
- let returnString = false;
14
- if (!Array.isArray(text)) {
15
- returnString = true;
16
- text = String(text).split(split);
17
- }
18
- let width;
19
- let maxWidth = 0;
20
- text = text.map((input) => {
21
- input = String(input);
22
- width = getStringWidth(input, options.stringWidthOptions);
23
- maxWidth = Math.max(width, maxWidth);
24
- return {
25
- str: input,
26
- width
27
- };
28
- }).map((object) => Array.from({ length: widthDiffFunction(maxWidth, object.width) + 1 }).join(pad) + object.str);
29
- return returnString ? text.join(split) : text;
30
- };
31
-
32
- export { alignText };
1
+ import{getStringWidth as f}from"./get-string-width.js";const m=(t,r)=>Math.floor((t-r)/2),c=(t,r)=>t-r,u=(t,r={})=>{const s=r.align??"center";if(s==="left")return t;const a=r.split??`
2
+ `,g=r.pad??" ",h=s==="right"?c:m;let l=!1,i;Array.isArray(t)?i=t:(l=!0,i=t.split(a));let o,e=0;const p=i.map(n=>(o=f(n,r.stringWidthOptions),e=Math.max(o,e),{str:n,width:o})).map(n=>Array.from({length:h(e,n.width)+1}).join(g)+n.str);return l?p.join(a):p};export{u as alignText};
@@ -1,5 +1,19 @@
1
- import { C as CaseOptions, a as CamelCase } 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, C as CamelCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Converts a string to camelCase.
5
+ * @param value The string to convert.
6
+ * @param options Options for case conversion.
7
+ * @returns The string in camelCase.
8
+ * @example
9
+ * ```typescript
10
+ * camelCase('foo bar') // 'fooBar'
11
+ * camelCase('foo-bar') // 'fooBar'
12
+ * camelCase('foo_bar') // 'fooBar'
13
+ * camelCase('XMLHttpRequest') // 'xmlHttpRequest'
14
+ * camelCase('AJAXRequest') // 'ajaxRequest'
15
+ * camelCase('QueryXML123String') // 'queryXml123String'
16
+ * ```
17
+ */
4
18
  declare const camelCase: <T extends string = string>(value?: T, options?: CaseOptions) => CamelCase<T>;
5
19
  export { camelCase as default };
@@ -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 lowerFirst from './lower-first.js';
4
- import { splitByCase } from './split-by-case.js';
5
- import upperFirst from './upper-first.js';
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';
9
-
10
- const defaultCacheStore = new LRUCache(1e3);
11
- const camelCase = (value, options) => {
12
- if (typeof value !== "string" || !value) {
13
- return "";
14
- }
15
- const shouldCache = options?.cache ?? false;
16
- const cacheStore = options?.cacheStore ?? defaultCacheStore;
17
- let cacheKey;
18
- if (shouldCache) {
19
- cacheKey = generateCacheKey(value, options);
20
- }
21
- if (shouldCache && cacheKey && cacheStore.has(cacheKey)) {
22
- return cacheStore.get(cacheKey);
23
- }
24
- let firstWord = true;
25
- const result = joinSegments(
26
- splitByCase(value, {
27
- handleAnsi: options?.handleAnsi,
28
- handleEmoji: options?.handleEmoji,
29
- knownAcronyms: options?.knownAcronyms,
30
- locale: options?.locale,
31
- normalize: options?.normalize,
32
- separators: void 0,
33
- stripAnsi: options?.stripAnsi,
34
- stripEmoji: options?.stripEmoji
35
- }).map((word) => {
36
- if (options?.handleAnsi && RE_FAST_ANSI.test(word)) {
37
- return word;
38
- }
39
- word = options?.locale?.startsWith("de") ? normalizeGermanEszett(word) : word;
40
- word = options?.locale ? word.toLocaleLowerCase(options.locale) : word.toLowerCase();
41
- if (firstWord) {
42
- firstWord = false;
43
- return lowerFirst(word, options);
44
- }
45
- return upperFirst(word, options);
46
- }),
47
- ""
48
- );
49
- if (shouldCache && cacheKey) {
50
- cacheStore.set(cacheKey, result);
51
- }
52
- return result;
53
- };
54
-
55
- export { camelCase as default };
1
+ import{c}from"../packem_shared/constants-aPzGW29R.js";import{i as p}from"../packem_shared/lru-cache-BtMSrYQJ.js";import f from"./lower-first.js";import{splitByCase as A}from"./split-by-case.js";import h from"./upper-first.js";import{n as d}from"../packem_shared/generate-cache-key-BqU1Cqwm.js";import u from"../packem_shared/joinSegments-CaHT-45s.js";import{a as w}from"../packem_shared/normalize-german-eszett-hNMwtGjd.js";const y=new p(1e3),_=(t,o)=>{if(typeof t!="string"||!t)return"";const i=o?.cache??!1,n=o?.cacheStore??y;let r;if(i&&(r=d(t,o)),i&&r&&n.has(r))return n.get(r);let a=!0;const e=u(A(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&&c.test(s))return s;const m=o?.locale?.startsWith("de")?w(s):s,l=o?.locale?m.toLocaleLowerCase(o.locale):m.toLowerCase();return a?(a=!1,f(l,o)):h(l,o)}),"");return i&&r&&n.set(r,e),e};export{_ as default};
@@ -1,5 +1,16 @@
1
- import { C as CaseOptions, b as CapitalCase } 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, a as CapitalCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Converts a string to Capital Case.
5
+ * @example
6
+ * ```typescript
7
+ * capitalCase("foo bar") // => "Foo Bar"
8
+ * capitalCase("foo-bar") // => "Foo Bar"
9
+ * capitalCase("foo_bar") // => "Foo Bar"
10
+ * capitalCase("XMLHttpRequest") // => "Xml Http Request"
11
+ * capitalCase("AJAXRequest") // => "Ajax Request"
12
+ * capitalCase("QueryXML123String") // => "Query Xml 123 String"
13
+ * ```
14
+ */
4
15
  declare const capitalCase: <T extends string = string>(value?: T, options?: CaseOptions) => CapitalCase<T>;
5
16
  export { capitalCase as default };
@@ -1,47 +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 capitalCase = (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
- const words = splitByCase(value, {
24
- handleAnsi: options?.handleAnsi,
25
- handleEmoji: options?.handleEmoji,
26
- knownAcronyms: options?.knownAcronyms,
27
- locale: options?.locale,
28
- normalize: options?.normalize,
29
- separators: void 0,
30
- stripAnsi: options?.stripAnsi,
31
- stripEmoji: options?.stripEmoji
32
- });
33
- const processed = words.map((word) => {
34
- if (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.toLocaleLowerCase(), options);
39
- });
40
- const result = joinSegments(processed, " ");
41
- if (shouldCache && cacheKey) {
42
- cacheStore.set(cacheKey, result);
43
- }
44
- return result;
45
- };
46
-
47
- export { capitalCase as default };
1
+ import{c as m}from"../packem_shared/constants-aPzGW29R.js";import{i as c}from"../packem_shared/lru-cache-BtMSrYQJ.js";import{splitByCase as p}from"./split-by-case.js";import f from"./upper-first.js";import{n as h}from"../packem_shared/generate-cache-key-BqU1Cqwm.js";import A from"../packem_shared/joinSegments-CaHT-45s.js";import{a as d}from"../packem_shared/normalize-german-eszett-hNMwtGjd.js";const u=new c(1e3),S=(s,o)=>{if(typeof s!="string")return"";const i=o?.cache??!1,a=o?.cacheStore??u;let r;if(i&&(r=h(s,o)),i&&r&&a.has(r))return a.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(m.test(t))return t;const e=o?.locale?.startsWith("de")?d(t):t;return f(o?.locale?e.toLocaleLowerCase(o.locale):e.toLocaleLowerCase(),o)}),n=A(l," ");return i&&r&&a.set(r,n),n};export{S as default};
@@ -1,5 +1,16 @@
1
- import { C as CaseOptions, c as ConstantCase } 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, c as ConstantCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Converts a string to CONSTANT_CASE.
5
+ * @example
6
+ * ```typescript
7
+ * constantCase("foo bar") // => "FOO_BAR"
8
+ * constantCase("foo-bar") // => "FOO_BAR"
9
+ * constantCase("foo_bar") // => "FOO_BAR"
10
+ * constantCase("XMLHttpRequest") // => "XML_HTTP_REQUEST"
11
+ * constantCase("AJAXRequest") // => "AJAX_REQUEST"
12
+ * constantCase("QueryXML123String") // => "QUERY_XML_123_STRING"
13
+ * ```
14
+ */
4
15
  declare const constantCase: <T extends string = string>(value?: T, options?: CaseOptions) => ConstantCase<T>;
5
16
  export { constantCase 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 constantCase = (value, options) => kebabCase(value, { cacheStore: defaultCacheStore, ...options, joiner: "_", toUpperCase: true });
6
-
7
- export { constantCase 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),m=(e,o)=>t(e,{cacheStore:a,...o,joiner:"_",toUpperCase:!0});export{m as default};
@@ -1,5 +1,16 @@
1
- import { C as CaseOptions, D as DotCase } 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, D as DotCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Converts a string to dot.case.
5
+ * @example
6
+ * ```typescript
7
+ * dotCase("foo bar") // => "foo.bar"
8
+ * dotCase("foo-bar") // => "foo.bar"
9
+ * dotCase("foo_bar") // => "foo.bar"
10
+ * dotCase("XMLHttpRequest") // => "xml.http.request"
11
+ * dotCase("AJAXRequest") // => "ajax.request"
12
+ * dotCase("QueryXML123String") // => "query.xml.123.string"
13
+ * ```
14
+ */
4
15
  declare const dotCase: <T extends string = string>(value?: T, options?: CaseOptions) => DotCase<T>;
5
16
  export { dotCase 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 dotCase = (value, options) => kebabCase(value, { cacheStore: defaultCacheStore, ...options, joiner: "." });
6
-
7
- export { dotCase 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,14 @@
1
- import { C as CaseOptions, F as FlatCase } 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 FlatCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Converts a string to flat case (all lowercase, no separators).
5
+ * @example
6
+ * ```typescript
7
+ * flatCase("foo-barBaz") // => "foobarbaz"
8
+ * flatCase("XMLHttpRequest") // => "xmlhttprequest"
9
+ * flatCase("AJAXRequest") // => "ajaxrequest"
10
+ * flatCase("QueryXML123String") // => "queryxml123string"
11
+ * ```
12
+ */
4
13
  declare const flatCase: <T extends string = string>(value?: T, options?: CaseOptions) => FlatCase<T>;
5
14
  export { flatCase 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 flatCase = (value, options) => kebabCase(value, { cacheStore: defaultCacheStore, ...options, joiner: "" });
6
-
7
- export { flatCase 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,6 +1,19 @@
1
- import { C as CaseOptions, d as FlipCase } 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, d as FlipCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Options specific to flip case operations.
5
+ * Note: handleEmoji is not needed as the function preserves emojis by default
6
+ */
4
7
  type FlipOptions = Omit<CaseOptions, "handleEmoji">;
8
+ /**
9
+ * Flips the case of each character in a string.
10
+ * @example
11
+ * ```typescript
12
+ * flipCase("FooBar") // => "fOObAR"
13
+ * flipCase("foobar") // => "FOOBAR"
14
+ * flipCase("FOOBAR") // => "foobar"
15
+ * flipCase("XMLHttpRequest") // => "xmlhTTPrEQUEST"
16
+ * ```
17
+ */
5
18
  declare const flipCase: <T extends string = string>(value?: T, options?: FlipOptions) => FlipCase<T>;
6
19
  export { FlipOptions, flipCase };
@@ -1,82 +1 @@
1
- import { createRequire as __cjs_createRequire } from "node:module";
2
-
3
- const __cjs_require = __cjs_createRequire(import.meta.url);
4
-
5
- const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
-
7
- const __cjs_getBuiltinModule = (module) => {
8
- // Check if we're in Node.js and version supports getBuiltinModule
9
- if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
- const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
- // Node.js 20.16.0+ and 22.3.0+
12
- if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
- return __cjs_getProcess.getBuiltinModule(module);
14
- }
15
- }
16
- // Fallback to createRequire
17
- return __cjs_require(module);
18
- };
19
-
20
- const {
21
- stripVTControlCharacters
22
- } = __cjs_getBuiltinModule("node:util");
23
- import { s as stripEmoji } from '../packem_shared/constants-D5qaproB.js';
24
- import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
25
- import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
26
-
27
- const defaultCacheStore = new LRUCache(1e3);
28
- const flipCase = (value, options) => {
29
- if (typeof value !== "string" || value.length === 0) {
30
- return "";
31
- }
32
- const shouldCache = options?.cache ?? false;
33
- const cacheStore = options?.cacheStore ?? defaultCacheStore;
34
- let cacheKey;
35
- if (shouldCache) {
36
- cacheKey = generateCacheKey(value, options);
37
- }
38
- if (shouldCache && cacheKey && cacheStore.has(cacheKey)) {
39
- return cacheStore.get(cacheKey);
40
- }
41
- let processedValue = value;
42
- if (options?.stripEmoji) {
43
- processedValue = stripEmoji(processedValue);
44
- }
45
- if (options?.stripAnsi) {
46
- processedValue = stripVTControlCharacters(processedValue);
47
- }
48
- let result = "";
49
- let index = 0;
50
- while (index < processedValue.length) {
51
- if (options?.handleAnsi && processedValue[index] === "\x1B") {
52
- let ansiSequence = processedValue[index];
53
- index += 1;
54
- while (index < processedValue.length && processedValue[index] !== "m") {
55
- ansiSequence += processedValue[index];
56
- index += 1;
57
- }
58
- if (index < processedValue.length) {
59
- ansiSequence += processedValue[index];
60
- result += ansiSequence;
61
- }
62
- index += 1;
63
- continue;
64
- }
65
- const char = processedValue[index];
66
- const lowerChar = options?.locale ? char.toLocaleLowerCase(options.locale) : char.toLowerCase();
67
- let flippedChar;
68
- if (char === lowerChar) {
69
- flippedChar = options?.locale ? char.toLocaleUpperCase(options.locale) : char.toUpperCase();
70
- } else {
71
- flippedChar = lowerChar;
72
- }
73
- result += flippedChar;
74
- index += 1;
75
- }
76
- if (shouldCache && cacheKey) {
77
- cacheStore.set(cacheKey, result);
78
- }
79
- return result;
80
- };
81
-
82
- export { flipCase };
1
+ import{createRequire as m}from"node:module";import{s as _}from"../packem_shared/constants-aPzGW29R.js";import{i as j}from"../packem_shared/lru-cache-BtMSrYQJ.js";import{n as C}from"../packem_shared/generate-cache-key-BqU1Cqwm.js";const h=m(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=s=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[e,n]=l.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return l.getBuiltinModule(s)}return h(s)},{stripVTControlCharacters:g}=d("node:util"),b=new j(1e3),v=(s,e)=>{if(typeof s!="string"||s.length===0)return"";const n=e?.cache??!1,a=e?.cacheStore??b;let r;if(n&&(r=C(s,e)),n&&r&&a.has(r))return a.get(r);let o=s;e?.stripEmoji&&(o=_(o)),e?.stripAnsi&&(o=g(o));let c="",t=0;for(;t<o.length;){if(e?.handleAnsi&&o[t]==="\x1B"){let f=o[t];for(t+=1;t<o.length&&o[t]!=="m";)f+=o[t],t+=1;t<o.length&&(f+=o[t],c+=f),t+=1;continue}const i=o[t],u=e?.locale?i.toLocaleLowerCase(e.locale):i.toLowerCase();let p;i===u?p=e?.locale?i.toLocaleUpperCase(e.locale):i.toUpperCase():p=u,c+=p,t+=1}return n&&r&&a.set(r,c),c};export{v as flipCase};
@@ -1,5 +1,17 @@
1
- import { I as IdentifyCase } 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 { I as IdentifyCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
3
+ /**
4
+ * Identifies the case style of a string.
5
+ * @example
6
+ * ```typescript
7
+ * identifyCase("fooBar") // => "camel"
8
+ * identifyCase("FooBar") // => "pascal"
9
+ * identifyCase("foo_bar") // => "snake"
10
+ * identifyCase("foo-bar") // => "kebab"
11
+ * identifyCase("foo") // => "lower"
12
+ * identifyCase("FOO") // => "upper"
13
+ * identifyCase("FooBAR") // => "mixed"
14
+ * ```
15
+ */
4
16
  declare const identifyCase: <T extends string = string>(value?: T) => IdentifyCase<T>;
5
17
  export { identifyCase as default };
@@ -1,65 +1 @@
1
- const IS_PASCAL_CASE = /^([A-Z][a-z]*)+$/;
2
- const CONTAINS_LETTER_CASE_INSENSITIVE = /[a-z]/i;
3
- const IS_UPPER_SNAKE_CASE = /^[A-Z0-9_]+$/;
4
- const IS_LOWER_SNAKE_CASE = /^[a-z0-9_]+$/;
5
- const IS_KEBAB_CASE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
6
- const IS_LOWERCASE_WITH_SPACE = /^[a-z ]+$/;
7
- const IS_UPPERCASE = /^[A-Z][A-Z0-9]*$/;
8
- const WHITESPACE_REGEX = /\s+/;
9
- const IS_NUMERIC = /^\d+$/;
10
- const IS_CAMEL_CASE_LIKE = /^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)+$/;
11
- const CONTAINS_PUNCTUATION_MID_WORD = /[.!?;:,](?!\s|$)/;
12
- const identifyCase = (value) => {
13
- if (typeof value !== "string") {
14
- throw new TypeError("Expected input to be a string");
15
- }
16
- if (!value) {
17
- return "unknown";
18
- }
19
- if (!CONTAINS_LETTER_CASE_INSENSITIVE.test(value)) {
20
- return "unknown";
21
- }
22
- if (value.includes("_")) {
23
- if (IS_UPPER_SNAKE_CASE.test(value)) {
24
- return "upper_snake";
25
- }
26
- if (IS_LOWER_SNAKE_CASE.test(value)) {
27
- return "snake";
28
- }
29
- return "mixed";
30
- }
31
- if (value.includes("-")) {
32
- if (IS_KEBAB_CASE.test(value)) {
33
- return "kebab";
34
- }
35
- return "mixed";
36
- }
37
- if (IS_LOWERCASE_WITH_SPACE.test(value)) {
38
- return "lower";
39
- }
40
- if (IS_UPPERCASE.test(value)) {
41
- return "upper";
42
- }
43
- const words = value.split(WHITESPACE_REGEX);
44
- if (words.length > 1 && words.every((word) => IS_PASCAL_CASE.test(word))) {
45
- return "title";
46
- }
47
- if (words.length > 1 && IS_NUMERIC.test(words[0]) && IS_PASCAL_CASE.test(words[1])) {
48
- return "title";
49
- }
50
- if (words.length > 1 && IS_PASCAL_CASE.test(words[0]) && /^[a-z]/.test(words[1])) {
51
- return "sentence";
52
- }
53
- if (IS_PASCAL_CASE.test(value)) {
54
- return "pascal";
55
- }
56
- if (IS_CAMEL_CASE_LIKE.test(value)) {
57
- return "camel";
58
- }
59
- if (CONTAINS_PUNCTUATION_MID_WORD.test(value)) {
60
- return "unknown";
61
- }
62
- return "mixed";
63
- };
64
-
65
- export { identifyCase as default };
1
+ const n=/^([A-Z][a-z]*)+$/,r=/[a-z]/i,a=/^[A-Z0-9_]+$/,i=/^[a-z0-9_]+$/,u=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,l=/^[a-z ]+$/,o=/^[A-Z][A-Z0-9]*$/,p=/\s+/,z=/^\d+$/,c=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)+$/,f=/^[a-z]/,$=/[.!?;:,](?!\s|$)/,d=e=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(!e||!r.test(e))return"unknown";if(e.includes("_"))return a.test(e)?"upper_snake":i.test(e)?"snake":"mixed";if(e.includes("-"))return u.test(e)?"kebab":"mixed";if(l.test(e))return"lower";if(o.test(e))return"upper";const t=e.split(p);return t.length>1&&t.every(s=>n.test(s))||t.length>1&&z.test(t[0])&&n.test(t[1])?"title":t.length>1&&n.test(t[0])&&f.test(t[1])?"sentence":n.test(e)?"pascal":c.test(e)?"camel":$.test(e)?"unknown":"mixed"};export{d as default};
@@ -1,4 +1,4 @@
1
- export { type N as NodeLocale } from "../packem_shared/types.d-BVNv675q.js";
1
+ export type { N as NodeLocale } from "../packem_shared/types.d-CmNvyl4l.js";
2
2
  export { default as camelCase } from "./camel-case.js";
3
3
  export { default as capitalCase } from "./capital-case.js";
4
4
  export { default as constantCase } from "./constant-case.js";
@@ -17,8 +17,13 @@ export { default as snakeCase } from "./snake-case.js";
17
17
  export { type SplitOptions, splitByCase } from "./split-by-case.js";
18
18
  export { default as titleCase } from "./title-case.js";
19
19
  export { default as trainCase } from "./train-case.js";
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";
20
+ export type { C as CamelCase, a as CapitalCase, b as CaseOptions, c as ConstantCase, D as DotCase, F as FlatCase, d as FlipCase, I as IdentifyCase, K as KebabCase, L as LocaleOptions, e as LowerFirst, N as NoCase, P as PascalCase, f as PascalSnakeCase, g as PathCase, S as SentenceCase, h as SnakeCase, i as SplitByCase, T as TitleCase, j as TrainCase, U as UpperFirst } from "../packem_shared/types.d-fhe030jX.js";
21
21
  export { default as upperFirst } from "./upper-first.js";
22
- import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
23
- declare const joinSegments: <T extends string = string>(segments: string[], joiner: string) => T;
22
+ /**
23
+ * Joins segments with a joiner, handling ANSI sequences and emojis correctly.
24
+ * @param segments Array of segments to join
25
+ * @param joiner String used to join segments together
26
+ * @returns Joined string with proper handling of ANSI and emoji sequences
27
+ */
28
+ declare const joinSegments: (segments: string[], joiner: string) => string;
24
29
  export { joinSegments };
@@ -1,20 +1 @@
1
- export { default as camelCase } from './camel-case.js';
2
- export { default as capitalCase } from './capital-case.js';
3
- export { default as constantCase } from './constant-case.js';
4
- export { default as dotCase } from './dot-case.js';
5
- export { default as flatCase } from './flat-case.js';
6
- export { flipCase } from './flip-case.js';
7
- export { default as identifyCase } from './identify-case.js';
8
- export { kebabCase } from './kebab-case.js';
9
- export { default as lowerFirst } from './lower-first.js';
10
- export { default as noCase } from './no-case.js';
11
- export { default as pascalCase } from './pascal-case.js';
12
- export { default as pascalSnakeCase } from './pascal-snake-case.js';
13
- export { default as pathCase } from './path-case.js';
14
- export { default as sentenceCase } from './sentence-case.js';
15
- export { default as snakeCase } from './snake-case.js';
16
- export { splitByCase } from './split-by-case.js';
17
- export { default as titleCase } from './title-case.js';
18
- export { default as trainCase } from './train-case.js';
19
- export { default as upperFirst } from './upper-first.js';
20
- export { default as joinSegments } from '../packem_shared/joinSegments-BStLas0c.js';
1
+ import{default as t}from"./camel-case.js";import{default as r}from"./capital-case.js";import{default as f}from"./constant-case.js";import{default as l}from"./dot-case.js";import{default as x}from"./flat-case.js";import{flipCase as u}from"./flip-case.js";import{default as n}from"./identify-case.js";import{kebabCase as c}from"./kebab-case.js";import{default as b}from"./lower-first.js";import{default as F}from"./no-case.js";import{default as g}from"./pascal-case.js";import{default as j}from"./pascal-snake-case.js";import{default as B}from"./path-case.js";import{default as v}from"./sentence-case.js";import{default as A}from"./snake-case.js";import{splitByCase as E}from"./split-by-case.js";import{default as H}from"./title-case.js";import{default as J}from"./train-case.js";import{default as L}from"./upper-first.js";import{default as N}from"../packem_shared/joinSegments-CaHT-45s.js";export{t as camelCase,r as capitalCase,f as constantCase,l as dotCase,x as flatCase,u as flipCase,n as identifyCase,N as joinSegments,c as kebabCase,b as lowerFirst,F as noCase,g as pascalCase,j as pascalSnakeCase,B as pathCase,v as sentenceCase,A as snakeCase,E as splitByCase,H as titleCase,J as trainCase,L as upperFirst};
@@ -1,9 +1,31 @@
1
- import { C as CaseOptions, K as KebabCase } 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, K as KebabCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
4
3
  interface KebabCaseOptions extends CaseOptions {
4
+ /**
5
+ * String used to join words together in kebab case format.
6
+ * @default "-"
7
+ */
5
8
  joiner?: string;
9
+ /**
10
+ * Whether to convert the result to uppercase.
11
+ * @default false
12
+ */
6
13
  toUpperCase?: boolean;
7
14
  }
15
+ /**
16
+ * Converts a string to kebab-case.
17
+ * @param value The string to convert to kebab-case.
18
+ * @param options Configuration options for kebab-case conversion.
19
+ * @returns The converted kebab-case string.
20
+ * @example
21
+ * ```typescript
22
+ * kebabCase("fooBar") // => "foo-bar"
23
+ * kebabCase("foo bar") // => "foo-bar"
24
+ * kebabCase("foo_bar") // => "foo-bar"
25
+ * kebabCase("XMLHttpRequest") // => "xml-http-request"
26
+ * kebabCase("AJAXRequest") // => "ajax-request"
27
+ * kebabCase("QueryXML123String") // => "query-xml-123-string"
28
+ * ```
29
+ */
8
30
  declare const kebabCase: <T extends string = string>(value?: T, options?: KebabCaseOptions) => KebabCase<T>;
9
31
  export { KebabCaseOptions, kebabCase };