@visulima/string 3.0.0-alpha.11 → 3.0.0-alpha.13
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.
- package/CHANGELOG.md +28 -0
- package/LICENSE.md +68 -3
- package/dist/align-text.d.ts +35 -0
- package/dist/align-text.js +2 -34
- package/dist/case/camel-case.d.ts +17 -2
- package/dist/case/camel-case.js +1 -55
- package/dist/case/capital-case.d.ts +14 -2
- package/dist/case/capital-case.js +1 -47
- package/dist/case/constant-case.d.ts +14 -2
- package/dist/case/constant-case.js +1 -7
- package/dist/case/dot-case.d.ts +14 -2
- package/dist/case/dot-case.js +1 -7
- package/dist/case/flat-case.d.ts +12 -2
- package/dist/case/flat-case.js +1 -7
- package/dist/case/flip-case.d.ts +16 -2
- package/dist/case/flip-case.js +1 -82
- package/dist/case/identify-case.d.ts +15 -2
- package/dist/case/identify-case.js +1 -66
- package/dist/case/index.d.ts +8 -2
- package/dist/case/index.js +1 -20
- package/dist/case/kebab-case.d.ts +25 -2
- package/dist/case/kebab-case.js +1 -55
- package/dist/case/lower-first.d.ts +13 -2
- package/dist/case/lower-first.js +1 -9
- package/dist/case/no-case.d.ts +14 -2
- package/dist/case/no-case.js +1 -7
- package/dist/case/pascal-case.d.ts +17 -2
- package/dist/case/pascal-case.js +1 -48
- package/dist/case/pascal-snake-case.d.ts +14 -2
- package/dist/case/pascal-snake-case.js +1 -28
- package/dist/case/path-case.d.ts +14 -2
- package/dist/case/path-case.js +1 -7
- package/dist/case/sentence-case.d.ts +14 -2
- package/dist/case/sentence-case.js +1 -54
- package/dist/case/snake-case.d.ts +14 -2
- package/dist/case/snake-case.js +1 -7
- package/dist/case/split-by-case.d.ts +29 -2
- package/dist/case/split-by-case.js +1 -763
- package/dist/case/title-case.d.ts +12 -2
- package/dist/case/title-case.js +1 -40
- package/dist/case/train-case.d.ts +14 -2
- package/dist/case/train-case.js +1 -40
- package/dist/case/upper-first.d.ts +13 -2
- package/dist/case/upper-first.js +1 -9
- package/dist/closest-string.d.ts +32 -0
- package/dist/closest-string.js +1 -22
- package/dist/compare-similarity.d.ts +38 -1
- package/dist/compare-similarity.js +1 -12
- package/dist/get-string-truncated-width.d.ts +151 -0
- package/dist/get-string-truncated-width.js +1 -332
- package/dist/get-string-width.d.ts +58 -0
- package/dist/get-string-width.js +1 -5
- package/dist/index.d.ts +194 -9
- package/dist/index.js +1 -44
- package/dist/native-string-types.d.ts +239 -0
- package/dist/outdent.d.ts +74 -0
- package/dist/outdent.js +1 -109
- package/dist/packem_shared/LRUCache-Bjo6gsbC.js +1 -0
- package/dist/packem_shared/closest-uarbVSbs.js +1 -0
- package/dist/packem_shared/closestN-Vd5oNJy_.js +1 -0
- package/dist/packem_shared/constants-DmzZF6_u.js +1 -0
- package/dist/packem_shared/countOccurrences-DIHSCdcG.js +1 -0
- package/dist/packem_shared/direction-dtczwUOE.js +1 -0
- package/dist/packem_shared/eastAsianWidthType-lcBsj7vg.js +1 -0
- package/dist/packem_shared/excerpt-DhV2yoHG.js +54 -0
- package/dist/packem_shared/generate-cache-key-DPByFaMH.js +1 -0
- package/dist/packem_shared/indent-CDlPQmpe.js +1 -0
- package/dist/packem_shared/isFullwidthCodePoint-Dmsf2-5L.js +1 -0
- package/dist/packem_shared/joinSegments-D27SxoCV.js +1 -0
- package/dist/packem_shared/lookup-ChWuUpyb.js +1 -0
- package/dist/packem_shared/normalize-german-eszett-AKfdw2MZ.js +1 -0
- package/dist/packem_shared/redent-BECVOaZp.js +1 -0
- package/dist/packem_shared/replaceString-aq-C7Wor.js +1 -0
- package/dist/packem_shared/stripIndent-Dt8hSxVM.js +1 -0
- package/dist/packem_shared/transliterate-D1p1yYE7.js +5 -0
- package/dist/packem_shared/types.d-FOLSY2Tc.d.ts +392 -0
- package/dist/packem_shared/types.d-NJ4vcG-A.d.ts +346 -0
- package/dist/slice.d.ts +42 -0
- package/dist/slice.js +1 -415
- package/dist/slugify.d.ts +10 -1
- package/dist/slugify.js +1 -46
- package/dist/test/utils.d.ts +17 -0
- package/dist/test/utils.js +13 -88
- package/dist/test/vitest.d.ts +3 -0
- package/dist/test/vitest.js +1 -5
- package/dist/truncate.d.ts +43 -0
- package/dist/truncate.js +1 -112
- package/dist/utilities.d.ts +28 -1
- package/dist/utilities.js +1 -52
- package/dist/word-similarity-sort.d.ts +34 -0
- package/dist/word-similarity-sort.js +1 -22
- package/dist/word-wrap.d.ts +44 -0
- package/dist/word-wrap.js +8 -639
- package/package.json +46 -46
- package/dist/packem_shared/LRUCache-3r3SovvR.js +0 -46
- package/dist/packem_shared/closest-IHuSvnSn.js +0 -139
- package/dist/packem_shared/closestN-DUsjgiXb.js +0 -25
- package/dist/packem_shared/constants-BsZS5f0z.js +0 -95
- package/dist/packem_shared/countOccurrences-CS9XprQN.js +0 -22
- package/dist/packem_shared/direction-C9gfWWTK.js +0 -16
- package/dist/packem_shared/eastAsianWidthType-SD3YniiT.js +0 -20
- package/dist/packem_shared/excerpt-COsVNttN.js +0 -1502
- package/dist/packem_shared/generate-cache-key-DdayDfjV.js +0 -6
- package/dist/packem_shared/indent-D3DSCa6s.js +0 -33
- package/dist/packem_shared/isFullwidthCodePoint-IFXZxNjq.js +0 -10
- package/dist/packem_shared/joinSegments-CvxSgKz0.js +0 -44
- package/dist/packem_shared/lookup-BE8lEqy4.js +0 -104
- package/dist/packem_shared/normalize-german-eszett-4p3yKEzn.js +0 -8
- package/dist/packem_shared/redent-DSb1IJWn.js +0 -8
- package/dist/packem_shared/replaceString-Ce8X2ZQ-.js +0 -192
- package/dist/packem_shared/stripIndent-D_TRjxZ_.js +0 -20
- package/dist/packem_shared/transliterate-CKt9VK7D.js +0 -47756
- package/dist/packem_shared/types.d-BVNv675q.d.ts +0 -61
- package/dist/packem_shared/types.d-DfgbcNKh.d.ts +0 -57
package/dist/case/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type N as NodeLocale } from "../packem_shared/types.d-
|
|
1
|
+
export { type N as NodeLocale } from "../packem_shared/types.d-NJ4vcG-A.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,14 @@ 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-
|
|
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-FOLSY2Tc.js";
|
|
21
21
|
export { default as upperFirst } from "./upper-first.js";
|
|
22
22
|
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
23
|
+
/**
|
|
24
|
+
* Joins segments with a joiner, handling ANSI sequences and emojis correctly.
|
|
25
|
+
* @param segments Array of segments to join
|
|
26
|
+
* @param joiner String used to join segments together
|
|
27
|
+
* @returns Joined string with proper handling of ANSI and emoji sequences
|
|
28
|
+
*/
|
|
23
29
|
declare const joinSegments: (segments: string[], joiner: string) => string;
|
|
24
30
|
export { joinSegments };
|
package/dist/case/index.js
CHANGED
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
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-CvxSgKz0.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-D27SxoCV.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,32 @@
|
|
|
1
|
-
import { C as CaseOptions, K as KebabCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, K as KebabCase } from "../packem_shared/types.d-FOLSY2Tc.js";
|
|
2
|
+
import "../packem_shared/types.d-NJ4vcG-A.js";
|
|
3
3
|
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
4
4
|
interface KebabCaseOptions extends CaseOptions {
|
|
5
|
+
/**
|
|
6
|
+
* String used to join words together in kebab case format.
|
|
7
|
+
* @default "-"
|
|
8
|
+
*/
|
|
5
9
|
joiner?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to convert the result to uppercase.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
6
14
|
toUpperCase?: boolean;
|
|
7
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Converts a string to kebab-case.
|
|
18
|
+
* @param value The string to convert to kebab-case.
|
|
19
|
+
* @param options Configuration options for kebab-case conversion.
|
|
20
|
+
* @returns The converted kebab-case string.
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* kebabCase("fooBar") // => "foo-bar"
|
|
24
|
+
* kebabCase("foo bar") // => "foo-bar"
|
|
25
|
+
* kebabCase("foo_bar") // => "foo-bar"
|
|
26
|
+
* kebabCase("XMLHttpRequest") // => "xml-http-request"
|
|
27
|
+
* kebabCase("AJAXRequest") // => "ajax-request"
|
|
28
|
+
* kebabCase("QueryXML123String") // => "query-xml-123-string"
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
8
31
|
declare const kebabCase: <T extends string = string>(value?: T, options?: KebabCaseOptions) => KebabCase<T>;
|
|
9
32
|
export { KebabCaseOptions, kebabCase };
|
package/dist/case/kebab-case.js
CHANGED
|
@@ -1,55 +1 @@
|
|
|
1
|
-
|
|
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-CvxSgKz0.js';
|
|
6
|
-
import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-4p3yKEzn.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
|
+
var m=Object.defineProperty;var l=(r,o)=>m(r,"name",{value:o,configurable:!0});import{R as p}from"../packem_shared/constants-DmzZF6_u.js";import f from"../packem_shared/LRUCache-Bjo6gsbC.js";import{splitByCase as h}from"./split-by-case.js";import{a as u}from"../packem_shared/generate-cache-key-DPByFaMH.js";import A from"../packem_shared/joinSegments-D27SxoCV.js";import{l as d}from"../packem_shared/normalize-german-eszett-AKfdw2MZ.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 s=o?.cache??!1,a=o?.cacheStore??j;let e;if(s&&(e=u(r,o)),s&&e&&a.has(e))return a.get(e);const c=h(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 s&&e&&a.set(e,n),n},"kebabCase");export{S as kebabCase};
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import { L as LocaleOptions, e as LowerFirst } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { L as LocaleOptions, e as LowerFirst } from "../packem_shared/types.d-FOLSY2Tc.js";
|
|
2
|
+
import "../packem_shared/types.d-NJ4vcG-A.js";
|
|
3
3
|
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
4
|
+
/**
|
|
5
|
+
* Converts first character to lower case.
|
|
6
|
+
* @param value The string to convert.
|
|
7
|
+
* @param options Options for case conversion.
|
|
8
|
+
* @returns The string with its first character converted to lowercase.
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* lowerFirst("Hello world!") // => "hello world!"
|
|
12
|
+
* lowerFirst("İSTANBUL", { locale: "tr" }) // => "istanbul"
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
4
15
|
declare const lowerFirst: <T extends string = string>(value?: T, options?: LocaleOptions) => LowerFirst<T>;
|
|
5
16
|
export { lowerFirst as default };
|
package/dist/case/lower-first.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
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
|
+
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};
|
package/dist/case/no-case.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import { C as CaseOptions, N as NoCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, N as NoCase } from "../packem_shared/types.d-FOLSY2Tc.js";
|
|
2
|
+
import "../packem_shared/types.d-NJ4vcG-A.js";
|
|
3
3
|
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
4
|
+
/**
|
|
5
|
+
* Converts a string to no case (space separated words).
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* noCase("foo bar") // => "foo bar"
|
|
9
|
+
* noCase("foo-bar") // => "foo bar"
|
|
10
|
+
* noCase("foo_bar") // => "foo bar"
|
|
11
|
+
* noCase("XMLHttpRequest") // => "xml http request"
|
|
12
|
+
* noCase("AJAXRequest") // => "ajax request"
|
|
13
|
+
* noCase("QueryXML123String") // => "query xml 123 string"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
4
16
|
declare const noCase: <T extends string = string>(value?: T, options?: CaseOptions) => NoCase<T>;
|
|
5
17
|
export { noCase as default };
|
package/dist/case/no-case.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
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
|
+
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,5 +1,20 @@
|
|
|
1
|
-
import { C as CaseOptions, P as PascalCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, P as PascalCase } from "../packem_shared/types.d-FOLSY2Tc.js";
|
|
2
|
+
import "../packem_shared/types.d-NJ4vcG-A.js";
|
|
3
3
|
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
4
|
+
/**
|
|
5
|
+
* Converts a string to PascalCase.
|
|
6
|
+
* @param value The string to convert.
|
|
7
|
+
* @param options Options for case conversion.
|
|
8
|
+
* @returns The string in PascalCase.
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* pascalCase('foo bar') // 'FooBar'
|
|
12
|
+
* pascalCase('foo-bar') // 'FooBar'
|
|
13
|
+
* pascalCase('foo_bar') // 'FooBar'
|
|
14
|
+
* pascalCase('XMLHttpRequest') // 'XmlHttpRequest'
|
|
15
|
+
* pascalCase('AJAXRequest') // 'AjaxRequest'
|
|
16
|
+
* pascalCase('QueryXML123String') // 'QueryXml123String'
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
4
19
|
declare const pascalCase: <T extends string = string>(value?: T, options?: CaseOptions) => PascalCase<T>;
|
|
5
20
|
export { pascalCase as default };
|
package/dist/case/pascal-case.js
CHANGED
|
@@ -1,48 +1 @@
|
|
|
1
|
-
|
|
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-CvxSgKz0.js';
|
|
7
|
-
import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-4p3yKEzn.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
|
+
var m=Object.defineProperty;var l=(r,o)=>m(r,"name",{value:o,configurable:!0});import{R as c}from"../packem_shared/constants-DmzZF6_u.js";import p from"../packem_shared/LRUCache-Bjo6gsbC.js";import{splitByCase as f}from"./split-by-case.js";import h from"./upper-first.js";import{a as u}from"../packem_shared/generate-cache-key-DPByFaMH.js";import A from"../packem_shared/joinSegments-D27SxoCV.js";import{l as d}from"../packem_shared/normalize-german-eszett-AKfdw2MZ.js";var j=Object.defineProperty,w=l((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,s=o?.cacheStore??y;let a;if(e&&(a=u(r,o)),e&&a&&s.has(a))return s.get(a);const n=A(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(t=>{if(o?.handleAnsi&&c.test(t))return t;const i=o?.locale?.startsWith("de")?d(t):t;return h(o?.locale?i.toLocaleLowerCase(o.locale):i.toLowerCase(),{locale:o?.locale})}),"");return e&&a&&s.set(a,n),n},"pascalCase");export{z as default};
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import { C as CaseOptions, f as PascalSnakeCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, f as PascalSnakeCase } from "../packem_shared/types.d-FOLSY2Tc.js";
|
|
2
|
+
import "../packem_shared/types.d-NJ4vcG-A.js";
|
|
3
3
|
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
4
|
+
/**
|
|
5
|
+
* Converts a string to Pascal_Snake_Case.
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* pascalSnakeCase("foo bar") // => "Foo_Bar"
|
|
9
|
+
* pascalSnakeCase("foo-bar") // => "Foo_Bar"
|
|
10
|
+
* pascalSnakeCase("foo_bar") // => "Foo_Bar"
|
|
11
|
+
* pascalSnakeCase("XMLHttpRequest") // => "Xml_Http_Request"
|
|
12
|
+
* pascalSnakeCase("AJAXRequest") // => "Ajax_Request"
|
|
13
|
+
* pascalSnakeCase("QueryXML123String") // => "Query_Xml_123_String"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
4
16
|
declare const pascalSnakeCase: <T extends string = string>(value?: T, options?: CaseOptions) => PascalSnakeCase<T>;
|
|
5
17
|
export { pascalSnakeCase as default };
|
|
@@ -1,28 +1 @@
|
|
|
1
|
-
import LRUCache from
|
|
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
|
+
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};
|
package/dist/case/path-case.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import { C as CaseOptions, g as PathCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, g as PathCase } from "../packem_shared/types.d-FOLSY2Tc.js";
|
|
2
|
+
import "../packem_shared/types.d-NJ4vcG-A.js";
|
|
3
3
|
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
4
|
+
/**
|
|
5
|
+
* Converts a string to path/case.
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* pathCase("foo bar") // => "foo/bar"
|
|
9
|
+
* pathCase("foo-bar") // => "foo/bar"
|
|
10
|
+
* pathCase("foo_bar") // => "foo/bar"
|
|
11
|
+
* pathCase("XMLHttpRequest") // => "xml/http/request"
|
|
12
|
+
* pathCase("AJAXRequest") // => "ajax/request"
|
|
13
|
+
* pathCase("QueryXML123String") // => "query/xml/123/string"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
4
16
|
declare const pathCase: <T extends string = string>(value?: T, options?: CaseOptions) => PathCase<T>;
|
|
5
17
|
export { pathCase as default };
|
package/dist/case/path-case.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
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
|
+
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,5 +1,17 @@
|
|
|
1
|
-
import { C as CaseOptions, S as SentenceCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, S as SentenceCase } from "../packem_shared/types.d-FOLSY2Tc.js";
|
|
2
|
+
import "../packem_shared/types.d-NJ4vcG-A.js";
|
|
3
3
|
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
4
|
+
/**
|
|
5
|
+
* Converts a string to Sentence case.
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* sentenceCase("foo bar") // => "Foo bar"
|
|
9
|
+
* sentenceCase("foo-bar") // => "Foo bar"
|
|
10
|
+
* sentenceCase("foo_bar") // => "Foo bar"
|
|
11
|
+
* sentenceCase("XMLHttpRequest") // => "Xml http request"
|
|
12
|
+
* sentenceCase("AJAXRequest") // => "Ajax request"
|
|
13
|
+
* sentenceCase("QueryXML123String") // => "Query xml 123 string"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
4
16
|
declare const sentenceCase: <T extends string = string>(value?: T, options?: CaseOptions) => SentenceCase<T>;
|
|
5
17
|
export { sentenceCase as default };
|
|
@@ -1,54 +1 @@
|
|
|
1
|
-
|
|
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-CvxSgKz0.js';
|
|
7
|
-
import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-4p3yKEzn.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
|
-
const normalized = options?.locale?.startsWith("de") ? normalizeGermanEszett(word) : word;
|
|
39
|
-
const lowered = options?.locale ? normalized.toLocaleLowerCase(options.locale) : normalized.toLowerCase();
|
|
40
|
-
if (firstWord) {
|
|
41
|
-
firstWord = false;
|
|
42
|
-
return upperFirst(lowered, options);
|
|
43
|
-
}
|
|
44
|
-
return lowered;
|
|
45
|
-
}),
|
|
46
|
-
" "
|
|
47
|
-
);
|
|
48
|
-
if (shouldCache && cacheKey) {
|
|
49
|
-
cacheStore.set(cacheKey, result);
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export { sentenceCase as default };
|
|
1
|
+
var p=Object.defineProperty;var c=(o,r)=>p(o,"name",{value:r,configurable:!0});import{R as f}from"../packem_shared/constants-DmzZF6_u.js";import h 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 y from"../packem_shared/joinSegments-D27SxoCV.js";import{l as j}from"../packem_shared/normalize-german-eszett-AKfdw2MZ.js";var w=Object.defineProperty,E=c((o,r)=>w(o,"name",{value:r,configurable:!0}),"o");const v=new h(1e3),_=E((o,r)=>{if(typeof o!="string")return"";const a=r?.cache??!1,s=r?.cacheStore??v;let t;if(a&&(t=d(o,r)),a&&t&&s.has(t))return s.get(t);let i=!0;const n=y(u(o,{handleAnsi:r?.handleAnsi,handleEmoji:r?.handleEmoji,knownAcronyms:r?.knownAcronyms,locale:r?.locale,normalize:r?.normalize,separators:void 0,stripAnsi:r?.stripAnsi,stripEmoji:r?.stripEmoji}).map(e=>{if(r?.handleAnsi&&f.test(e))return e;const l=r?.locale?.startsWith("de")?j(e):e,m=r?.locale?l.toLocaleLowerCase(r.locale):l.toLowerCase();return i?(i=!1,A(m,r)):m})," ");return a&&t&&s.set(t,n),n},"sentenceCase");export{_ as default};
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import { C as CaseOptions, h as SnakeCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, h as SnakeCase } from "../packem_shared/types.d-FOLSY2Tc.js";
|
|
2
|
+
import "../packem_shared/types.d-NJ4vcG-A.js";
|
|
3
3
|
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
4
|
+
/**
|
|
5
|
+
* Converts a string to snake_case.
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* snakeCase("fooBar") // => "foo_bar"
|
|
9
|
+
* snakeCase("foo bar") // => "foo_bar"
|
|
10
|
+
* snakeCase("foo-bar") // => "foo_bar"
|
|
11
|
+
* snakeCase("XMLHttpRequest") // => "xml_http_request"
|
|
12
|
+
* snakeCase("AJAXRequest") // => "ajax_request"
|
|
13
|
+
* snakeCase("QueryXML123String") // => "query_xml_123_string"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
4
16
|
declare const snakeCase: <T extends string = string>(value?: T, options?: CaseOptions) => SnakeCase<T>;
|
|
5
17
|
export { snakeCase as default };
|
package/dist/case/snake-case.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
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
|
+
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 s=Object.defineProperty,i=a((e,r)=>s(e,"name",{value:r,configurable:!0}),"s");const c=new t(1e3),p=i((e,r)=>n(e,{cacheStore:c,...r,joiner:"_"}),"snakeCase");export{p as default};
|
|
@@ -1,14 +1,41 @@
|
|
|
1
|
-
import { L as LocaleOptions, i as SplitByCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { L as LocaleOptions, i as SplitByCase } from "../packem_shared/types.d-FOLSY2Tc.js";
|
|
2
|
+
import "../packem_shared/types.d-NJ4vcG-A.js";
|
|
3
3
|
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
4
|
+
/** Options for the `splitByCase` function. */
|
|
4
5
|
interface SplitOptions extends LocaleOptions {
|
|
6
|
+
/** Whether to handle ANSI escape sequences. (default: false) */
|
|
5
7
|
handleAnsi?: boolean;
|
|
8
|
+
/** Whether to handle emoji sequences. (default: false) */
|
|
6
9
|
handleEmoji?: boolean;
|
|
10
|
+
/** A list of known acronyms to preserve casing for. */
|
|
7
11
|
knownAcronyms?: ReadonlyArray<string>;
|
|
12
|
+
/** Whether to normalize case (convert all‑upper tokens not in knownAcronyms to title case). */
|
|
8
13
|
normalize?: boolean;
|
|
14
|
+
/** List of additional separators to split on. */
|
|
9
15
|
separators?: ReadonlyArray<string> | RegExp;
|
|
16
|
+
/** Whether to strip ANSI escape sequences. (default: false) */
|
|
10
17
|
stripAnsi?: boolean;
|
|
18
|
+
/** Whether to strip emoji sequences. (default: false) */
|
|
11
19
|
stripEmoji?: boolean;
|
|
12
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Splits a string into segments based on various criteria including case changes,
|
|
23
|
+
* separators, Unicode scripts, ANSI codes, and emojis.
|
|
24
|
+
*
|
|
25
|
+
* This is the core splitting logic used by various case conversion functions.
|
|
26
|
+
* @template T - The specific literal type of the input string, if known.
|
|
27
|
+
* @param input The string to split.
|
|
28
|
+
* @param options Configuration options for splitting behavior.
|
|
29
|
+
* @returns An array of string segments.
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* splitByCase("fooBarBaz") // => ["foo", "Bar", "Baz"]
|
|
33
|
+
* splitByCase("foo_bar-baz") // => ["foo", "bar", "baz"]
|
|
34
|
+
* splitByCase("HTMLElement") // => ["HTML", "Element"]
|
|
35
|
+
* splitByCase("HTMLElement", { knownAcronyms: ["HTML"] }) // => ["HTML", "Element"]
|
|
36
|
+
* splitByCase("\u001B[31mhello\u001B[0mWorld", { handleAnsi: true }) // => ["\u001B[31m", "hello", "\u001B[0m", "World"]
|
|
37
|
+
* splitByCase("hello🌍world", { handleEmoji: true }) // => ["hello", "🌍", "world"]
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
13
40
|
declare const splitByCase: <T extends string = string>(input: T, options?: SplitOptions) => SplitByCase<T>;
|
|
14
41
|
export { SplitOptions, splitByCase };
|