@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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## @visulima/string [3.0.0-alpha.13](https://github.com/visulima/visulima/compare/@visulima/string@3.0.0-alpha.12...@visulima/string@3.0.0-alpha.13) (2026-05-10)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **string:** use case aggregator export and drop invalid slice case ([cefe2c7](https://github.com/visulima/visulima/commit/cefe2c776eae495c0fead9214ced7e52e95e6a56))
|
|
6
|
+
|
|
7
|
+
### Documentation
|
|
8
|
+
|
|
9
|
+
* **string:** match per-file case subpath imports to actual exports ([1091367](https://github.com/visulima/visulima/commit/109136726458d682a9d6c276e0ce63d8fb35cf0c))
|
|
10
|
+
|
|
11
|
+
## @visulima/string [3.0.0-alpha.12](https://github.com/visulima/visulima/compare/@visulima/string@3.0.0-alpha.11...@visulima/string@3.0.0-alpha.12) (2026-05-07)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **string:** repair broken bench imports ([f077356](https://github.com/visulima/visulima/commit/f077356139dc4745c59ac286f5a0681918fbb366))
|
|
16
|
+
|
|
17
|
+
### Miscellaneous Chores
|
|
18
|
+
|
|
19
|
+
* re-sort workspace package.json files via vis sort-package-json ([f625696](https://github.com/visulima/visulima/commit/f625696cfac974325774b3243e1a83c3d23acbd7))
|
|
20
|
+
* simplify pnpm-workspace packages list ([7cab221](https://github.com/visulima/visulima/commit/7cab221163632d9b7aa044a6f88c49083103a869))
|
|
21
|
+
* **string:** apply prettier and eslint quote-style auto-fix ([db1d161](https://github.com/visulima/visulima/commit/db1d1615c7614fb537d53c458bdef3c38c6aab98))
|
|
22
|
+
* **string:** housekeeping cleanup ([ecb3058](https://github.com/visulima/visulima/commit/ecb3058b68c2ffae62d9b1d685fe606a605861cd))
|
|
23
|
+
* **string:** upgrade packem to 2.0.0-alpha.76 ([bcac381](https://github.com/visulima/visulima/commit/bcac381ead9c22befbc54cbd7ad67764e22140af))
|
|
24
|
+
|
|
25
|
+
### Continuous Integration
|
|
26
|
+
|
|
27
|
+
* integrate codspeed for benchmark tracking ([e758f3d](https://github.com/visulima/visulima/commit/e758f3da491cc00d3f8bbf10d7ba3fdf8deb5325))
|
|
28
|
+
|
|
1
29
|
## @visulima/string [3.0.0-alpha.11](https://github.com/visulima/visulima/compare/@visulima/string@3.0.0-alpha.10...@visulima/string@3.0.0-alpha.11) (2026-04-22)
|
|
2
30
|
|
|
3
31
|
### Bug Fixes
|
package/LICENSE.md
CHANGED
|
@@ -530,14 +530,11 @@ Repository: https://github.com/alexreardon/tiny-invariant.git
|
|
|
530
530
|
<!-- TYPE_DEPENDENCIES -->
|
|
531
531
|
|
|
532
532
|
# Licenses of bundled types
|
|
533
|
-
|
|
534
533
|
The published @visulima/string artifact additionally contains code with the following licenses:
|
|
535
534
|
MIT
|
|
536
535
|
|
|
537
536
|
# Bundled types:
|
|
538
|
-
|
|
539
537
|
## fastest-levenshtein
|
|
540
|
-
|
|
541
538
|
License: MIT
|
|
542
539
|
By: Kasper U. Weihe
|
|
543
540
|
Repository: git+https://github.com/ka-weihe/fastest-levenshtein.git
|
|
@@ -564,4 +561,72 @@ Repository: git+https://github.com/ka-weihe/fastest-levenshtein.git
|
|
|
564
561
|
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
565
562
|
> SOFTWARE.
|
|
566
563
|
|
|
564
|
+
---------------------------------------
|
|
565
|
+
|
|
566
|
+
## get-east-asian-width
|
|
567
|
+
License: MIT
|
|
568
|
+
By: Sindre Sorhus
|
|
569
|
+
Repository: sindresorhus/get-east-asian-width
|
|
570
|
+
|
|
571
|
+
> MIT License
|
|
572
|
+
>
|
|
573
|
+
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
574
|
+
>
|
|
575
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
576
|
+
>
|
|
577
|
+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
578
|
+
>
|
|
579
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
580
|
+
|
|
581
|
+
---------------------------------------
|
|
582
|
+
|
|
583
|
+
## indent-string
|
|
584
|
+
License: MIT
|
|
585
|
+
By: Sindre Sorhus
|
|
586
|
+
Repository: sindresorhus/indent-string
|
|
587
|
+
|
|
588
|
+
> MIT License
|
|
589
|
+
>
|
|
590
|
+
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
591
|
+
>
|
|
592
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
593
|
+
>
|
|
594
|
+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
595
|
+
>
|
|
596
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
597
|
+
|
|
598
|
+
---------------------------------------
|
|
599
|
+
|
|
600
|
+
## redent
|
|
601
|
+
License: MIT
|
|
602
|
+
By: Sindre Sorhus
|
|
603
|
+
Repository: sindresorhus/redent
|
|
604
|
+
|
|
605
|
+
> MIT License
|
|
606
|
+
>
|
|
607
|
+
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
608
|
+
>
|
|
609
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
610
|
+
>
|
|
611
|
+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
612
|
+
>
|
|
613
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
614
|
+
|
|
615
|
+
---------------------------------------
|
|
616
|
+
|
|
617
|
+
## strip-indent
|
|
618
|
+
License: MIT
|
|
619
|
+
By: Sindre Sorhus
|
|
620
|
+
Repository: sindresorhus/strip-indent
|
|
621
|
+
|
|
622
|
+
> MIT License
|
|
623
|
+
>
|
|
624
|
+
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
625
|
+
>
|
|
626
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
627
|
+
>
|
|
628
|
+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
629
|
+
>
|
|
630
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
631
|
+
|
|
567
632
|
<!-- /TYPE_DEPENDENCIES -->
|
package/dist/align-text.d.ts
CHANGED
|
@@ -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 };
|
package/dist/align-text.js
CHANGED
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
|
|
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
|
-
let lines;
|
|
15
|
-
if (Array.isArray(text)) {
|
|
16
|
-
lines = text;
|
|
17
|
-
} else {
|
|
18
|
-
returnString = true;
|
|
19
|
-
lines = text.split(split);
|
|
20
|
-
}
|
|
21
|
-
let width;
|
|
22
|
-
let maxWidth = 0;
|
|
23
|
-
const result = lines.map((input) => {
|
|
24
|
-
width = getStringWidth(input, options.stringWidthOptions);
|
|
25
|
-
maxWidth = Math.max(width, maxWidth);
|
|
26
|
-
return {
|
|
27
|
-
str: input,
|
|
28
|
-
width
|
|
29
|
-
};
|
|
30
|
-
}).map((object) => Array.from({ length: widthDiffFunction(maxWidth, object.width) + 1 }).join(pad) + object.str);
|
|
31
|
-
return returnString ? result.join(split) : result;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { alignText };
|
|
1
|
+
var m=Object.defineProperty;var h=(t,r)=>m(t,"name",{value:r,configurable:!0});import{getStringWidth as d}from"./get-string-width.js";var u=Object.defineProperty,l=h((t,r)=>u(t,"name",{value:r,configurable:!0}),"n");const x=l((t,r)=>Math.floor((t-r)/2),"halfDiff"),y=l((t,r)=>t-r,"fullDiff"),A=l((t,r={})=>{const o=r.align??"center";if(o==="left")return t;const f=r.split??`
|
|
2
|
+
`,p=r.pad??" ",c=o==="right"?y:x;let s=!1,n;Array.isArray(t)?n=t:(s=!0,n=t.split(f));let a,i=0;const g=n.map(e=>(a=d(e,r.stringWidthOptions),i=Math.max(a,i),{str:e,width:a})).map(e=>Array.from({length:c(i,e.width)+1}).join(p)+e.str);return s?g.join(f):g},"alignText");export{A as alignText};
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
import { C as CaseOptions, a as CamelCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, a as CamelCase } 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 camelCase.
|
|
6
|
+
* @param value The string to convert.
|
|
7
|
+
* @param options Options for case conversion.
|
|
8
|
+
* @returns The string in camelCase.
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* camelCase('foo bar') // 'fooBar'
|
|
12
|
+
* camelCase('foo-bar') // 'fooBar'
|
|
13
|
+
* camelCase('foo_bar') // 'fooBar'
|
|
14
|
+
* camelCase('XMLHttpRequest') // 'xmlHttpRequest'
|
|
15
|
+
* camelCase('AJAXRequest') // 'ajaxRequest'
|
|
16
|
+
* camelCase('QueryXML123String') // 'queryXml123String'
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
4
19
|
declare const camelCase: <T extends string = string>(value?: T, options?: CaseOptions) => CamelCase<T>;
|
|
5
20
|
export { camelCase as default };
|
package/dist/case/camel-case.js
CHANGED
|
@@ -1,55 +1 @@
|
|
|
1
|
-
|
|
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-CvxSgKz0.js';
|
|
8
|
-
import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-4p3yKEzn.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
|
-
const normalized = options?.locale?.startsWith("de") ? normalizeGermanEszett(word) : word;
|
|
40
|
-
const lowered = options?.locale ? normalized.toLocaleLowerCase(options.locale) : normalized.toLowerCase();
|
|
41
|
-
if (firstWord) {
|
|
42
|
-
firstWord = false;
|
|
43
|
-
return lowerFirst(lowered, options);
|
|
44
|
-
}
|
|
45
|
-
return upperFirst(lowered, 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
|
+
var p=Object.defineProperty;var c=(r,o)=>p(r,"name",{value:o,configurable:!0});import{R as f}from"../packem_shared/constants-DmzZF6_u.js";import h from"../packem_shared/LRUCache-Bjo6gsbC.js";import u from"./lower-first.js";import{splitByCase as d}from"./split-by-case.js";import A from"./upper-first.js";import{a as E}from"../packem_shared/generate-cache-key-DPByFaMH.js";import j from"../packem_shared/joinSegments-D27SxoCV.js";import{l as w}from"../packem_shared/normalize-german-eszett-AKfdw2MZ.js";var y=Object.defineProperty,v=c((r,o)=>y(r,"name",{value:o,configurable:!0}),"o");const C=new h(1e3),x=v((r,o)=>{if(typeof r!="string"||!r)return"";const s=o?.cache??!1,a=o?.cacheStore??C;let t;if(s&&(t=E(r,o)),s&&t&&a.has(t))return a.get(t);let i=!0;const n=j(d(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(e=>{if(o?.handleAnsi&&f.test(e))return e;const l=o?.locale?.startsWith("de")?w(e):e,m=o?.locale?l.toLocaleLowerCase(o.locale):l.toLowerCase();return i?(i=!1,u(m,o)):A(m,o)}),"");return s&&t&&a.set(t,n),n},"camelCase");export{x as default};
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import { C as CaseOptions, b as CapitalCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, b as CapitalCase } 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 Capital Case.
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* capitalCase("foo bar") // => "Foo Bar"
|
|
9
|
+
* capitalCase("foo-bar") // => "Foo Bar"
|
|
10
|
+
* capitalCase("foo_bar") // => "Foo Bar"
|
|
11
|
+
* capitalCase("XMLHttpRequest") // => "Xml Http Request"
|
|
12
|
+
* capitalCase("AJAXRequest") // => "Ajax Request"
|
|
13
|
+
* capitalCase("QueryXML123String") // => "Query Xml 123 String"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
4
16
|
declare const capitalCase: <T extends string = string>(value?: T, options?: CaseOptions) => CapitalCase<T>;
|
|
5
17
|
export { capitalCase as default };
|
|
@@ -1,47 +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 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
|
+
var c=Object.defineProperty;var l=(r,o)=>c(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 u from"./upper-first.js";import{a as A}from"../packem_shared/generate-cache-key-DPByFaMH.js";import d from"../packem_shared/joinSegments-D27SxoCV.js";import{l as y}from"../packem_shared/normalize-german-eszett-AKfdw2MZ.js";var j=Object.defineProperty,w=l((r,o)=>j(r,"name",{value:o,configurable:!0}),"l");const E=new f(1e3),R=w((r,o)=>{if(typeof r!="string")return"";const e=o?.cache??!1,s=o?.cacheStore??E;let a;if(e&&(a=A(r,o)),e&&a&&s.has(a))return s.get(a);const m=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(p.test(t))return t;const n=o?.locale?.startsWith("de")?y(t):t;return u(o?.locale?n.toLocaleLowerCase(o.locale):n.toLocaleLowerCase(),o)}),i=d(m," ");return e&&a&&s.set(a,i),i},"capitalCase");export{R as default};
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import { C as CaseOptions, c as ConstantCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, c as ConstantCase } 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 CONSTANT_CASE.
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* constantCase("foo bar") // => "FOO_BAR"
|
|
9
|
+
* constantCase("foo-bar") // => "FOO_BAR"
|
|
10
|
+
* constantCase("foo_bar") // => "FOO_BAR"
|
|
11
|
+
* constantCase("XMLHttpRequest") // => "XML_HTTP_REQUEST"
|
|
12
|
+
* constantCase("AJAXRequest") // => "AJAX_REQUEST"
|
|
13
|
+
* constantCase("QueryXML123String") // => "QUERY_XML_123_STRING"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
4
16
|
declare const constantCase: <T extends string = string>(value?: T, options?: CaseOptions) => ConstantCase<T>;
|
|
5
17
|
export { constantCase as default };
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
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
|
+
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};
|
package/dist/case/dot-case.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import { C as CaseOptions, D as DotCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, D as DotCase } 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 dot.case.
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* dotCase("foo bar") // => "foo.bar"
|
|
9
|
+
* dotCase("foo-bar") // => "foo.bar"
|
|
10
|
+
* dotCase("foo_bar") // => "foo.bar"
|
|
11
|
+
* dotCase("XMLHttpRequest") // => "xml.http.request"
|
|
12
|
+
* dotCase("AJAXRequest") // => "ajax.request"
|
|
13
|
+
* dotCase("QueryXML123String") // => "query.xml.123.string"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
4
16
|
declare const dotCase: <T extends string = string>(value?: T, options?: CaseOptions) => DotCase<T>;
|
|
5
17
|
export { dotCase as default };
|
package/dist/case/dot-case.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
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
|
+
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};
|
package/dist/case/flat-case.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import { C as CaseOptions, F as FlatCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, F as FlatCase } 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 flat case (all lowercase, no separators).
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* flatCase("foo-barBaz") // => "foobarbaz"
|
|
9
|
+
* flatCase("XMLHttpRequest") // => "xmlhttprequest"
|
|
10
|
+
* flatCase("AJAXRequest") // => "ajaxrequest"
|
|
11
|
+
* flatCase("QueryXML123String") // => "queryxml123string"
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
4
14
|
declare const flatCase: <T extends string = string>(value?: T, options?: CaseOptions) => FlatCase<T>;
|
|
5
15
|
export { flatCase as default };
|
package/dist/case/flat-case.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
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
|
+
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}),"s");const s=new t(1e3),l=i((e,a)=>n(e,{cacheStore:s,...a,joiner:""}),"flatCase");export{l as default};
|
package/dist/case/flip-case.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import { C as CaseOptions, d as FlipCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { C as CaseOptions, d as FlipCase } 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
|
+
* Options specific to flip case operations.
|
|
6
|
+
* Note: handleEmoji is not needed as the function preserves emojis by default
|
|
7
|
+
*/
|
|
4
8
|
type FlipOptions = Omit<CaseOptions, "handleEmoji">;
|
|
9
|
+
/**
|
|
10
|
+
* Flips the case of each character in a string.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* flipCase("FooBar") // => "fOObAR"
|
|
14
|
+
* flipCase("foobar") // => "FOOBAR"
|
|
15
|
+
* flipCase("FOOBAR") // => "foobar"
|
|
16
|
+
* flipCase("XMLHttpRequest") // => "xmlhTTPrEQUEST"
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
5
19
|
declare const flipCase: <T extends string = string>(value?: T, options?: FlipOptions) => FlipCase<T>;
|
|
6
20
|
export { FlipOptions, flipCase };
|
package/dist/case/flip-case.js
CHANGED
|
@@ -1,82 +1 @@
|
|
|
1
|
-
|
|
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-BsZS5f0z.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
|
+
var g=Object.defineProperty;var u=(r,e)=>g(r,"name",{value:e,configurable:!0});import{createRequire as h}from"node:module";import{s as j}from"../packem_shared/constants-DmzZF6_u.js";import b from"../packem_shared/LRUCache-Bjo6gsbC.js";import{a as v}from"../packem_shared/generate-cache-key-DPByFaMH.js";const d=h(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=u(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 d(r)},"__cjs_getBuiltinModule"),{stripVTControlCharacters:C}=_("node:util");var y=Object.defineProperty,T=u((r,e)=>y(r,"name",{value:e,configurable:!0}),"f");const L=new b(1e3),E=T((r,e)=>{if(typeof r!="string"||r.length===0)return"";const s=e?.cache??!1,c=e?.cacheStore??L;let n;if(s&&(n=v(r,e)),s&&n&&c.has(n))return c.get(n);let o=r;e?.stripEmoji&&(o=j(o)),e?.stripAnsi&&(o=C(o));let a="",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],a+=f),t+=1;continue}const i=o[t],m=e?.locale?i.toLocaleLowerCase(e.locale):i.toLowerCase();let p;i===m?p=e?.locale?i.toLocaleUpperCase(e.locale):i.toUpperCase():p=m,a+=p,t+=1}return s&&n&&c.set(n,a),a},"flipCase");export{E as flipCase};
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { I as IdentifyCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { I as IdentifyCase } 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
|
+
* Identifies the case style of a string.
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* identifyCase("fooBar") // => "camel"
|
|
9
|
+
* identifyCase("FooBar") // => "pascal"
|
|
10
|
+
* identifyCase("foo_bar") // => "snake"
|
|
11
|
+
* identifyCase("foo-bar") // => "kebab"
|
|
12
|
+
* identifyCase("foo") // => "lower"
|
|
13
|
+
* identifyCase("FOO") // => "upper"
|
|
14
|
+
* identifyCase("FooBAR") // => "mixed"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
4
17
|
declare const identifyCase: <T extends string = string>(value?: T) => IdentifyCase<T>;
|
|
5
18
|
export { identifyCase as default };
|
|
@@ -1,66 +1 @@
|
|
|
1
|
-
|
|
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 IS_LOWERCASE_START = /^[a-z]/;
|
|
12
|
-
const CONTAINS_PUNCTUATION_MID_WORD = /[.!?;:,](?!\s|$)/;
|
|
13
|
-
const identifyCase = (value) => {
|
|
14
|
-
if (typeof value !== "string") {
|
|
15
|
-
throw new TypeError("Expected input to be a string");
|
|
16
|
-
}
|
|
17
|
-
if (!value) {
|
|
18
|
-
return "unknown";
|
|
19
|
-
}
|
|
20
|
-
if (!CONTAINS_LETTER_CASE_INSENSITIVE.test(value)) {
|
|
21
|
-
return "unknown";
|
|
22
|
-
}
|
|
23
|
-
if (value.includes("_")) {
|
|
24
|
-
if (IS_UPPER_SNAKE_CASE.test(value)) {
|
|
25
|
-
return "upper_snake";
|
|
26
|
-
}
|
|
27
|
-
if (IS_LOWER_SNAKE_CASE.test(value)) {
|
|
28
|
-
return "snake";
|
|
29
|
-
}
|
|
30
|
-
return "mixed";
|
|
31
|
-
}
|
|
32
|
-
if (value.includes("-")) {
|
|
33
|
-
if (IS_KEBAB_CASE.test(value)) {
|
|
34
|
-
return "kebab";
|
|
35
|
-
}
|
|
36
|
-
return "mixed";
|
|
37
|
-
}
|
|
38
|
-
if (IS_LOWERCASE_WITH_SPACE.test(value)) {
|
|
39
|
-
return "lower";
|
|
40
|
-
}
|
|
41
|
-
if (IS_UPPERCASE.test(value)) {
|
|
42
|
-
return "upper";
|
|
43
|
-
}
|
|
44
|
-
const words = value.split(WHITESPACE_REGEX);
|
|
45
|
-
if (words.length > 1 && words.every((word) => IS_PASCAL_CASE.test(word))) {
|
|
46
|
-
return "title";
|
|
47
|
-
}
|
|
48
|
-
if (words.length > 1 && IS_NUMERIC.test(words[0]) && IS_PASCAL_CASE.test(words[1])) {
|
|
49
|
-
return "title";
|
|
50
|
-
}
|
|
51
|
-
if (words.length > 1 && IS_PASCAL_CASE.test(words[0]) && IS_LOWERCASE_START.test(words[1])) {
|
|
52
|
-
return "sentence";
|
|
53
|
-
}
|
|
54
|
-
if (IS_PASCAL_CASE.test(value)) {
|
|
55
|
-
return "pascal";
|
|
56
|
-
}
|
|
57
|
-
if (IS_CAMEL_CASE_LIKE.test(value)) {
|
|
58
|
-
return "camel";
|
|
59
|
-
}
|
|
60
|
-
if (CONTAINS_PUNCTUATION_MID_WORD.test(value)) {
|
|
61
|
-
return "unknown";
|
|
62
|
-
}
|
|
63
|
-
return "mixed";
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export { identifyCase as default };
|
|
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=/^[a-z]/,b=/[.!?;:,](?!\s|$)/,m=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.test(t[1])?"sentence":n.test(e)?"pascal":g.test(e)?"camel":b.test(e)?"unknown":"mixed"},"identifyCase");export{m as default};
|