@visulima/string 1.0.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +201 -2
  3. package/dist/case/camel-case.d.cts +3 -3
  4. package/dist/case/camel-case.d.mts +3 -3
  5. package/dist/case/camel-case.d.ts +3 -3
  6. package/dist/case/capital-case.d.cts +3 -3
  7. package/dist/case/capital-case.d.mts +3 -3
  8. package/dist/case/capital-case.d.ts +3 -3
  9. package/dist/case/constant-case.d.cts +3 -3
  10. package/dist/case/constant-case.d.mts +3 -3
  11. package/dist/case/constant-case.d.ts +3 -3
  12. package/dist/case/dot-case.d.cts +3 -3
  13. package/dist/case/dot-case.d.mts +3 -3
  14. package/dist/case/dot-case.d.ts +3 -3
  15. package/dist/case/flat-case.d.cts +3 -3
  16. package/dist/case/flat-case.d.mts +3 -3
  17. package/dist/case/flat-case.d.ts +3 -3
  18. package/dist/case/flip-case.d.cts +3 -3
  19. package/dist/case/flip-case.d.mts +3 -3
  20. package/dist/case/flip-case.d.ts +3 -3
  21. package/dist/case/identify-case.cjs +47 -8
  22. package/dist/case/identify-case.d.cts +3 -3
  23. package/dist/case/identify-case.d.mts +3 -3
  24. package/dist/case/identify-case.d.ts +3 -3
  25. package/dist/case/identify-case.mjs +47 -8
  26. package/dist/case/index.d.cts +3 -3
  27. package/dist/case/index.d.mts +3 -3
  28. package/dist/case/index.d.ts +3 -3
  29. package/dist/case/kebab-case.d.cts +3 -3
  30. package/dist/case/kebab-case.d.mts +3 -3
  31. package/dist/case/kebab-case.d.ts +3 -3
  32. package/dist/case/lower-first.d.cts +3 -3
  33. package/dist/case/lower-first.d.mts +3 -3
  34. package/dist/case/lower-first.d.ts +3 -3
  35. package/dist/case/no-case.d.cts +3 -3
  36. package/dist/case/no-case.d.mts +3 -3
  37. package/dist/case/no-case.d.ts +3 -3
  38. package/dist/case/pascal-case.d.cts +3 -3
  39. package/dist/case/pascal-case.d.mts +3 -3
  40. package/dist/case/pascal-case.d.ts +3 -3
  41. package/dist/case/pascal-snake-case.d.cts +3 -3
  42. package/dist/case/pascal-snake-case.d.mts +3 -3
  43. package/dist/case/pascal-snake-case.d.ts +3 -3
  44. package/dist/case/path-case.d.cts +3 -3
  45. package/dist/case/path-case.d.mts +3 -3
  46. package/dist/case/path-case.d.ts +3 -3
  47. package/dist/case/sentence-case.d.cts +3 -3
  48. package/dist/case/sentence-case.d.mts +3 -3
  49. package/dist/case/sentence-case.d.ts +3 -3
  50. package/dist/case/snake-case.d.cts +3 -3
  51. package/dist/case/snake-case.d.mts +3 -3
  52. package/dist/case/snake-case.d.ts +3 -3
  53. package/dist/case/split-by-case.d.cts +3 -3
  54. package/dist/case/split-by-case.d.mts +3 -3
  55. package/dist/case/split-by-case.d.ts +3 -3
  56. package/dist/case/title-case.d.cts +3 -3
  57. package/dist/case/title-case.d.mts +3 -3
  58. package/dist/case/title-case.d.ts +3 -3
  59. package/dist/case/train-case.d.cts +3 -3
  60. package/dist/case/train-case.d.mts +3 -3
  61. package/dist/case/train-case.d.ts +3 -3
  62. package/dist/case/upper-first.d.cts +3 -3
  63. package/dist/case/upper-first.d.mts +3 -3
  64. package/dist/case/upper-first.d.ts +3 -3
  65. package/dist/index.cjs +6 -0
  66. package/dist/index.d.cts +11 -4
  67. package/dist/index.d.mts +11 -4
  68. package/dist/index.d.ts +11 -4
  69. package/dist/index.mjs +3 -0
  70. package/dist/native-string-types.d.cts +1 -1
  71. package/dist/native-string-types.d.mts +1 -1
  72. package/dist/native-string-types.d.ts +1 -1
  73. package/dist/packem_shared/lru-cache-B_t27XwI.d.cts +14 -0
  74. package/dist/packem_shared/lru-cache-B_t27XwI.d.mts +14 -0
  75. package/dist/packem_shared/lru-cache-B_t27XwI.d.ts +14 -0
  76. package/dist/packem_shared/replaceString-C7Dp5vAg.mjs +200 -0
  77. package/dist/packem_shared/replaceString-iYo1cDfZ.cjs +202 -0
  78. package/dist/packem_shared/slugify-B9zJ8G7m.cjs +50 -0
  79. package/dist/packem_shared/slugify-C7by01BU.mjs +48 -0
  80. package/dist/packem_shared/transliterate-BUI0uSNe.cjs +46092 -0
  81. package/dist/packem_shared/transliterate-DPctxBml.mjs +46090 -0
  82. package/dist/packem_shared/{types-BttWSSIk.d.ts → types-C5Pk8B8Q.d.cts} +3 -3
  83. package/dist/packem_shared/{types-BAd3WDHo.d.mts → types-DcGtApe2.d.ts} +3 -3
  84. package/dist/packem_shared/{types-BNbQJg02.d.cts → types-DmfKbIaI.d.cts} +23 -1
  85. package/dist/packem_shared/{types-BNbQJg02.d.mts → types-DmfKbIaI.d.mts} +23 -1
  86. package/dist/packem_shared/{types-BNbQJg02.d.ts → types-DmfKbIaI.d.ts} +23 -1
  87. package/dist/packem_shared/{types-D2-6p7t1.d.cts → types-_jqW_ZOt.d.mts} +3 -3
  88. package/dist/truncate.cjs +1 -0
  89. package/dist/truncate.mjs +1 -0
  90. package/dist/utils.cjs +57 -1
  91. package/dist/utils.d.cts +9 -13
  92. package/dist/utils.d.mts +9 -13
  93. package/dist/utils.d.ts +9 -13
  94. package/dist/utils.mjs +55 -0
  95. package/package.json +4 -4
