@visulima/string 2.0.2 → 2.0.4

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 (55) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/dist/align-text.js +32 -2
  3. package/dist/case/camel-case.js +55 -1
  4. package/dist/case/capital-case.js +47 -1
  5. package/dist/case/constant-case.js +7 -1
  6. package/dist/case/dot-case.js +7 -1
  7. package/dist/case/flat-case.js +7 -1
  8. package/dist/case/flip-case.js +76 -1
  9. package/dist/case/identify-case.js +65 -1
  10. package/dist/case/index.js +20 -1
  11. package/dist/case/kebab-case.js +55 -1
  12. package/dist/case/lower-first.js +9 -1
  13. package/dist/case/no-case.js +7 -1
  14. package/dist/case/pascal-case.js +48 -1
  15. package/dist/case/pascal-snake-case.js +28 -1
  16. package/dist/case/path-case.js +7 -1
  17. package/dist/case/sentence-case.js +54 -1
  18. package/dist/case/snake-case.js +7 -1
  19. package/dist/case/split-by-case.js +644 -1
  20. package/dist/case/title-case.js +42 -1
  21. package/dist/case/train-case.js +40 -1
  22. package/dist/case/upper-first.js +9 -1
  23. package/dist/closest-string.js +25 -1
  24. package/dist/compare-similarity.js +12 -1
  25. package/dist/get-string-truncated-width.js +363 -1
  26. package/dist/get-string-width.js +5 -1
  27. package/dist/index.js +36 -1
  28. package/dist/outdent.js +118 -1
  29. package/dist/packem_shared/LRUCache-3r3SovvR.js +46 -0
  30. package/dist/packem_shared/closest-IHuSvnSn.js +139 -0
  31. package/dist/packem_shared/closestN-BREy4E7C.js +19 -0
  32. package/dist/packem_shared/constants-CTzC6Gjg.js +95 -0
  33. package/dist/packem_shared/generate-cache-key-DdayDfjV.js +6 -0
  34. package/dist/packem_shared/joinSegments-CuU8RGpP.js +44 -0
  35. package/dist/packem_shared/normalize-german-eszett-DEB8-ZPT.js +7 -0
  36. package/dist/packem_shared/replaceString-vYvRBMfC.js +190 -0
  37. package/dist/packem_shared/transliterate-CUF6Ggy_.js +47776 -0
  38. package/dist/slice.js +413 -1
  39. package/dist/slugify.js +46 -1
  40. package/dist/test/utils.js +88 -13
  41. package/dist/test/vitest.js +5 -1
  42. package/dist/truncate.js +89 -1
  43. package/dist/utilities.js +54 -1
  44. package/dist/word-similarity-sort.js +22 -1
  45. package/dist/word-wrap.js +637 -8
  46. package/package.json +1 -1
  47. package/dist/packem_shared/LRUCache-Bjo6gsbC.js +0 -1
  48. package/dist/packem_shared/closest-uarbVSbs.js +0 -1
  49. package/dist/packem_shared/closestN-DjNxwK0t.js +0 -1
  50. package/dist/packem_shared/constants-CDcaCZKC.js +0 -1
  51. package/dist/packem_shared/generate-cache-key-DPByFaMH.js +0 -1
  52. package/dist/packem_shared/joinSegments-DTGeJBZG.js +0 -1
  53. package/dist/packem_shared/normalize-german-eszett-4k1qRtEP.js +0 -1
  54. package/dist/packem_shared/replaceString-DwIZyvoL.js +0 -1
  55. package/dist/packem_shared/transliterate-CxVHmZUa.js +0 -5
