@visulima/string 3.0.0-alpha.16 → 3.0.0-alpha.17
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/README.md +80 -2
- package/dist/case/camel-case.d.ts +2 -3
- package/dist/case/camel-case.js +1 -1
- package/dist/case/capital-case.d.ts +2 -3
- package/dist/case/capital-case.js +1 -1
- package/dist/case/constant-case.d.ts +2 -3
- package/dist/case/constant-case.js +1 -1
- package/dist/case/dot-case.d.ts +2 -3
- package/dist/case/dot-case.js +1 -1
- package/dist/case/flat-case.d.ts +2 -3
- package/dist/case/flat-case.js +1 -1
- package/dist/case/flip-case.d.ts +2 -3
- package/dist/case/flip-case.js +1 -1
- package/dist/case/identify-case.d.ts +2 -3
- package/dist/case/index.d.ts +2 -3
- package/dist/case/index.js +1 -1
- package/dist/case/kebab-case.d.ts +2 -3
- package/dist/case/kebab-case.js +1 -1
- package/dist/case/lower-first.d.ts +2 -3
- package/dist/case/no-case.d.ts +2 -3
- package/dist/case/no-case.js +1 -1
- package/dist/case/pascal-case.d.ts +2 -3
- package/dist/case/pascal-case.js +1 -1
- package/dist/case/pascal-snake-case.d.ts +2 -3
- package/dist/case/pascal-snake-case.js +1 -1
- package/dist/case/path-case.d.ts +2 -3
- package/dist/case/path-case.js +1 -1
- package/dist/case/sentence-case.d.ts +2 -3
- package/dist/case/sentence-case.js +1 -1
- package/dist/case/snake-case.d.ts +2 -3
- package/dist/case/snake-case.js +1 -1
- package/dist/case/split-by-case.d.ts +2 -3
- package/dist/case/split-by-case.js +1 -1
- package/dist/case/title-case.d.ts +2 -3
- package/dist/case/title-case.js +1 -1
- package/dist/case/train-case.d.ts +2 -3
- package/dist/case/train-case.js +1 -1
- package/dist/case/upper-first.d.ts +2 -3
- package/dist/count-occurrences.d.ts +9 -0
- package/dist/direction.d.ts +7 -0
- package/dist/east-asian-width.d.ts +52 -0
- package/dist/east-asian-width.js +1 -0
- package/dist/excerpt.d.ts +25 -0
- package/dist/excerpt.js +53 -0
- package/dist/get-string-truncated-width.js +1 -1
- package/dist/indent.d.ts +87 -0
- package/dist/indent.js +1 -0
- package/dist/index.d.ts +12 -205
- package/dist/index.js +1 -1
- package/dist/is-fullwidth-code-point.d.ts +7 -0
- package/dist/is-fullwidth-code-point.js +1 -0
- package/dist/levenshtein.d.ts +25 -0
- package/dist/levenshtein.js +1 -0
- package/dist/outdent.js +1 -1
- package/dist/packem_shared/{lookup-DsIbtHWS.js → _isFullWidth-Dqc3MWgl.js} +1 -1
- package/dist/packem_shared/{constants-CImsldtV.js → constants-B7EE3d7a.js} +1 -1
- package/dist/packem_shared/eastAsianWidth-DJV8Kqd-.js +1 -0
- package/dist/packem_shared/{joinSegments-cvixBSMu.js → joinSegments-DwpAvf1_.js} +1 -1
- package/dist/packem_shared/{LRUCache-Dm3jkQzc.js → lru-cache-BtMSrYQJ.js} +1 -1
- package/dist/packem_shared/redent-ByOoJ6fN.js +1 -0
- package/dist/packem_shared/{types.d-NJ4vcG-A.d.ts → types.d-CmNvyl4l.d.ts} +16 -2
- package/dist/packem_shared/{types.d-XxhGlCLZ.d.ts → types.d-fhe030jX.d.ts} +13 -3
- package/dist/replace-string.d.ts +10 -0
- package/dist/slice.js +1 -1
- package/dist/slugify.d.ts +1 -1
- package/dist/slugify.js +1 -1
- package/dist/transliterate.d.ts +10 -0
- package/dist/{packem_shared/transliterate-BYGS0N0m.js → transliterate.js} +3 -3
- package/dist/utilities.d.ts +1 -2
- package/dist/utilities.js +1 -1
- package/dist/word-wrap.js +7 -7
- package/package.json +37 -1
- package/dist/packem_shared/closestN-DfsjM5M2.js +0 -1
- package/dist/packem_shared/eastAsianWidthType-DDZo0voG.js +0 -1
- package/dist/packem_shared/excerpt-De-Waruz.js +0 -34
- package/dist/packem_shared/isFullwidthCodePoint-BMvc9BNh.js +0 -1
- package/dist/packem_shared/lru-cache.d-BVu2_gfi.d.ts +0 -12
- package/dist/packem_shared/redent-DqgI-fa_.js +0 -1
- /package/dist/{packem_shared/countOccurrences-DTjnj8Pm.js → count-occurrences.js} +0 -0
- /package/dist/{packem_shared/direction-Dp2CCCH6.js → direction.js} +0 -0
- /package/dist/packem_shared/{stripIndent-CPjAYUXh.js → dedent-CPjAYUXh.js} +0 -0
- /package/dist/{packem_shared/replaceString-DoWVBsen.js → replace-string.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -17,220 +17,27 @@ export { default as snakeCase } from "./case/snake-case.js";
|
|
|
17
17
|
export { type SplitOptions, splitByCase } from "./case/split-by-case.js";
|
|
18
18
|
export { default as titleCase } from "./case/title-case.js";
|
|
19
19
|
export { default as trainCase } from "./case/train-case.js";
|
|
20
|
-
export {
|
|
20
|
+
export type { C as CamelCase, a as CapitalCase, b as CaseOptions, c as ConstantCase, D as DotCase, F as FlatCase, d as FlipCase, I as IdentifyCase, K as KebabCase, L as LocaleOptions, e as LowerFirst, N as NoCase, P as PascalCase, f as PascalSnakeCase, g as PathCase, S as SentenceCase, h as SnakeCase, i as SplitByCase, T as TitleCase, j as TrainCase, U as UpperFirst } from "./packem_shared/types.d-fhe030jX.js";
|
|
21
21
|
export { default as upperFirst } from "./case/upper-first.js";
|
|
22
22
|
export { joinSegments } from "./case/index.js";
|
|
23
23
|
export { type ClosestStringOptions, closestString } from "./closest-string.js";
|
|
24
24
|
export { type CompareSimilarityOptions, compareSimilarity } from "./compare-similarity.js";
|
|
25
|
-
|
|
26
|
-
export {
|
|
25
|
+
export { countOccurrences } from "./count-occurrences.js";
|
|
26
|
+
export { direction } from "./direction.js";
|
|
27
|
+
export { type EastAsianWidthOptions, type EastAsianWidthType, eastAsianWidth, eastAsianWidthType } from "./east-asian-width.js";
|
|
28
|
+
export { type ExcerptOptions, excerpt } from "./excerpt.js";
|
|
27
29
|
export { type StringTruncatedWidthOptions, type StringTruncatedWidthResult, getStringTruncatedWidth } from "./get-string-truncated-width.js";
|
|
28
30
|
export { type StringWidthOptions, getStringWidth } from "./get-string-width.js";
|
|
31
|
+
export { type IndentOptions, dedent, indent, redent, stripIndent } from "./indent.js";
|
|
32
|
+
export { default as isFullwidthCodePoint } from "./is-fullwidth-code-point.js";
|
|
33
|
+
export { closest, closestN, distance, similarity } from "./levenshtein.js";
|
|
29
34
|
export { type Outdent, type Options as OutdentOptions, outdent } from "./outdent.js";
|
|
30
|
-
|
|
31
|
-
export { type A as All, type c as Any, type C as CharAt, type d as Charmap, type e as Concat, type E as EndsWith, type f as Includes, type g as Interval, type h as IsBooleanLiteral, type i as IsNumberLiteral, type I as IsStringLiteral, type j as IsStringLiteralArray, type J as Join, type L as Length, type M as Math, type N as NodeLocale, type k as OptionReplaceCombined, type l as OptionReplaceObject, type P as PadEnd, type m as PadStart, type R as Repeat, type n as Replace, type o as ReplaceAll, type p as Reverse, type q as Slice, type S as SlugifyOptions, type r as Split, type s as StartsWith, type T as ToLowerCase, type t as ToUpperCase, type u as Trim, type v as TrimEnd, type w as TrimStart } from "./packem_shared/types.d-NJ4vcG-A.js";
|
|
35
|
+
export { default as replaceString } from "./replace-string.js";
|
|
32
36
|
export { type SliceOptions, slice } from "./slice.js";
|
|
33
37
|
export { default as slugify } from "./slugify.js";
|
|
38
|
+
export { default as transliterate } from "./transliterate.js";
|
|
39
|
+
export { type TruncateOptions, truncate } from "./truncate.js";
|
|
40
|
+
export type { A as All, a as Any, C as CharAt, b as Charmap, c as Concat, E as EndsWith, I as Includes, d as Interval, e as IntervalArray, f as IsBooleanLiteral, g as IsNumberLiteral, h as IsStringLiteral, i as IsStringLiteralArray, J as Join, L as Length, M as Math, N as NodeLocale, O as OptionReplaceArray, j as OptionReplaceCombined, k as OptionReplaceObject, l as OptionsTransliterate, P as PadEnd, m as PadStart, R as Repeat, n as Replace, o as ReplaceAll, p as Reverse, S as Slice, q as SlugifyOptions, r as Split, s as StartsWith, T as ToLowerCase, t as ToUpperCase, u as Trim, v as TrimEnd, w as TrimStart } from "./packem_shared/types.d-CmNvyl4l.js";
|
|
34
41
|
export { escapeRegExp, findStringOccurrences, hasChinese, hasPunctuationOrSpace, inRange } from "./utilities.js";
|
|
35
42
|
export { type WordSimilaritySortOptions, wordSimilaritySort } from "./word-similarity-sort.js";
|
|
36
43
|
export { type WordWrapOptions, WrapMode, wordWrap } from "./word-wrap.js";
|
|
37
|
-
import "./packem_shared/lru-cache.d-BVu2_gfi.js";
|
|
38
|
-
/**
|
|
39
|
-
* Get the count of `substring` in `value`.
|
|
40
|
-
* @param value Content to search in. Will be coerced to string.
|
|
41
|
-
* @param substring Substring to look for, typically one character.
|
|
42
|
-
* @returns Count of `substring`s in `value`.
|
|
43
|
-
* @throws {TypeError} When substring is not a string or is empty.
|
|
44
|
-
*/
|
|
45
|
-
declare const countOccurrences: (value: unknown, substring: string) => number;
|
|
46
|
-
/**
|
|
47
|
-
* Detect the direction of text: left-to-right, right-to-left, or neutral.
|
|
48
|
-
* @param value The string to analyze.
|
|
49
|
-
* @returns The text direction: 'rtl' for right-to-left, 'ltr' for left-to-right, or 'neutral' for neutral.
|
|
50
|
-
*/
|
|
51
|
-
declare const direction: (value?: string) => "rtl" | "ltr" | "neutral";
|
|
52
|
-
type WidthType = 'fullwidth' | 'halfwidth' | 'wide' | 'narrow' | 'neutral' | 'ambiguous';
|
|
53
|
-
type Options$1 = {
|
|
54
|
-
/**
|
|
55
|
-
Whether to treat an `'ambiguous'` character as wide.
|
|
56
|
-
@default true
|
|
57
|
-
@example
|
|
58
|
-
```
|
|
59
|
-
import {eastAsianWidth} from 'get-east-asian-width';
|
|
60
|
-
const codePoint = '⛣'.codePointAt(0);
|
|
61
|
-
console.log(eastAsianWidth(codePoint));
|
|
62
|
-
//=> 1
|
|
63
|
-
console.log(eastAsianWidth(codePoint, {ambiguousAsWide: true}));
|
|
64
|
-
//=> 2
|
|
65
|
-
```
|
|
66
|
-
> Ambiguous characters behave like wide or narrow characters depending on the context (language tag, script identification, associated font, source of data, or explicit markup; all can provide the context). __If the context cannot be established reliably, they should be treated as narrow characters by default.__
|
|
67
|
-
> - http://www.unicode.org/reports/tr11/
|
|
68
|
-
*/
|
|
69
|
-
readonly ambiguousAsWide?: boolean;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
Returns the width as a number for the given code point.
|
|
73
|
-
|
|
74
|
-
@param codePoint - A Unicode code point.
|
|
75
|
-
|
|
76
|
-
@example
|
|
77
|
-
```
|
|
78
|
-
import {eastAsianWidth} from 'get-east-asian-width';
|
|
79
|
-
|
|
80
|
-
const codePoint = '字'.codePointAt(0);
|
|
81
|
-
|
|
82
|
-
console.log(eastAsianWidth(codePoint));
|
|
83
|
-
//=> 2
|
|
84
|
-
```
|
|
85
|
-
*/
|
|
86
|
-
declare function eastAsianWidth(codePoint: number, options?: Options$1): 1 | 2;
|
|
87
|
-
/**
|
|
88
|
-
Returns the type of “East Asian Width” for the given code point.
|
|
89
|
-
|
|
90
|
-
@param codePoint - A Unicode code point.
|
|
91
|
-
|
|
92
|
-
@example
|
|
93
|
-
```
|
|
94
|
-
import {eastAsianWidthType} from 'get-east-asian-width';
|
|
95
|
-
|
|
96
|
-
const codePoint = '字'.codePointAt(0);
|
|
97
|
-
|
|
98
|
-
console.log(eastAsianWidthType(codePoint));
|
|
99
|
-
//=> 'wide'
|
|
100
|
-
```
|
|
101
|
-
*/
|
|
102
|
-
declare function eastAsianWidthType(codePoint: number): WidthType;
|
|
103
|
-
/**
|
|
104
|
-
* Truncates a sentence to be under the given character limit and strips HTML tags from it.
|
|
105
|
-
* This function first removes all HTML tags and decodes HTML entities, then truncates
|
|
106
|
-
* the resulting plain text to the specified character limit using the truncate function.
|
|
107
|
-
* @example
|
|
108
|
-
* ```typescript
|
|
109
|
-
* excerpt('<p>Hello <strong>world</strong>!</p>', 10);
|
|
110
|
-
* // => 'Hello worl…'
|
|
111
|
-
*
|
|
112
|
-
* excerpt('<div>This is a <em>long</em> text</div>', 20, { ellipsis: '...' });
|
|
113
|
-
* // => 'This is a long text'
|
|
114
|
-
* ```
|
|
115
|
-
* @param html The HTML string to truncate
|
|
116
|
-
* @param limit Maximum character limit for the truncated string
|
|
117
|
-
* @param options Configuration options for truncation
|
|
118
|
-
* @returns The truncated plain text string with HTML tags removed
|
|
119
|
-
*/
|
|
120
|
-
declare const excerpt: (html: string, limit: number, options?: ExcerptOptions) => string;
|
|
121
|
-
/**
|
|
122
|
-
* Options for the excerpt function
|
|
123
|
-
*/
|
|
124
|
-
type ExcerptOptions = Omit<TruncateOptions, "position">;
|
|
125
|
-
interface Options {
|
|
126
|
-
/**
|
|
127
|
-
The string to use for the indent.
|
|
128
|
-
@default ' '
|
|
129
|
-
*/
|
|
130
|
-
readonly indent?: string;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
Also indent empty lines.
|
|
134
|
-
@default false
|
|
135
|
-
*/
|
|
136
|
-
readonly includeEmptyLines?: boolean;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
Indent each line in a string.
|
|
140
|
-
|
|
141
|
-
@param string - The string to indent.
|
|
142
|
-
@param count - How many times you want `options.indent` repeated. Default: `1`.
|
|
143
|
-
|
|
144
|
-
@example
|
|
145
|
-
```
|
|
146
|
-
import indentString from 'indent-string';
|
|
147
|
-
|
|
148
|
-
indentString('Unicorns\nRainbows', 4);
|
|
149
|
-
//=> ' Unicorns\n Rainbows'
|
|
150
|
-
|
|
151
|
-
indentString('Unicorns\nRainbows', 4, {indent: '♥'});
|
|
152
|
-
//=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows'
|
|
153
|
-
```
|
|
154
|
-
*/
|
|
155
|
-
declare function indentString(string: string, count?: number, options?: Options): string;
|
|
156
|
-
/**
|
|
157
|
-
[Strip redundant indentation](https://github.com/sindresorhus/strip-indent) and [indent the string](https://github.com/sindresorhus/indent-string).
|
|
158
|
-
|
|
159
|
-
@param string - The string to normalize indentation.
|
|
160
|
-
@param count - How many times you want `options.indent` repeated. Default: `0`.
|
|
161
|
-
|
|
162
|
-
@example
|
|
163
|
-
```
|
|
164
|
-
import redent from 'redent';
|
|
165
|
-
|
|
166
|
-
redent('\n foo\n bar\n', 1);
|
|
167
|
-
//=> '\n foo\n bar\n'
|
|
168
|
-
```
|
|
169
|
-
*/
|
|
170
|
-
declare function redent(string: string, count?: number, options?: Options): string;
|
|
171
|
-
/**
|
|
172
|
-
Strip leading whitespace from each line in a string.
|
|
173
|
-
|
|
174
|
-
The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove.
|
|
175
|
-
|
|
176
|
-
@example
|
|
177
|
-
```
|
|
178
|
-
import stripIndent from 'strip-indent';
|
|
179
|
-
|
|
180
|
-
const string = '\tunicorn\n\t\tcake';
|
|
181
|
-
// unicorn
|
|
182
|
-
// cake
|
|
183
|
-
|
|
184
|
-
stripIndent(string);
|
|
185
|
-
//unicorn
|
|
186
|
-
// cake
|
|
187
|
-
```
|
|
188
|
-
*/
|
|
189
|
-
declare function stripIndent(string: string): string;
|
|
190
|
-
/**
|
|
191
|
-
Strip leading whitespace from each line in a string and remove surrounding blank lines.
|
|
192
|
-
|
|
193
|
-
The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove.
|
|
194
|
-
Leading and trailing lines that contain only whitespace are removed.
|
|
195
|
-
|
|
196
|
-
Useful for template literals and multi-line strings where you want clean boundaries.
|
|
197
|
-
|
|
198
|
-
@example
|
|
199
|
-
```
|
|
200
|
-
import {dedent} from 'strip-indent';
|
|
201
|
-
|
|
202
|
-
dedent(`
|
|
203
|
-
unicorn
|
|
204
|
-
cake
|
|
205
|
-
`);
|
|
206
|
-
//unicorn
|
|
207
|
-
// cake
|
|
208
|
-
```
|
|
209
|
-
*/
|
|
210
|
-
declare function dedent(string: string): string;
|
|
211
|
-
/**
|
|
212
|
-
* Check if the given code point is a fullwidth character.
|
|
213
|
-
* @param codePoint The code point to check.
|
|
214
|
-
* @returns Whether the code point is a fullwidth character.
|
|
215
|
-
*/
|
|
216
|
-
declare const isFullwidthCodePoint: (codePoint: number) => boolean;
|
|
217
|
-
declare const distance: (a: string, b: string) => number;
|
|
218
|
-
declare const closest: (str: string, arr: readonly string[]) => string;
|
|
219
|
-
declare const closestN: (string_: string, array: ReadonlyArray<string>, n: number) => (string | undefined)[];
|
|
220
|
-
/**
|
|
221
|
-
* Performs multiple string or RegExp replacements using a refined pre-processing approach.
|
|
222
|
-
* @param source The string to search and replace in.
|
|
223
|
-
* @param searches An array of search/replace pairs.
|
|
224
|
-
* @param ignoreRanges An array of ignored ranges.
|
|
225
|
-
* @returns The string with replacements applied.
|
|
226
|
-
*/
|
|
227
|
-
declare const replaceString: (source: string, searches: OptionReplaceArray, ignoreRanges: IntervalArray) => string;
|
|
228
|
-
/**
|
|
229
|
-
* Main transliterate function.
|
|
230
|
-
* Replaces characters in a string based on a charmap and options.
|
|
231
|
-
* @param source The string which is being transliterated.
|
|
232
|
-
* @param options Options object.
|
|
233
|
-
* @returns The transliterated string.
|
|
234
|
-
*/
|
|
235
|
-
declare const transliterate: (source: string, options?: OptionsTransliterate) => string;
|
|
236
|
-
export { type Options$1 as EastAsianWidthOptions, type WidthType as EastAsianWidthType, type ExcerptOptions, type Options as IndentOptions, type IntervalArray, type OptionReplaceArray, type OptionsTransliterate, type TruncateOptions, closest, closestN, countOccurrences, dedent, direction, distance, eastAsianWidth, eastAsianWidthType, excerpt, indentString as indent, isFullwidthCodePoint, redent, replaceString, stripIndent, transliterate };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{alignText as r}from"./align-text.js";import{default as a}from"./case/camel-case.js";import{default as s}from"./case/capital-case.js";import{default as m}from"./case/constant-case.js";import{default as
|
|
1
|
+
import{alignText as r}from"./align-text.js";import{default as a}from"./case/camel-case.js";import{default as s}from"./case/capital-case.js";import{default as m}from"./case/constant-case.js";import{default as i}from"./case/dot-case.js";import{default as d}from"./case/flat-case.js";import{flipCase as u}from"./case/flip-case.js";import{default as C}from"./case/identify-case.js";import{kebabCase as S}from"./case/kebab-case.js";import{default as y}from"./case/lower-first.js";import{default as w}from"./case/no-case.js";import{default as F}from"./case/pascal-case.js";import{default as T}from"./case/pascal-snake-case.js";import{default as A}from"./case/path-case.js";import{default as R}from"./case/sentence-case.js";import{default as B}from"./case/snake-case.js";import{splitByCase as I}from"./case/split-by-case.js";import{default as N}from"./case/title-case.js";import{default as v}from"./case/train-case.js";import{default as D}from"./case/upper-first.js";import{default as H}from"./packem_shared/joinSegments-DwpAvf1_.js";import{closestString as K}from"./closest-string.js";import{compareSimilarity as Q}from"./compare-similarity.js";import{countOccurrences as V}from"./count-occurrences.js";import{direction as Y}from"./direction.js";import{excerpt as _}from"./excerpt.js";import{getStringTruncatedWidth as ee}from"./get-string-truncated-width.js";import{getStringWidth as re}from"./get-string-width.js";import{default as ae}from"./is-fullwidth-code-point.js";import{closestN as se,similarity as pe}from"./levenshtein.js";import{outdent as xe}from"./outdent.js";import{default as le}from"./replace-string.js";import{slice as ne}from"./slice.js";import{default as ce}from"./slugify.js";import{default as ge}from"./transliterate.js";import{truncate as he}from"./truncate.js";import{escapeRegExp as We,findStringOccurrences as we,hasChinese as ke,hasPunctuationOrSpace as Fe,inRange as Oe}from"./utilities.js";import{wordSimilaritySort as be}from"./word-similarity-sort.js";import{WrapMode as Pe,wordWrap as Re}from"./word-wrap.js";import{default as Be}from"./packem_shared/indent-cz8WMI0e.js";import{default as Ie}from"./packem_shared/redent-ByOoJ6fN.js";import{dedent as Ne,default as qe}from"./packem_shared/dedent-CPjAYUXh.js";import{closest as ze,distance as De}from"./packem_shared/closest-C6YDQs4m.js";import{eastAsianWidth as He,eastAsianWidthType as Je}from"./packem_shared/eastAsianWidth-DJV8Kqd-.js";export{Pe as WrapMode,r as alignText,a as camelCase,s as capitalCase,ze as closest,se as closestN,K as closestString,Q as compareSimilarity,m as constantCase,V as countOccurrences,Ne as dedent,Y as direction,De as distance,i as dotCase,He as eastAsianWidth,Je as eastAsianWidthType,We as escapeRegExp,_ as excerpt,we as findStringOccurrences,d as flatCase,u as flipCase,ee as getStringTruncatedWidth,re as getStringWidth,ke as hasChinese,Fe as hasPunctuationOrSpace,C as identifyCase,Oe as inRange,Be as indent,ae as isFullwidthCodePoint,H as joinSegments,S as kebabCase,y as lowerFirst,w as noCase,xe as outdent,F as pascalCase,T as pascalSnakeCase,A as pathCase,Ie as redent,le as replaceString,R as sentenceCase,pe as similarity,ne as slice,ce as slugify,B as snakeCase,I as splitByCase,qe as stripIndent,N as titleCase,v as trainCase,ge as transliterate,he as truncate,D as upperFirst,be as wordSimilaritySort,Re as wordWrap};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the given code point is a fullwidth character.
|
|
3
|
+
* @param codePoint The code point to check.
|
|
4
|
+
* @returns Whether the code point is a fullwidth character.
|
|
5
|
+
*/
|
|
6
|
+
declare const isFullwidthCodePoint: (codePoint: number) => boolean;
|
|
7
|
+
export { isFullwidthCodePoint as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isFullWidth as i,isWide as t}from"./packem_shared/_isFullWidth-Dqc3MWgl.js";const r=s=>Number.isInteger(s)?i(s)||t(s):!1;export{r as default};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const distance: (a: string, b: string) => number;
|
|
2
|
+
declare const closest: (str: string, arr: readonly string[]) => string;
|
|
3
|
+
declare const closestN: (string_: string, array: ReadonlyArray<string>, n: number) => (string | undefined)[];
|
|
4
|
+
/**
|
|
5
|
+
* Computes a normalized similarity score between two strings in the range `[0, 1]`,
|
|
6
|
+
* where `1` means the strings are identical and `0` means maximally different.
|
|
7
|
+
*
|
|
8
|
+
* The score is derived from the Levenshtein edit distance, normalized by the
|
|
9
|
+
* length of the longer string: `1 - distance(a, b) / max(a.length, b.length)`.
|
|
10
|
+
* Two empty strings are considered identical (`1`).
|
|
11
|
+
*
|
|
12
|
+
* This is convenient for threshold-based "did you mean?" UX, complementing the
|
|
13
|
+
* raw {@link distance} and the sort-based helpers.
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* similarity("kitten", "sitting"); // => ~0.571
|
|
17
|
+
* similarity("foo", "foo"); // => 1
|
|
18
|
+
* similarity("", ""); // => 1
|
|
19
|
+
* ```
|
|
20
|
+
* @param a The first string.
|
|
21
|
+
* @param b The second string.
|
|
22
|
+
* @returns A similarity score between 0 and 1 (inclusive).
|
|
23
|
+
*/
|
|
24
|
+
declare const similarity: (a: string, b: string) => number;
|
|
25
|
+
export { closest, closestN, distance, similarity };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{distance as c}from"./packem_shared/closest-C6YDQs4m.js";import{closest as y}from"./packem_shared/closest-C6YDQs4m.js";const u=(r,s,o)=>{const e=Array.from({length:o}).fill(1/0),n=Array.from({length:o}).fill(void 0);for(const a of s){const f=a;let l=c(r,f),i=f;for(let t=0;t<o;t+=1)if(l<e[t]){const m=e[t],h=n[t];e[t]=l,n[t]=i,l=m,i=h}}return n},d=(r,s)=>{if(r===s)return 1;const o=Math.max(r.length,s.length);return o===0?1:1-c(r,s)/o};export{y as closest,u as closestN,c as distance,d as similarity};
|
package/dist/outdent.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{f as A,g as R,h as p,i as S,j as W,k as m}from"./packem_shared/constants-B7EE3d7a.js";const I=(e,r)=>Object.hasOwn(e,r),T=(e,r)=>Object.assign(e,r),h=(e,r,n)=>{if(e.length===0)return[];let t=0;const s=m.exec(e[0]);s&&(t=s[1].length);const i=String.raw`(\r\n|\r|\n).{0,${t}}`,g=new RegExp(i,"g"),l=r?e.slice(1):e,{newline:N,trimLeadingNewline:_,trimTrailingNewline:o}=n,f=typeof N=="string",E=l.length,u=Array.from({length:E});for(let c=0;c<E;c++){let a=l[c];a=a.replace(g,"$1"),c===0&&_&&(a=a.replace(A,"")),c===E-1&&o&&(a=a.replace(R,"")),f&&(a=a.replaceAll(W,N)),u[c]=a}return u},O=(e,r)=>{const n=Array.from({length:e.length+r.length});let t=0;const s=e.length;for(;t<s-1;t++)n[t*2]=e[t],n[t*2+1]=String(r[t]);return n[t*2]=e[t],n.join("")},d=e=>I(e,"raw")&&I(e,"length"),j=new WeakMap,w=e=>{const r=e.cache!==!1,n=r?e.cacheStore??j:void 0,t=e.newline!==void 0;function s(i,...g){if(d(i)){const l=i,N=g.length;if(l.length===1&&l[0]==="")return"";if(N===0){if(r&&n&&!t){const E=n.get(l);if(E)return E[0]}const f=h(l,!1,e);return r&&n&&n.set(l,f),f[0]}const _=(g[0]===s||g[0]===L)&&p.test(l[0])&&S.test(l[1]);let o;return r&&n&&!t&&(o=n.get(l)),o||(o=h(l,_,e),r&&n&&n.set(l,o)),O(o,_?g.slice(1):g)}return w(T(T({},e),i))}return T(s,{string(i){return i===""||!i?"":h([i],!1,e)[0]}})},L=w({cache:!0,newline:null,trimLeadingNewline:!0,trimTrailingNewline:!0}),b=L;export{b as outdent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const r=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],d=12288,m=65510,f=[12288,12288,65281,65376,65504,65510],g=8361,h=65518,w=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],M=32,C=10630,P=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],c=4352,b=262141,t=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],
|
|
1
|
+
const r=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],d=12288,m=65510,f=[12288,12288,65281,65376,65504,65510],g=8361,h=65518,w=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],M=32,C=10630,P=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],c=4352,b=262141,t=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],u=(i,l)=>{let e=0,o=Math.floor(i.length/2)-1;for(;e<=o;){const n=Math.floor((e+o)/2),a=n*2;if(l<i[a])o=n-1;else if(l>i[a+1])e=n+1;else return!0}return!1},s=19968,[x,R]=W(t);function W(i){let l=i[0],e=i[1];for(let o=0;o<i.length;o+=2){const n=i[o],a=i[o+1];if(s>=n&&s<=a)return[n,a];a-n>e-l&&(l=n,e=a)}return[l,e]}const j=i=>i<161||i>1114109?!1:u(r,i),k=i=>i<d||i>m?!1:u(f,i),p=i=>i<g||i>h?!1:u(w,i),y=i=>i<M||i>C?!1:u(P,i),A=i=>i>=x&&i<=R?!0:i<c||i>b?!1:u(t,i);function E(i){return j(i)?"ambiguous":k(i)?"fullwidth":p(i)?"halfwidth":y(i)?"narrow":A(i)?"wide":"neutral"}export{E as getCategory,j as isAmbiguous,k as isFullWidth,A as isWide};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const R=String.raw,E=R`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,a=()=>new RegExp(R`\p{RI}{2}|(?)${E}(?:\u200D${E})*`,"gu"),n=new Set(["\x1B",""]),e="\x07",_="[",r="m",u="]8;;",S=39,s=/[\u200B\uFEFF\u2060-\u2064]/g,I=new RegExp(`(?:\\${_}(?<code>\\d+)m|\\${u}(?<uri>.*)${e})`),i=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),t=/^[ \t]*(?:\r\n|\r|\n)/,N=/(?:\r\n|\r|\n)[ \t]*$/,g=/^(?:[\r\n]|$)/,c=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,T=/^[ \t]*[\r\n][ \t\r\n]*$/,L=/\r\n|\n|\r/g,w=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,x=/\u001B\[(\d+(?:;\d+)*)?m[^\u001B]*(?:\u001B\[(?:\d+(?:;\d+)*)?m|$)/g,B=/\u001B\]8;[^\u0007\u001B]*(?:\u0007|\u001B\\)(.*?)\u001B\]8;;(?:\u0007|\u001B\\)/g,O=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,A=a(),H=/[-_./\s]+/g,C=/(\u001B\[[0-9;]*[a-z])/i,G=new RegExp("\\p{Script=Arabic}","u"),M=new RegExp("\\p{Script=Bengali}","u"),D=new RegExp("\\p{Script=Cyrillic}","u"),K=new RegExp("\\p{Script=Devanagari}","u"),F=new RegExp("\\p{Script=Ethiopic}","u"),P=new RegExp("\\p{Script=Greek}","u"),d=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),m=new RegExp("\\p{Script=Gujarati}","u"),l=new RegExp("\\p{Script=Gurmukhi}","u"),o=new RegExp("\\p{Script=Hangul}","u"),W=new RegExp("\\p{Script=Hebrew}","u"),$=new RegExp("\\p{Script=Hiragana}","u"),U=new RegExp("\\p{Script=Han}","u"),y=new RegExp("\\p{Script=Kannada}","u"),Y=new RegExp("\\p{Script=Katakana}","u"),h=new RegExp("\\p{Script=Khmer}","u"),k=new RegExp("\\p{Script=Lao}","u"),b=new RegExp("\\p{Script=Latin}","u"),j=new RegExp("\\p{Script=Malayalam}","u"),J=new RegExp("\\p{Script=Myanmar}","u"),V=new RegExp("\\p{Script=Oriya}","u"),f=new RegExp("\\p{Script=Sinhala}","u"),z=new RegExp("\\p{Script=Tamil}","u"),Z=new RegExp("\\p{Script=Telugu}","u"),q=new RegExp("\\p{Script=Thai}","u"),v=new RegExp("\\p{Script=Tibetan}","u"),Q=/[\u02BB\u02BC\u0027]/u,X=p=>p.replace(A,"");export{m as A,l as B,y as C,z as D,Z as E,j as F,f as G,q as H,k as I,v as J,J as K,F as L,h as M,V as N,n as O,r as P,u as Q,
|
|
1
|
+
const R=String.raw,E=R`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,a=()=>new RegExp(R`\p{RI}{2}|(?)${E}(?:\u200D${E})*`,"gu"),n=new Set(["\x1B",""]),e="\x07",_="[",r="m",u="]8;;",S=39,s=/[\u200B\uFEFF\u2060-\u2064]/g,I=new RegExp(`(?:\\${_}(?<code>\\d+)m|\\${u}(?<uri>.*)${e})`),i=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),t=/^[ \t]*(?:\r\n|\r|\n)/,N=/(?:\r\n|\r|\n)[ \t]*$/,g=/^(?:[\r\n]|$)/,c=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,T=/^[ \t]*[\r\n][ \t\r\n]*$/,L=/\r\n|\n|\r/g,w=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,x=/\u001B\[(\d+(?:;\d+)*)?m[^\u001B]*(?:\u001B\[(?:\d+(?:;\d+)*)?m|$)/g,B=/\u001B\]8;[^\u0007\u001B]*(?:\u0007|\u001B\\)(.*?)\u001B\]8;;(?:\u0007|\u001B\\)/g,O=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,A=a(),H=/[-_./\s]+/g,C=/(\u001B\[[0-9;]*[a-z])/i,G=new RegExp("\\p{Script=Arabic}","u"),M=new RegExp("\\p{Script=Bengali}","u"),D=new RegExp("\\p{Script=Cyrillic}","u"),K=new RegExp("\\p{Script=Devanagari}","u"),F=new RegExp("\\p{Script=Ethiopic}","u"),P=new RegExp("\\p{Script=Greek}","u"),d=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),m=new RegExp("\\p{Script=Gujarati}","u"),l=new RegExp("\\p{Script=Gurmukhi}","u"),o=new RegExp("\\p{Script=Hangul}","u"),W=new RegExp("\\p{Script=Hebrew}","u"),$=new RegExp("\\p{Script=Hiragana}","u"),U=new RegExp("\\p{Script=Han}","u"),y=new RegExp("\\p{Script=Kannada}","u"),Y=new RegExp("\\p{Script=Katakana}","u"),h=new RegExp("\\p{Script=Khmer}","u"),k=new RegExp("\\p{Script=Lao}","u"),b=new RegExp("\\p{Script=Latin}","u"),j=new RegExp("\\p{Script=Malayalam}","u"),J=new RegExp("\\p{Script=Myanmar}","u"),V=new RegExp("\\p{Script=Oriya}","u"),f=new RegExp("\\p{Script=Sinhala}","u"),z=new RegExp("\\p{Script=Tamil}","u"),Z=new RegExp("\\p{Script=Telugu}","u"),q=new RegExp("\\p{Script=Thai}","u"),v=new RegExp("\\p{Script=Tibetan}","u"),Q=/[\u02BB\u02BC\u0027]/u,X=p=>p.replace(A,"");export{m as A,l as B,y as C,z as D,Z as E,j as F,f as G,q as H,k as I,v as J,J as K,F as L,h as M,V as N,n as O,r as P,u as Q,w as R,e as S,_ as T,I as U,i as V,S as W,s as X,O as a,A as b,C as c,x as d,B as e,t as f,N as g,T as h,g as i,L as j,c as k,H as l,D as m,b as n,P as o,d as p,Q as q,Y as r,X as s,U as t,$ as u,o as v,W as w,G as x,K as y,M as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isFullWidth as s,isWide as o,isAmbiguous as r,getCategory as n}from"./_isFullWidth-Dqc3MWgl.js";function t(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function a(e){return t(e),n(e)}function d(e,{ambiguousAsWide:i=!1}={}){return t(e),s(e)||o(e)||i&&r(e)?2:1}export{s as _isFullWidth,o as _isWide,d as eastAsianWidth,a as eastAsianWidthType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as h}from"./constants-B7EE3d7a.js";const l=(o,u)=>{const{length:r}=o;if(r===0)return"";if(r===1)return o[0];const t=[];let n="",e="";for(let f=0;f<r;f++){const s=o[f];if(h.test(s)){n?(t.push(n+e+s),n="",e=""):(t.length>0&&t.push(u),n=s);continue}n?(e&&(e+=u),e+=s):(t.length>0&&t.push(u),t.push(s))}return t.join("")};export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
class s{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const c=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,c),c}has(e){return this.cache.has(e)}set(e,c){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t!==void 0&&this.cache.delete(t)}this.cache.set(e,c)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}}export{s as
|
|
1
|
+
class s{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const c=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,c),c}has(e){return this.cache.has(e)}set(e,c){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t!==void 0&&this.cache.delete(t)}this.cache.set(e,c)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}}export{s as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import f from"./indent-cz8WMI0e.js";import i from"./dedent-CPjAYUXh.js";function n(r,o=0,t={}){return f(i(r),o,t)}export{n as default};
|
|
@@ -321,8 +321,22 @@ interface SlugifyOptions extends OptionsTransliterate {
|
|
|
321
321
|
*/
|
|
322
322
|
fixChineseSpacing?: boolean;
|
|
323
323
|
/**
|
|
324
|
+
* Locale to use for locale-aware transliteration. When set, locale-specific
|
|
325
|
+
* character replacements are applied *before* the global charmap, so e.g.
|
|
326
|
+
* German `ö` becomes `oe` instead of `o`, and Turkish `ı` becomes `i`.
|
|
327
|
+
*
|
|
328
|
+
* Only the primary subtag is considered (case-insensitively), so `"de-DE"`
|
|
329
|
+
* resolves to `"de"`. Unknown locales fall back to the global charmap.
|
|
330
|
+
*
|
|
331
|
+
* Supported locales: `de`, `da`, `nb`, `sr`, `tr`, `vi`. Use `replaceBefore`
|
|
332
|
+
* for any additional custom mappings.
|
|
333
|
+
* @default undefined
|
|
334
|
+
*/
|
|
335
|
+
locale?: string;
|
|
336
|
+
/**
|
|
324
337
|
* Whether the result should be converted into lowercase.
|
|
325
|
-
* Cannot be true if `uppercase` is true.
|
|
338
|
+
* Cannot be true if `uppercase` is true. Passing both `lowercase: true` and
|
|
339
|
+
* `uppercase: true` throws a `TypeError`.
|
|
326
340
|
* @default true
|
|
327
341
|
*/
|
|
328
342
|
lowercase?: boolean;
|
|
@@ -343,4 +357,4 @@ interface SlugifyOptions extends OptionsTransliterate {
|
|
|
343
357
|
*/
|
|
344
358
|
uppercase?: boolean;
|
|
345
359
|
}
|
|
346
|
-
export { All as A, CharAt as C, EndsWith as E,
|
|
360
|
+
export { All as A, CharAt as C, EndsWith as E, Includes as I, Join as J, Length as L, Math as M, NodeLocale as N, OptionReplaceArray as O, PadEnd as P, Repeat as R, Slice as S, ToLowerCase as T, Any as a, Charmap as b, Concat as c, Interval as d, IntervalArray as e, IsBooleanLiteral as f, IsNumberLiteral as g, IsStringLiteral as h, IsStringLiteralArray as i, OptionReplaceCombined as j, OptionReplaceObject as k, OptionsTransliterate as l, PadStart as m, Replace as n, ReplaceAll as o, Reverse as p, SlugifyOptions as q, Split as r, StartsWith as s, ToUpperCase as t, Trim as u, TrimEnd as v, TrimStart as w };
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { N as NodeLocale, h as IsStringLiteral } from "./types.d-CmNvyl4l.js";
|
|
2
|
+
declare class LRUCache<K, V> {
|
|
3
|
+
private readonly capacity;
|
|
4
|
+
private readonly cache;
|
|
5
|
+
constructor(capacity: number);
|
|
6
|
+
get(key: K): V | undefined;
|
|
7
|
+
has(key: K): boolean;
|
|
8
|
+
set(key: K, value: V): void;
|
|
9
|
+
delete(key: K): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
size(): number;
|
|
12
|
+
}
|
|
3
13
|
/**
|
|
4
14
|
* Valid characters used to split strings into words.
|
|
5
15
|
* Used by various case conversion functions to identify word boundaries.
|
|
@@ -389,4 +399,4 @@ type IdentifyCase<T extends string> = IsStringLiteral<T> extends true ? T extend
|
|
|
389
399
|
* type Split4 = SplitByCase<'simpletext'> // type Split4 = ['simpletext']
|
|
390
400
|
*/
|
|
391
401
|
type SplitByCase<T, Separator extends string = SplitterCharacter, Accumulator extends unknown[] = []> = string extends Separator ? string[] : T extends `${infer F}${infer R}` ? [LastOfArray<Accumulator>] extends [never] ? SplitByCase<R, Separator, [F]> : LastOfArray<Accumulator> extends string ? R extends "" ? SplitByCase<R, Separator, [...RemoveLastOfArray<Accumulator>, `${LastOfArray<Accumulator>}${F}`]> : SameLetterCase<F, FirstOfString<R>> extends true ? F extends Separator ? FirstOfString<R> extends Separator ? SplitByCase<R, Separator, [...Accumulator, ""]> : IsUpperCase<FirstOfString<R>> extends true ? SplitByCase<RemoveFirstOfString<R>, Separator, [...Accumulator, FirstOfString<R>]> : SplitByCase<R, Separator, [...Accumulator, ""]> : SplitByCase<R, Separator, [...RemoveLastOfArray<Accumulator>, `${LastOfArray<Accumulator>}${F}`]> : IsLowerCase<F> extends true ? SplitByCase<RemoveFirstOfString<R>, Separator, [...RemoveLastOfArray<Accumulator>, `${LastOfArray<Accumulator>}${F}`, FirstOfString<R>]> : SplitByCase<R, Separator, [...Accumulator, F]> : never : Accumulator extends [] ? T extends "" ? [] : string[] : Accumulator;
|
|
392
|
-
export {
|
|
402
|
+
export { CamelCase as C, DotCase as D, FlatCase as F, IdentifyCase as I, KebabCase as K, LocaleOptions as L, NoCase as N, PascalCase as P, SentenceCase as S, TitleCase as T, UpperFirst as U, CapitalCase as a, CaseOptions as b, ConstantCase as c, FlipCase as d, LowerFirst as e, PascalSnakeCase as f, PathCase as g, SnakeCase as h, SplitByCase as i, TrainCase as j };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { O as OptionReplaceArray, e as IntervalArray } from "./packem_shared/types.d-CmNvyl4l.js";
|
|
2
|
+
/**
|
|
3
|
+
* Performs multiple string or RegExp replacements using a refined pre-processing approach.
|
|
4
|
+
* @param source The string to search and replace in.
|
|
5
|
+
* @param searches An array of search/replace pairs.
|
|
6
|
+
* @param ignoreRanges An array of ignored ranges.
|
|
7
|
+
* @returns The string with replacements applied.
|
|
8
|
+
*/
|
|
9
|
+
declare const replaceString: (source: string, searches: OptionReplaceArray, ignoreRanges: IntervalArray) => string;
|
|
10
|
+
export { replaceString as default };
|
package/dist/slice.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as I,e as k,R as L}from"./packem_shared/constants-B7EE3d7a.js";import{getStringWidth as w}from"./get-string-width.js";import{i as v}from"./packem_shared/lru-cache-BtMSrYQJ.js";const R=new v(100),N=new Intl.Segmenter("en",{granularity:"grapheme"}),O=/^[\u0000-\u007F]*$/,j=new Set(["0","22","23","24","27","28","29","39","49"]),y=new Set(["1","3","4","7","8","9"]),A=new Map([["22","1"],["23","3"],["24","4"],["27","7"],["28","8"],["29","9"]]),b=t=>t>="30"&&t<="37"||t>="90"&&t<="97"||t.startsWith("38;"),S=t=>t>="40"&&t<="47"||t>="100"&&t<="107"||t.startsWith("48;"),M=[{close:"\x1B[22m",open:"\x1B[1m"},{close:"\x1B[23m",open:"\x1B[3m"},{close:"\x1B[24m",open:"\x1B[4m"},{close:"\x1B[27m",open:"\x1B[7m"},{close:"\x1B[28m",open:"\x1B[8m"},{close:"\x1B[29m",open:"\x1B[9m"}],E=(t,h)=>{let l=-1;for(const u of h){const c=t.indexOf(u);c!==-1&&(l===-1||c<l)&&(l=c)}return l},F=(t,h)=>{if(!t.includes("\x1B"))return[{after:"",before:"",content:t,visibleLength:w(t,h.width)}];const l=R.get(t);if(l)return l;const u=[],c=[];let W=0,B;for(L.lastIndex=0;(B=L.exec(t))!==null;){const r=B[0];u.push(t.slice(W,B.index)),c.push(r),W=B.index+r.length}W<t.length&&u.push(t.slice(W));const m=[];for(const r of c){if(r==="\x1B[0m"||r==="\x1B]8;;\x07"){m.push(r);continue}if(r.startsWith("\x1B[")&&r.endsWith("m")){const x=r.slice(2,-1);if(j.has(x)){m.push(r);continue}}}const s=new Set,a=[];for(const[r,x]of u.entries()){if(r>0&&c[r-1]){const n=c[r-1];if(n==="\x1B[0m")s.clear();else if(n==="\x1B]8;;\x07"){for(const i of s)if(i.startsWith("\x1B]8;;")&&!i.endsWith("\x1B]8;;\x07")){s.delete(i);break}}else if(n.startsWith("\x1B[")&&n.endsWith("m")){const i=n.slice(2,-1);if(i==="39"){for(const e of s)if(e.startsWith("\x1B[")&&e.endsWith("m")){const f=e.slice(2,-1);if(b(f)){s.delete(e);break}}}else if(i==="49"){for(const e of s)if(e.startsWith("\x1B[")&&e.endsWith("m")){const f=e.slice(2,-1);if(S(f)){s.delete(e);break}}}else if(A.has(i)){const e=A.get(i);for(const f of s)if(f===`\x1B[${e}m`){s.delete(f);break}}else{if(b(i)){for(const e of s)if(e.startsWith("\x1B[")&&e.endsWith("m")){const f=e.slice(2,-1);if(b(f)){s.delete(e);break}}}else if(S(i)){for(const e of s)if(e.startsWith("\x1B[")&&e.endsWith("m")){const f=e.slice(2,-1);if(S(f)){s.delete(e);break}}}else if(y.has(i)){const e=`\x1B[${i}m`;s.has(e)&&s.delete(e)}s.add(n)}}else if(n.startsWith("\x1B]8;;")&&!n.endsWith("\x1B]8;;\x07")){for(const i of s)if(i.startsWith("\x1B]8;;")&&!i.endsWith("\x1B]8;;\x07")){s.delete(i);break}s.add(n)}}if(x==="")continue;let d="";if(s.size>0)if(m.includes("\x1B[0m"))d="\x1B[0m";else{const n=[];let i=!1;for(const o of s)if(o.startsWith("\x1B]8;;")&&!o.endsWith("\x1B]8;;\x07")){i=!0;break}i&&m.includes("\x1B]8;;\x07")&&n.push("\x1B]8;;\x07");let e=!1,f=!1;for(const o of s)if(o.startsWith("\x1B[")&&o.endsWith("m")){const g=o.slice(2,-1);b(g)?e=!0:S(g)&&(f=!0)}if(e&&f){const o=E(t,["\x1B[3","\x1B[9","\x1B[38;"]),g=E(t,["\x1B[4","\x1B[10","\x1B[48;"]);o>=0&&g>=0?o>g?n.push("\x1B[39m","\x1B[49m"):n.push("\x1B[49m","\x1B[39m"):n.push("\x1B[39m","\x1B[49m")}else e&&n.push("\x1B[39m"),f&&n.push("\x1B[49m");e&&f&&t.includes("\x1B[39m")&&t.includes("\x1B[49m")&&(t.indexOf("\x1B[39m")<t.indexOf("\x1B[49m")?(n.length-=2,n.push("\x1B[39m","\x1B[49m")):t.indexOf("\x1B[49m")<t.indexOf("\x1B[39m")&&(n.length-=2,n.push("\x1B[49m","\x1B[39m")));const _=M.filter(o=>s.has(o.open)).map(o=>({position:t.indexOf(o.open),style:o})).filter(o=>o.position>=0).toSorted((o,g)=>g.position-o.position);for(const o of _){const g=o;m.includes(g.style.close)&&n.push(g.style.close)}d=n.join("")}const p=[...s].join("");a.push({after:d,before:p,content:x,visibleLength:w(x,{fullWidth:1,wideWidth:1})})}return R.set(t,a),a},P=(t,h,l,u)=>{const c=[...u.segmenter.segment(t)],W=[];let B=0,m=!1;for(const s of c){const a=w(s.segment,u.width),r=B,x=B+a;if(!m)if(r<h){B=x;continue}else m=!0;if(r>=l||x>l)break;W.push(s.segment),B=x}return W.join("")},T=(t,h=0,l=Number.MAX_SAFE_INTEGER,u={})=>{const c={segmenter:N,...u};if(h>=l||t==="")return"";const W=w(t,c.width);if(h===0&&l>=W)return t;if(h<0||l<0)throw new RangeError("Negative indices aren't supported");if(!t.includes("\x1B"))return O.test(t)?t.slice(h,l):P(t,h,l,c);if(I.lastIndex=0,k.lastIndex=0,!I.test(t)&&!k.test(t))return t;const B=F(t,c);if(B.length===0)return"";let m=0;const s=[];for(const[x,d]of B.entries()){const p=m,n=m+d.visibleLength;if(n>h&&p<l){const i=Math.max(0,h-p),e=Math.min(d.visibleLength,l-p);s.push({end:e,index:x,segment:d,start:i})}m=n}if(s.length===0)return"";const a=[],r=s[0].segment;a.push(r.before);for(let x=0;x<s.length;x++){const{end:d,segment:p,start:n}=s[x];if(n===0&&d===p.visibleLength)a.push(p.content);else{const i=[...c.segmenter.segment(p.content)];a.push(i.slice(n,d).map(e=>e.segment).join(""))}if(x<s.length-1){const i=s[x+1].segment,e=p.after,f=i.before;e!==f&&(e||f)&&a.push(e,f)}}return a.push(s.at(-1).segment.after),a.join("")};export{T as slice};
|
package/dist/slugify.d.ts
CHANGED
package/dist/slugify.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import c from"./transliterate.js";import{escapeRegExp as t}from"./utilities.js";const p={da:{Å:"AA",å:"aa",Æ:"AE",æ:"ae",Ø:"OE",ø:"oe"},de:{Ä:"AE",ä:"ae",Ö:"OE",ö:"oe",ß:"ss",Ü:"UE",ü:"ue"},nb:{Å:"AA",å:"aa",Æ:"AE",æ:"ae",Ø:"OE",ø:"oe"},sr:{Ć:"C",ć:"c",Č:"C",č:"c",Đ:"DJ",đ:"dj",Š:"S",š:"s",Ž:"Z",ž:"z"},tr:{Ç:"C",ç:"c",Ğ:"G",ğ:"g",I:"I",İ:"I",ı:"i",Ö:"O",ö:"o",Ş:"S",ş:"s",Ü:"U",ü:"u"},vi:{Đ:"D",đ:"d"}},n=a=>{const s=a.split("-")[0]?.toLowerCase()??"",e=p[s];return e?Object.entries(e):[]},i=(a,s)=>{const e=a?n(a):[],r=Array.isArray(s)?s:Object.entries(s??{});return[...e,...r]},u=(a,s,e)=>{const r=t(s).replaceAll(String.raw`\-`,"-"),o=new RegExp(`[^${r}]`,"g");return a.replaceAll(o,e)},f=(a,s)=>{const e={allowedChars:"a-zA-Z0-9-_.~",fixChineseSpacing:!0,ignore:[],lowercase:!0,replaceAfter:[],replaceBefore:[],separator:"-",transliterate:!0,trim:!1,unknown:"",uppercase:!1,...s};if(e.lowercase&&e.uppercase)throw new TypeError("slugify: The `lowercase` and `uppercase` options are mutually exclusive; enable at most one.");e.replaceBefore=i(e.locale??"",e.replaceBefore);let r=e.transliterate?c(a,e):a.normalize("NFC");e.lowercase?r=r.toLowerCase():e.uppercase&&(r=r.toUpperCase()),r=u(r,e.allowedChars,e.separator);const o=t(e.separator);if(o){const l=new RegExp(`${o}+`,"g");r=r.replace(l,e.separator)}return o?r.replaceAll(new RegExp(`^${o}+|${o}+$`,"g"),""):r};export{f as default};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { l as OptionsTransliterate } from "./packem_shared/types.d-CmNvyl4l.js";
|
|
2
|
+
/**
|
|
3
|
+
* Main transliterate function.
|
|
4
|
+
* Replaces characters in a string based on a charmap and options.
|
|
5
|
+
* @param source The string which is being transliterated.
|
|
6
|
+
* @param options Options object.
|
|
7
|
+
* @returns The transliterated string.
|
|
8
|
+
*/
|
|
9
|
+
declare const transliterate: (source: string, options?: OptionsTransliterate) => string;
|
|
10
|
+
export { transliterate as default };
|