@@ -1,5 +1,5 @@
1
- import { N as NodeLocale, m as IsStringLiteral } from './types-BNbQJg02.js';
2
- import { LRUCache } from '../utils.js';
1
+ import { N as NodeLocale, j as IsStringLiteral } from './types-DmfKbIaI.cjs';
2
+ import { L as LRUCache } from './lru-cache-B_t27XwI.cjs';
3
3
 
4
4
  type SplitterCharacter = " " | "_" | "-" | "." | "/";
5
5
  type LastOfArray<T extends any[]> = T extends [...any, infer R] ? R : never;
@@ -56,4 +56,4 @@ type PascalSnakeCase<T extends string> = T & {
56
56
  type IdentifyCase<T extends string> = IsStringLiteral<T> extends true ? T extends Lowercase<T> ? T extends `${string}_${string}` ? "snake" : T extends `${string}-${string}` ? "kebab" : T extends `${string}${string}` ? "flat" : "lower" : T extends Uppercase<T> ? "upper" : T extends Capitalize<string> ? T extends `${Uppercase<string>}${string}` ? T extends `${string}-${string}` ? "train" : "pascal" : T extends `${Lowercase<string>}${Capitalize<string>}` ? "camel" : T extends `${Capitalize<string>} ${Lowercase<string>}` ? "title" : "mixed" : "mixed" : string;
57
57
  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;
58
58
 
59
- export type { 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 };
59
+ export type { CaseOptions 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, CamelCase as a, CapitalCase 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 };
@@ -1,5 +1,5 @@
1
- import { N as NodeLocale, m as IsStringLiteral } from './types-BNbQJg02.mjs';
2
- import { LRUCache } from '../utils.mjs';
1
+ import { N as NodeLocale, j as IsStringLiteral } from './types-DmfKbIaI.js';
2
+ import { L as LRUCache } from './lru-cache-B_t27XwI.js';
3
3
 
4
4
  type SplitterCharacter = " " | "_" | "-" | "." | "/";
5
5
  type LastOfArray<T extends any[]> = T extends [...any, infer R] ? R : never;
@@ -56,4 +56,4 @@ type PascalSnakeCase<T extends string> = T & {
56
56
  type IdentifyCase<T extends string> = IsStringLiteral<T> extends true ? T extends Lowercase<T> ? T extends `${string}_${string}` ? "snake" : T extends `${string}-${string}` ? "kebab" : T extends `${string}${string}` ? "flat" : "lower" : T extends Uppercase<T> ? "upper" : T extends Capitalize<string> ? T extends `${Uppercase<string>}${string}` ? T extends `${string}-${string}` ? "train" : "pascal" : T extends `${Lowercase<string>}${Capitalize<string>}` ? "camel" : T extends `${Capitalize<string>} ${Lowercase<string>}` ? "title" : "mixed" : "mixed" : string;
57
57
  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;
58
58
 
59
- export type { 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 };
59
+ export type { CaseOptions 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, CamelCase as a, CapitalCase 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 };
@@ -37,5 +37,27 @@ type Trim<T extends string> = TrimEnd<TrimStart<T>>;
37
37
  type NodeLocale = "af" | "am" | "ar" | "az" | "be" | "bg" | "bn" | "bs" | "ca" | "cs" | "cy" | "da" | "de" | "el" | "en" | "en-AU" | "en-CA" | "en-GB" | "en-US" | "es" | "es-ES" | "et" | "fa" | "fi" | "fil" | "fr" | "ga" | "gl" | "gu" | "he" | "hi" | "hr" | "hu" | "hy" | "id" | "is" | "it" | "ja" | "ka" | "kk" | "km" | "kn" | "ko" | "ky" | "lo" | "lt" | "lv" | "mk" | "ml" | "mn" | "mr" | "ms" | "mt" | "ne" | "nl" | "no" | "pa" | "pl" | "pt" | "pt-BR" | "pt-PT" | "ro" | "ru" | "si" | "sk" | "sl" | "sq" | "sr" | "sv" | "ta" | "te" | "th" | "tr" | "uk" | "ur" | "uz" | "vi" | "zh" | "zh-CN" | "zh-HK" | "zh-TW";
38
38
  type ToLowerCase<T extends string> = IsStringLiteral<T> extends true ? Lowercase<T> : string;
39
39
  type ToUpperCase<T extends string> = IsStringLiteral<T> extends true ? Uppercase<T> : string;
40
+ type Interval = [number, number];
41
+ type IntervalArray = Interval[];
42
+ type OptionReplaceArray = [RegExp | string, string | undefined][];
43
+ type OptionReplaceObject = Record<string, string>;
44
+ type OptionReplaceCombined = OptionReplaceArray | OptionReplaceObject;
45
+ interface OptionsTransliterate {
46
+ fixChineseSpacing?: boolean;
47
+ ignore?: string[];
48
+ replaceAfter?: OptionReplaceCombined;
49
+ replaceBefore?: OptionReplaceCombined;
50
+ trim?: boolean;
51
+ unknown?: string;
52
+ }
53
+ type Charmap = Record<string, string | undefined>;
54
+ interface SlugifyOptions extends OptionsTransliterate {
55
+ allowedChars?: string;
56
+ fixChineseSpacing?: boolean;
57
+ lowercase?: boolean;
58
+ separator?: string;
59
+ transliterate?: boolean;
60
+ uppercase?: boolean;
61
+ }
40
62
 
41
- export { type All as A, type CharAt as C, type EndsWith as E, type Includes as I, type Join as J, type Length as L, Math as M, type NodeLocale as N, type PadEnd as P, type Replace as R, type Slice as S, type ToLowerCase as T, type Concat as a, type PadStart as b, type ReplaceAll as c, type Split as d, type StartsWith as e, type ToUpperCase as f, type Trim as g, type TrimEnd as h, type TrimStart as i, type Any as j, type IsBooleanLiteral as k, type IsNumberLiteral as l, type IsStringLiteral as m, type IsStringLiteralArray as n, type Repeat as o, type Reverse as p };
63
+ export { type All as A, type CharAt as C, type EndsWith as E, type Includes as I, type Join as J, type Length as L, Math as M, type NodeLocale as N, type OptionReplaceArray as O, type PadEnd as P, type Replace as R, type Slice as S, type ToLowerCase as T, type Concat as a, type PadStart as b, type ReplaceAll as c, type Split as d, type StartsWith as e, type ToUpperCase as f, type Trim as g, type TrimEnd as h, type TrimStart as i, type IsStringLiteral as j, type IntervalArray as k, type SlugifyOptions as l, type OptionsTransliterate as m, type Any as n, type Charmap as o, type Interval as p, type IsBooleanLiteral as q, type IsNumberLiteral as r, type IsStringLiteralArray as s, type OptionReplaceCombined as t, type OptionReplaceObject as u, type Repeat as v, type Reverse as w };
@@ -37,5 +37,27 @@ type Trim<T extends string> = TrimEnd<TrimStart<T>>;
37
37
  type NodeLocale = "af" | "am" | "ar" | "az" | "be" | "bg" | "bn" | "bs" | "ca" | "cs" | "cy" | "da" | "de" | "el" | "en" | "en-AU" | "en-CA" | "en-GB" | "en-US" | "es" | "es-ES" | "et" | "fa" | "fi" | "fil" | "fr" | "ga" | "gl" | "gu" | "he" | "hi" | "hr" | "hu" | "hy" | "id" | "is" | "it" | "ja" | "ka" | "kk" | "km" | "kn" | "ko" | "ky" | "lo" | "lt" | "lv" | "mk" | "ml" | "mn" | "mr" | "ms" | "mt" | "ne" | "nl" | "no" | "pa" | "pl" | "pt" | "pt-BR" | "pt-PT" | "ro" | "ru" | "si" | "sk" | "sl" | "sq" | "sr" | "sv" | "ta" | "te" | "th" | "tr" | "uk" | "ur" | "uz" | "vi" | "zh" | "zh-CN" | "zh-HK" | "zh-TW";
38
38
  type ToLowerCase<T extends string> = IsStringLiteral<T> extends true ? Lowercase<T> : string;
39
39
  type ToUpperCase<T extends string> = IsStringLiteral<T> extends true ? Uppercase<T> : string;
40
+ type Interval = [number, number];
41
+ type IntervalArray = Interval[];
42
+ type OptionReplaceArray = [RegExp | string, string | undefined][];
43
+ type OptionReplaceObject = Record<string, string>;
44
+ type OptionReplaceCombined = OptionReplaceArray | OptionReplaceObject;
45
+ interface OptionsTransliterate {
46
+ fixChineseSpacing?: boolean;
47
+ ignore?: string[];
48
+ replaceAfter?: OptionReplaceCombined;
49
+ replaceBefore?: OptionReplaceCombined;
50
+ trim?: boolean;
51
+ unknown?: string;
52
+ }
53
+ type Charmap = Record<string, string | undefined>;
54
+ interface SlugifyOptions extends OptionsTransliterate {
55
+ allowedChars?: string;
56
+ fixChineseSpacing?: boolean;
57
+ lowercase?: boolean;
58
+ separator?: string;
59
+ transliterate?: boolean;
60
+ uppercase?: boolean;
61
+ }
40
62
 
41
- export { type All as A, type CharAt as C, type EndsWith as E, type Includes as I, type Join as J, type Length as L, Math as M, type NodeLocale as N, type PadEnd as P, type Replace as R, type Slice as S, type ToLowerCase as T, type Concat as a, type PadStart as b, type ReplaceAll as c, type Split as d, type StartsWith as e, type ToUpperCase as f, type Trim as g, type TrimEnd as h, type TrimStart as i, type Any as j, type IsBooleanLiteral as k, type IsNumberLiteral as l, type IsStringLiteral as m, type IsStringLiteralArray as n, type Repeat as o, type Reverse as p };
63
+ export { type All as A, type CharAt as C, type EndsWith as E, type Includes as I, type Join as J, type Length as L, Math as M, type NodeLocale as N, type OptionReplaceArray as O, type PadEnd as P, type Replace as R, type Slice as S, type ToLowerCase as T, type Concat as a, type PadStart as b, type ReplaceAll as c, type Split as d, type StartsWith as e, type ToUpperCase as f, type Trim as g, type TrimEnd as h, type TrimStart as i, type IsStringLiteral as j, type IntervalArray as k, type SlugifyOptions as l, type OptionsTransliterate as m, type Any as n, type Charmap as o, type Interval as p, type IsBooleanLiteral as q, type IsNumberLiteral as r, type IsStringLiteralArray as s, type OptionReplaceCombined as t, type OptionReplaceObject as u, type Repeat as v, type Reverse as w };
@@ -37,5 +37,27 @@ type Trim<T extends string> = TrimEnd<TrimStart<T>>;
37
37
  type NodeLocale = "af" | "am" | "ar" | "az" | "be" | "bg" | "bn" | "bs" | "ca" | "cs" | "cy" | "da" | "de" | "el" | "en" | "en-AU" | "en-CA" | "en-GB" | "en-US" | "es" | "es-ES" | "et" | "fa" | "fi" | "fil" | "fr" | "ga" | "gl" | "gu" | "he" | "hi" | "hr" | "hu" | "hy" | "id" | "is" | "it" | "ja" | "ka" | "kk" | "km" | "kn" | "ko" | "ky" | "lo" | "lt" | "lv" | "mk" | "ml" | "mn" | "mr" | "ms" | "mt" | "ne" | "nl" | "no" | "pa" | "pl" | "pt" | "pt-BR" | "pt-PT" | "ro" | "ru" | "si" | "sk" | "sl" | "sq" | "sr" | "sv" | "ta" | "te" | "th" | "tr" | "uk" | "ur" | "uz" | "vi" | "zh" | "zh-CN" | "zh-HK" | "zh-TW";
38
38
  type ToLowerCase<T extends string> = IsStringLiteral<T> extends true ? Lowercase<T> : string;
39
39
  type ToUpperCase<T extends string> = IsStringLiteral<T> extends true ? Uppercase<T> : string;
40
+ type Interval = [number, number];
41
+ type IntervalArray = Interval[];
42
+ type OptionReplaceArray = [RegExp | string, string | undefined][];
43
+ type OptionReplaceObject = Record<string, string>;
44
+ type OptionReplaceCombined = OptionReplaceArray | OptionReplaceObject;
45
+ interface OptionsTransliterate {
46
+ fixChineseSpacing?: boolean;
47
+ ignore?: string[];
48
+ replaceAfter?: OptionReplaceCombined;
49
+ replaceBefore?: OptionReplaceCombined;
50
+ trim?: boolean;
51
+ unknown?: string;
52
+ }
53
+ type Charmap = Record<string, string | undefined>;
54
+ interface SlugifyOptions extends OptionsTransliterate {
55
+ allowedChars?: string;
56
+ fixChineseSpacing?: boolean;
57
+ lowercase?: boolean;
58
+ separator?: string;
59
+ transliterate?: boolean;
60
+ uppercase?: boolean;
61
+ }
40
62
 
41
- export { type All as A, type CharAt as C, type EndsWith as E, type Includes as I, type Join as J, type Length as L, Math as M, type NodeLocale as N, type PadEnd as P, type Replace as R, type Slice as S, type ToLowerCase as T, type Concat as a, type PadStart as b, type ReplaceAll as c, type Split as d, type StartsWith as e, type ToUpperCase as f, type Trim as g, type TrimEnd as h, type TrimStart as i, type Any as j, type IsBooleanLiteral as k, type IsNumberLiteral as l, type IsStringLiteral as m, type IsStringLiteralArray as n, type Repeat as o, type Reverse as p };
63
+ export { type All as A, type CharAt as C, type EndsWith as E, type Includes as I, type Join as J, type Length as L, Math as M, type NodeLocale as N, type OptionReplaceArray as O, type PadEnd as P, type Replace as R, type Slice as S, type ToLowerCase as T, type Concat as a, type PadStart as b, type ReplaceAll as c, type Split as d, type StartsWith as e, type ToUpperCase as f, type Trim as g, type TrimEnd as h, type TrimStart as i, type IsStringLiteral as j, type IntervalArray as k, type SlugifyOptions as l, type OptionsTransliterate as m, type Any as n, type Charmap as o, type Interval as p, type IsBooleanLiteral as q, type IsNumberLiteral as r, type IsStringLiteralArray as s, type OptionReplaceCombined as t, type OptionReplaceObject as u, type Repeat as v, type Reverse as w };
@@ -1,5 +1,5 @@
1
- import { N as NodeLocale, m as IsStringLiteral } from './types-BNbQJg02.cjs';
2
- import { LRUCache } from '../utils.cjs';
1
+ import { N as NodeLocale, j as IsStringLiteral } from './types-DmfKbIaI.mjs';
2
+ import { L as LRUCache } from './lru-cache-B_t27XwI.mjs';
3
3
 
4
4
  type SplitterCharacter = " " | "_" | "-" | "." | "/";
5
5
  type LastOfArray<T extends any[]> = T extends [...any, infer R] ? R : never;
@@ -56,4 +56,4 @@ type PascalSnakeCase<T extends string> = T & {
56
56
  type IdentifyCase<T extends string> = IsStringLiteral<T> extends true ? T extends Lowercase<T> ? T extends `${string}_${string}` ? "snake" : T extends `${string}-${string}` ? "kebab" : T extends `${string}${string}` ? "flat" : "lower" : T extends Uppercase<T> ? "upper" : T extends Capitalize<string> ? T extends `${Uppercase<string>}${string}` ? T extends `${string}-${string}` ? "train" : "pascal" : T extends `${Lowercase<string>}${Capitalize<string>}` ? "camel" : T extends `${Capitalize<string>} ${Lowercase<string>}` ? "title" : "mixed" : "mixed" : string;
57
57
  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;
58
58
 
59
- export type { 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 };
59
+ export type { CaseOptions 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, CamelCase as a, CapitalCase 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 };
package/dist/truncate.cjs CHANGED
@@ -33,6 +33,7 @@ const truncate = /* @__PURE__ */ __name((input, limit, options = {}) => {
33
33
  if (input === "" || limit <= 0) {
34
34
  return "";
35
35
  }
36
+ input = input.normalize("NFC");
36
37
  const { ellipsis = DEFAULT_ELLIPSIS, position = "end", preferTruncationOnSpace = false } = options;
37
38
  let ellipsisWidth = options.ellipsisWidth ?? ellipsis === DEFAULT_ELLIPSIS ? 1 : void 0;
38
39
  if (ellipsisWidth === void 0) {
package/dist/truncate.mjs CHANGED
@@ -29,6 +29,7 @@ const truncate = /* @__PURE__ */ __name((input, limit, options = {}) => {
29
29
  if (input === "" || limit <= 0) {
30
30
  return "";
31
31
  }
32
+ input = input.normalize("NFC");
32
33
  const { ellipsis = DEFAULT_ELLIPSIS, position = "end", preferTruncationOnSpace = false } = options;
33
34
  let ellipsisWidth = options.ellipsisWidth ?? ellipsis === DEFAULT_ELLIPSIS ? 1 : void 0;
34
35
  if (ellipsisWidth === void 0) {
package/dist/utils.cjs CHANGED
@@ -4,6 +4,62 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
4
4
 
5
5
  const LRUCache = require('./packem_shared/LRUCache-Crb-m7cw.cjs');
6
6
 
7
-
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ const escapeRegExp = /* @__PURE__ */ __name((char) => (
10
+ // $& means the whole matched string
11
+ char.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&")
12
+ ), "escapeRegExp");
13
+ const inRange = /* @__PURE__ */ __name((number_, ranges) => ranges.some((range) => number_ >= range[0] && number_ <= range[1]), "inRange");
14
+ const hasChinese = /* @__PURE__ */ __name((char) => /[\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u3005\u3007\u3021-\u3029\u3038-\u303B\u3400-\u4DBF\u4E00-\u9FFC\uF900-\uFA6D\uFA70-\uFAD9]|\uD81B[\uDFF0\uDFF1]|[\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A]/.test(
15
+ char
16
+ ), "hasChinese");
17
+ const hasPunctuationOrSpace = /* @__PURE__ */ __name((char) => (
18
+ // Uses Unicode property escapes for Punctuation and general category for Space
19
+ /[\p{P}\p{Z}]/u.test(char)
20
+ ), "hasPunctuationOrSpace");
21
+ const findStringOccurrences = /* @__PURE__ */ __name((source, needles) => {
22
+ const ranges = [];
23
+ if (!Array.isArray(needles)) {
24
+ return ranges;
25
+ }
26
+ needles.forEach((needle) => {
27
+ if (typeof needle !== "string" || needle.length === 0) {
28
+ return;
29
+ }
30
+ let startIndex = 0;
31
+ let index;
32
+ while ((index = source.indexOf(needle, startIndex)) > -1) {
33
+ const end = index + needle.length - 1;
34
+ ranges.push([index, end]);
35
+ startIndex = index + 1;
36
+ }
37
+ });
38
+ if (ranges.length === 0) {
39
+ return [];
40
+ }
41
+ ranges.sort((a, b) => a[0] - b[0]);
42
+ const merged = [];
43
+ let currentRange = null;
44
+ for (const range of ranges) {
45
+ if (currentRange === null) {
46
+ currentRange = [...range];
47
+ } else if (range[0] <= currentRange[1] + 1) {
48
+ currentRange[1] = Math.max(currentRange[1], range[1]);
49
+ } else {
50
+ merged.push(currentRange);
51
+ currentRange = [...range];
52
+ }
53
+ }
54
+ if (currentRange !== null) {
55
+ merged.push(currentRange);
56
+ }
57
+ return merged;
58
+ }, "findStringOccurrences");
8
59
 
9
60
  exports.LRUCache = LRUCache;
61
+ exports.escapeRegExp = escapeRegExp;
62
+ exports.findStringOccurrences = findStringOccurrences;
63
+ exports.hasChinese = hasChinese;
64
+ exports.hasPunctuationOrSpace = hasPunctuationOrSpace;
65
+ exports.inRange = inRange;
package/dist/utils.d.cts CHANGED
@@ -1,14 +1,10 @@
1
- declare class LRUCache<K, V> {
2
- private readonly capacity;
3
- private readonly cache;
4
- private keyOrder;
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
- }
1
+ import { k as IntervalArray } from './packem_shared/types-DmfKbIaI.cjs';
2
+ export { L as LRUCache } from './packem_shared/lru-cache-B_t27XwI.cjs';
13
3
 
14
- export { LRUCache };
4
+ declare const escapeRegExp: (char: string) => string;
5
+ declare const inRange: (number_: number, ranges: IntervalArray) => boolean;
6
+ declare const hasChinese: (char: string) => boolean;
7
+ declare const hasPunctuationOrSpace: (char: string) => boolean;
8
+ declare const findStringOccurrences: (source: string, needles: string[]) => IntervalArray;
9
+
10
+ export { escapeRegExp, findStringOccurrences, hasChinese, hasPunctuationOrSpace, inRange };
package/dist/utils.d.mts CHANGED
@@ -1,14 +1,10 @@
1
- declare class LRUCache<K, V> {
2
- private readonly capacity;
3
- private readonly cache;
4
- private keyOrder;
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
- }
1
+ import { k as IntervalArray } from './packem_shared/types-DmfKbIaI.mjs';
2
+ export { L as LRUCache } from './packem_shared/lru-cache-B_t27XwI.mjs';
13
3
 
14
- export { LRUCache };
4
+ declare const escapeRegExp: (char: string) => string;
5
+ declare const inRange: (number_: number, ranges: IntervalArray) => boolean;
6
+ declare const hasChinese: (char: string) => boolean;
7
+ declare const hasPunctuationOrSpace: (char: string) => boolean;
8
+ declare const findStringOccurrences: (source: string, needles: string[]) => IntervalArray;
9
+
10
+ export { escapeRegExp, findStringOccurrences, hasChinese, hasPunctuationOrSpace, inRange };
package/dist/utils.d.ts CHANGED
@@ -1,14 +1,10 @@
1
- declare class LRUCache<K, V> {
2
- private readonly capacity;
3
- private readonly cache;
4
- private keyOrder;
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
- }
1
+ import { k as IntervalArray } from './packem_shared/types-DmfKbIaI.js';
2
+ export { L as LRUCache } from './packem_shared/lru-cache-B_t27XwI.js';
13
3
 
14
- export { LRUCache };
4
+ declare const escapeRegExp: (char: string) => string;
5
+ declare const inRange: (number_: number, ranges: IntervalArray) => boolean;
6
+ declare const hasChinese: (char: string) => boolean;
7
+ declare const hasPunctuationOrSpace: (char: string) => boolean;
8
+ declare const findStringOccurrences: (source: string, needles: string[]) => IntervalArray;
9
+
10
+ export { escapeRegExp, findStringOccurrences, hasChinese, hasPunctuationOrSpace, inRange };
package/dist/utils.mjs CHANGED
@@ -1 +1,56 @@
1
1
  export { default as LRUCache } from './packem_shared/LRUCache-udNErhWw.mjs';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const escapeRegExp = /* @__PURE__ */ __name((char) => (
6
+ // $& means the whole matched string
7
+ char.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&")
8
+ ), "escapeRegExp");
9
+ const inRange = /* @__PURE__ */ __name((number_, ranges) => ranges.some((range) => number_ >= range[0] && number_ <= range[1]), "inRange");
10
+ const hasChinese = /* @__PURE__ */ __name((char) => /[\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u3005\u3007\u3021-\u3029\u3038-\u303B\u3400-\u4DBF\u4E00-\u9FFC\uF900-\uFA6D\uFA70-\uFAD9]|\uD81B[\uDFF0\uDFF1]|[\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A]/.test(
11
+ char
12
+ ), "hasChinese");
13
+ const hasPunctuationOrSpace = /* @__PURE__ */ __name((char) => (
14
+ // Uses Unicode property escapes for Punctuation and general category for Space
15
+ /[\p{P}\p{Z}]/u.test(char)
16
+ ), "hasPunctuationOrSpace");
17
+ const findStringOccurrences = /* @__PURE__ */ __name((source, needles) => {
18
+ const ranges = [];
19
+ if (!Array.isArray(needles)) {
20
+ return ranges;
21
+ }
22
+ needles.forEach((needle) => {
23
+ if (typeof needle !== "string" || needle.length === 0) {
24
+ return;
25
+ }
26
+ let startIndex = 0;
27
+ let index;
28
+ while ((index = source.indexOf(needle, startIndex)) > -1) {
29
+ const end = index + needle.length - 1;
30
+ ranges.push([index, end]);
31
+ startIndex = index + 1;
32
+ }
33
+ });
34
+ if (ranges.length === 0) {
35
+ return [];
36
+ }
37
+ ranges.sort((a, b) => a[0] - b[0]);
38
+ const merged = [];
39
+ let currentRange = null;
40
+ for (const range of ranges) {
41
+ if (currentRange === null) {
42
+ currentRange = [...range];
43
+ } else if (range[0] <= currentRange[1] + 1) {
44
+ currentRange[1] = Math.max(currentRange[1], range[1]);
45
+ } else {
46
+ merged.push(currentRange);
47
+ currentRange = [...range];
48
+ }
49
+ }
50
+ if (currentRange !== null) {
51
+ merged.push(currentRange);
52
+ }
53
+ return merged;
54
+ }, "findStringOccurrences");
55
+
56
+ export { escapeRegExp, findStringOccurrences, hasChinese, hasPunctuationOrSpace, inRange };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/string",
3
- "version": "1.0.5",
3
+ "version": "1.2.0",
4
4
  "description": "Functions for manipulating strings.",
5
5
  "keywords": [
6
6
  "visulima",
@@ -32,9 +32,6 @@
32
32
  "uppercase",
33
33
  "lowercase",
34
34
  "string-splitting",
35
- "unicode",
36
- "i18n",
37
- "internationalization",
38
35
  "typescript",
39
36
  "type-safe"
40
37
  ],
@@ -474,5 +471,8 @@
474
471
  "publishConfig": {
475
472
  "access": "public",
476
473
  "provenance": true
474
+ },
475
+ "scripts": {
476
+ "postinstall": "node ./scripts/generate-charmap.js"
477
477
  }
478
478
  }