package/CHANGELOG.md CHANGED
@@ -1,3 +1,34 @@
1
+ ## @visulima/string [2.0.4](https://github.com/visulima/visulima/compare/@visulima/string@2.0.3...@visulima/string@2.0.4) (2025-11-07)
2
+
3
+ ### Bug Fixes
4
+
5
+ * update TypeScript configurations and improve linting across multiple packages ([6f25ec7](https://github.com/visulima/visulima/commit/6f25ec7841da7246f8f9166efc5292a7089d37ee))
6
+
7
+ ### Miscellaneous Chores
8
+
9
+ * update npm and pnpm configurations for monorepo optimization ([#564](https://github.com/visulima/visulima/issues/564)) ([5512b42](https://github.com/visulima/visulima/commit/5512b42f672c216b6a3c9e39035199a4ebd9a4b8))
10
+
11
+
12
+ ### Dependencies
13
+
14
+ * **@visulima/colorize:** upgraded to 1.4.27
15
+
16
+ ## @visulima/string [2.0.3](https://github.com/visulima/visulima/compare/@visulima/string@2.0.2...@visulima/string@2.0.3) (2025-11-05)
17
+
18
+ ### Bug Fixes
19
+
20
+ * added new tests for handling Japanese text in word wrapping functionality. ([c4a7c00](https://github.com/visulima/visulima/commit/c4a7c00a5606e1ab80bdc22538e5a7ea6263250b))
21
+ * update dependencies across multiple packages ([36a47f2](https://github.com/visulima/visulima/commit/36a47f26d65d25a7b4d8371186710e7d0ab61a2b))
22
+
23
+ ### Miscellaneous Chores
24
+
25
+ * update dependencies across multiple packages ([c526462](https://github.com/visulima/visulima/commit/c52646260c2ae8bbf85692e642f305f47a158d4e))
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * **@visulima/colorize:** upgraded to 1.4.26
31
+
1
32
  ## @visulima/string [2.0.2](https://github.com/visulima/visulima/compare/@visulima/string@2.0.1...@visulima/string@2.0.2) (2025-10-22)
2
33
 
3
34
  ### Bug Fixes
@@ -33,7 +64,7 @@
33
64
  ### Bug Fixes
34
65
 
35
66
  * Adjusted the node engine requirement to support versions 20.19 and above ([7a2a2c0](https://github.com/visulima/visulima/commit/7a2a2c003a3627ee3052095b5624e6bf20db28d9))
36
- * update @visulima/packem to 2.0.0-alpha.30 across multiple packages for improved compatibility ([27b346e](https://github.com/visulima/visulima/commit/27b346eaa1c0fb0e420d9a9824482028307f4249))
67
+ * update @visulima/packem to 2.0.0-alpha.32 across multiple packages for improved compatibility ([27b346e](https://github.com/visulima/visulima/commit/27b346eaa1c0fb0e420d9a9824482028307f4249))
37
68
 
38
69
  ### Miscellaneous Chores
39
70
 
@@ -1,2 +1,32 @@
1
- var p=Object.defineProperty;var s=(t,r)=>p(t,"name",{value:r,configurable:!0});import{getStringWidth as c}from"./get-string-width.js";var d=Object.defineProperty,i=s((t,r)=>d(t,"name",{value:r,configurable:!0}),"n");const m=i((t,r)=>Math.floor((t-r)/2),"halfDiff"),u=i((t,r)=>t-r,"fullDiff"),j=i((t,r={})=>{const l=r.align??"center";if(l==="left")return t;const o=r.split??`
2
- `,g=r.pad??" ",h=l==="right"?u:m;let f=!1;Array.isArray(t)||(f=!0,t=String(t).split(o));let n,a=0;return t=t.map(e=>(e=String(e),n=c(e,r.stringWidthOptions),a=Math.max(n,a),{str:e,width:n})).map(e=>Array.from({length:h(a,e.width)+1}).join(g)+e.str),f?t.join(o):t},"alignText");export{j as alignText};
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 +1,55 @@
1
- var m=Object.defineProperty;var n=(t,o)=>m(t,"name",{value:o,configurable:!0});import{R as c}from"../packem_shared/constants-CDcaCZKC.js";import p from"../packem_shared/LRUCache-Bjo6gsbC.js";import f from"./lower-first.js";import{splitByCase as d}from"./split-by-case.js";import h from"./upper-first.js";import{a as A}from"../packem_shared/generate-cache-key-DPByFaMH.js";import u from"../packem_shared/joinSegments-DTGeJBZG.js";import{l as y}from"../packem_shared/normalize-german-eszett-4k1qRtEP.js";var j=Object.defineProperty,w=n((t,o)=>j(t,"name",{value:o,configurable:!0}),"l");const E=new p(1e3),R=w((t,o)=>{if(typeof t!="string"||!t)return"";const e=o?.cache??!1,s=o?.cacheStore??E;let r;if(e&&(r=A(t,o)),e&&r&&s.has(r))return s.get(r);let i=!0;const l=u(d(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(a=>o?.handleAnsi&&c.test(a)?a:(a=o?.locale?.startsWith("de")?y(a):a,a=o?.locale?a.toLocaleLowerCase(o.locale):a.toLowerCase(),i?(i=!1,f(a,o)):h(a,o))),"");return e&&r&&s.set(r,l),l},"camelCase");export{R as default};
1
+ import { R as RE_FAST_ANSI } from '../packem_shared/constants-CTzC6Gjg.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-CuU8RGpP.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 +1,47 @@
1
- var c=Object.defineProperty;var l=(r,o)=>c(r,"name",{value:o,configurable:!0});import{R as p}from"../packem_shared/constants-CDcaCZKC.js";import f from"../packem_shared/LRUCache-Bjo6gsbC.js";import{splitByCase as u}from"./split-by-case.js";import A from"./upper-first.js";import{a as d}from"../packem_shared/generate-cache-key-DPByFaMH.js";import h from"../packem_shared/joinSegments-DTGeJBZG.js";import{l as y}from"../packem_shared/normalize-german-eszett-4k1qRtEP.js";var j=Object.defineProperty,w=l((r,o)=>j(r,"name",{value:o,configurable:!0}),"l");const E=new f(1e3),z=w((r,o)=>{if(typeof r!="string")return"";const e=o?.cache??!1,s=o?.cacheStore??E;let a;if(e&&(a=d(r,o)),e&&a&&s.has(a))return s.get(a);const m=u(r,{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(p.test(t))return t;const n=o?.locale?.startsWith("de")?y(t):t;return A(o?.locale?n.toLocaleLowerCase(o.locale):n.toLocaleLowerCase(),o)}),i=h(m," ");return e&&a&&s.set(a,i),i},"capitalCase");export{z as default};
1
+ import { R as RE_FAST_ANSI } from '../packem_shared/constants-CTzC6Gjg.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-CuU8RGpP.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 +1,7 @@
1
- var t=Object.defineProperty;var a=(e,r)=>t(e,"name",{value:r,configurable:!0});import o from"../packem_shared/LRUCache-Bjo6gsbC.js";import{kebabCase as n}from"./kebab-case.js";var s=Object.defineProperty,c=a((e,r)=>s(e,"name",{value:r,configurable:!0}),"s");const p=new o(1e3),u=c((e,r)=>n(e,{cacheStore:p,...r,joiner:"_",toUpperCase:!0}),"constantCase");export{u as default};
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 +1,7 @@
1
- var a=Object.defineProperty;var o=(e,r)=>a(e,"name",{value:r,configurable:!0});import t from"../packem_shared/LRUCache-Bjo6gsbC.js";import{kebabCase as n}from"./kebab-case.js";var i=Object.defineProperty,s=o((e,r)=>i(e,"name",{value:r,configurable:!0}),"o");const c=new t(1e3),p=s((e,r)=>n(e,{cacheStore:c,...r,joiner:"."}),"dotCase");export{p as default};
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 +1,7 @@
1
- var o=Object.defineProperty;var r=(e,a)=>o(e,"name",{value:a,configurable:!0});import t from"../packem_shared/LRUCache-Bjo6gsbC.js";import{kebabCase as n}from"./kebab-case.js";var f=Object.defineProperty,i=r((e,a)=>f(e,"name",{value:a,configurable:!0}),"a");const s=new t(1e3),l=i((e,a)=>n(e,{cacheStore:s,...a,joiner:""}),"flatCase");export{l as default};
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 +1,76 @@
1
- var m=Object.defineProperty;var f=(r,e)=>m(r,"name",{value:e,configurable:!0});import{createRequire as g}from"node:module";import{s as j}from"../packem_shared/constants-CDcaCZKC.js";import C from"../packem_shared/LRUCache-Bjo6gsbC.js";import{a as b}from"../packem_shared/generate-cache-key-DPByFaMH.js";const h=g(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=f(r=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[e,s]=l.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return l.getBuiltinModule(r)}return h(r)},"__cjs_getBuiltinModule"),{stripVTControlCharacters:_}=d("node:util");var v=Object.defineProperty,y=f((r,e)=>v(r,"name",{value:e,configurable:!0}),"p");const L=new C(1e3),A=y((r,e)=>{if(typeof r!="string"||r.length===0)return"";const s=e?.cache??!1,c=e?.cacheStore??L;let n;if(s&&(n=b(r,e)),s&&n&&c.has(n))return c.get(n);let o=r;e?.stripEmoji&&(o=j(o)),e?.stripAnsi&&(o=_(o));let a="",t=0;for(;t<o.length;){if(e?.handleAnsi&&o[t]==="\x1B"){let p=o[t];for(t+=1;t<o.length&&o[t]!=="m";)p+=o[t],t+=1;t<o.length&&(p+=o[t],a+=p),t+=1;continue}const i=o[t],u=e?.locale?i.toLocaleLowerCase(e.locale):i.toLowerCase();a+=i===u?e?.locale?i.toLocaleUpperCase(e.locale):i.toUpperCase():u,t+=1}return s&&n&&c.set(n,a),a},"flipCase");export{A as flipCase};
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-CTzC6Gjg.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
+ result += char === lowerChar ? options?.locale ? char.toLocaleUpperCase(options.locale) : char.toUpperCase() : lowerChar;
68
+ index += 1;
69
+ }
70
+ if (shouldCache && cacheKey) {
71
+ cacheStore.set(cacheKey, result);
72
+ }
73
+ return result;
74
+ };
75
+
76
+ export { flipCase };
@@ -1 +1,65 @@
1
- var a=Object.defineProperty;var s=(e,t)=>a(e,"name",{value:t,configurable:!0});var i=Object.defineProperty,u=s((e,t)=>i(e,"name",{value:t,configurable:!0}),"s");const n=/^([A-Z][a-z]*)+$/,l=/[a-z]/i,o=/^[A-Z0-9_]+$/,p=/^[a-z0-9_]+$/,f=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,c=/^[a-z ]+$/,z=/^[A-Z][A-Z0-9]*$/,d=/\s+/,$=/^\d+$/,g=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)+$/,A=/[.!?;:,](?!\s|$)/,k=u(e=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(!e||!l.test(e))return"unknown";if(e.includes("_"))return o.test(e)?"upper_snake":p.test(e)?"snake":"mixed";if(e.includes("-"))return f.test(e)?"kebab":"mixed";if(c.test(e))return"lower";if(z.test(e))return"upper";const t=e.split(d);return t.length>1&&t.every(r=>n.test(r))||t.length>1&&$.test(t[0])&&n.test(t[1])?"title":t.length>1&&n.test(t[0])&&/^[a-z]/.test(t[1])?"sentence":n.test(e)?"pascal":g.test(e)?"camel":A.test(e)?"unknown":"mixed"},"identifyCase");export{k as default};
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 +1,20 @@
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-DTGeJBZG.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
+ 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-CuU8RGpP.js';
@@ -1 +1,55 @@
1
- var m=Object.defineProperty;var l=(r,o)=>m(r,"name",{value:o,configurable:!0});import{R as p}from"../packem_shared/constants-CDcaCZKC.js";import f from"../packem_shared/LRUCache-Bjo6gsbC.js";import{splitByCase as u}from"./split-by-case.js";import{a as h}from"../packem_shared/generate-cache-key-DPByFaMH.js";import A from"../packem_shared/joinSegments-DTGeJBZG.js";import{l as d}from"../packem_shared/normalize-german-eszett-4k1qRtEP.js";var C=Object.defineProperty,b=l((r,o)=>C(r,"name",{value:o,configurable:!0}),"o");const j=new f(1e3),S=b((r,o)=>{if(typeof r!="string")return"";const a=o?.cache??!1,s=o?.cacheStore??j;let e;if(a&&(e=h(r,o)),a&&e&&s.has(e))return s.get(e);const c=u(r,{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&&p.test(t))return t;if(o?.toUpperCase)return o.locale?t.toLocaleUpperCase(o.locale):t.toUpperCase();const i=o?.locale?.startsWith("de")?d(t):t;return o?.locale?i.toLocaleLowerCase(o.locale):i.toLowerCase()}),n=A(c,o?.joiner??"-");return a&&e&&s.set(e,n),n},"kebabCase");export{S as kebabCase};
1
+ import { R as RE_FAST_ANSI } from '../packem_shared/constants-CTzC6Gjg.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-CuU8RGpP.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 +1,9 @@
1
- var l=Object.defineProperty;var a=(e,o)=>l(e,"name",{value:o,configurable:!0});var t=Object.defineProperty,r=a((e,o)=>t(e,"name",{value:o,configurable:!0}),"s");const c=r((e,o)=>typeof e!="string"||e===""?"":(o?.locale?e[0].toLocaleLowerCase(o.locale):e[0].toLowerCase())+e.slice(1),"lowerFirst");export{c as default};
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 +1,7 @@
1
- var a=Object.defineProperty;var o=(e,r)=>a(e,"name",{value:r,configurable:!0});import t from"../packem_shared/LRUCache-Bjo6gsbC.js";import{kebabCase as n}from"./kebab-case.js";var i=Object.defineProperty,s=o((e,r)=>i(e,"name",{value:r,configurable:!0}),"o");const c=new t(1e3),p=s((e,r)=>n(e,{cacheStore:c,...r,joiner:" "}),"noCase");export{p as default};
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 +1,48 @@
1
- var m=Object.defineProperty;var s=(r,o)=>m(r,"name",{value:o,configurable:!0});import{R as c}from"../packem_shared/constants-CDcaCZKC.js";import p from"../packem_shared/LRUCache-Bjo6gsbC.js";import{splitByCase as f}from"./split-by-case.js";import u from"./upper-first.js";import{a as A}from"../packem_shared/generate-cache-key-DPByFaMH.js";import d from"../packem_shared/joinSegments-DTGeJBZG.js";import{l as h}from"../packem_shared/normalize-german-eszett-4k1qRtEP.js";var j=Object.defineProperty,w=s((r,o)=>j(r,"name",{value:o,configurable:!0}),"i");const y=new p(1e3),z=w((r,o)=>{if(typeof r!="string"||!r)return"";const e=o?.cache??!1,n=o?.cacheStore??y;let t;if(e&&(t=A(r,o)),e&&t&&n.has(t))return n.get(t);const i=d(f(r,{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(a=>{if(o?.handleAnsi&&c.test(a))return a;const l=o?.locale?.startsWith("de")?h(a):a;return u(o?.locale?l.toLocaleLowerCase(o.locale):l.toLowerCase(),{locale:o?.locale})}),"");return e&&t&&n.set(t,i),i},"pascalCase");export{z as default};
1
+ import { R as RE_FAST_ANSI } from '../packem_shared/constants-CTzC6Gjg.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-CuU8RGpP.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 +1,28 @@
1
- var f=Object.defineProperty;var n=(r,e)=>f(r,"name",{value:e,configurable:!0});import l from"../packem_shared/LRUCache-Bjo6gsbC.js";import m from"./no-case.js";import p from"./upper-first.js";import{a as s}from"../packem_shared/generate-cache-key-DPByFaMH.js";var u=Object.defineProperty,h=n((r,e)=>u(r,"name",{value:e,configurable:!0}),"n");const g=new l(1e3),S=h((r,e)=>{if(typeof r!="string")return"";const a=e?.cache??!1,o=e?.cacheStore??g;let t;if(a&&(t=s(r,e)),a&&t&&o.has(t))return o.get(t);const c=m(r,{...e,cache:!1}).split(" ").map(i=>p(i,{locale:e?.locale})).join("_");return a&&t&&o.set(t,c),c},"pascalSnakeCase");export{S as default};
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 +1,7 @@
1
- var o=Object.defineProperty;var r=(e,a)=>o(e,"name",{value:a,configurable:!0});import t from"../packem_shared/LRUCache-Bjo6gsbC.js";import{kebabCase as n}from"./kebab-case.js";var i=Object.defineProperty,s=r((e,a)=>i(e,"name",{value:a,configurable:!0}),"a");const c=new t(1e3),b=s((e,a)=>n(e,{cacheStore:c,...a,joiner:"/"}),"pathCase");export{b as default};
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 +1,54 @@
1
- var m=Object.defineProperty;var n=(a,o)=>m(a,"name",{value:o,configurable:!0});import{R as c}from"../packem_shared/constants-CDcaCZKC.js";import p from"../packem_shared/LRUCache-Bjo6gsbC.js";import{splitByCase as f}from"./split-by-case.js";import A from"./upper-first.js";import{a as d}from"../packem_shared/generate-cache-key-DPByFaMH.js";import h from"../packem_shared/joinSegments-DTGeJBZG.js";import{l as u}from"../packem_shared/normalize-german-eszett-4k1qRtEP.js";var j=Object.defineProperty,w=n((a,o)=>j(a,"name",{value:o,configurable:!0}),"m");const y=new p(1e3),k=w((a,o)=>{if(typeof a!="string")return"";const s=o?.cache??!1,i=o?.cacheStore??y;let e;if(s&&(e=d(a,o)),s&&e&&i.has(e))return i.get(e);let t=!0;const l=h(f(a,{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(r=>o?.handleAnsi&&c.test(r)?r:(r=o?.locale?.startsWith("de")?u(r):r,r=o?.locale?r.toLocaleLowerCase(o.locale):r.toLowerCase(),t?(t=!1,A(r,o)):r))," ");return s&&e&&i.set(e,l),l},"sentenceCase");export{k as default};
1
+ import { R as RE_FAST_ANSI } from '../packem_shared/constants-CTzC6Gjg.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-CuU8RGpP.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 +1,7 @@
1
- var o=Object.defineProperty;var a=(e,r)=>o(e,"name",{value:r,configurable:!0});import t from"../packem_shared/LRUCache-Bjo6gsbC.js";import{kebabCase as n}from"./kebab-case.js";var i=Object.defineProperty,s=a((e,r)=>i(e,"name",{value:r,configurable:!0}),"t");const c=new t(1e3),p=s((e,r)=>n(e,{cacheStore:c,...r,joiner:"_"}),"snakeCase");export{p as default};
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 };