@dereekb/util 13.0.7 → 13.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 (143) hide show
  1. package/fetch/package.json +2 -2
  2. package/index.cjs.js +4107 -1516
  3. package/index.esm.js +4107 -1516
  4. package/package.json +1 -2
  5. package/src/lib/array/array.d.ts +92 -47
  6. package/src/lib/array/array.find.d.ts +14 -18
  7. package/src/lib/array/array.index.d.ts +43 -14
  8. package/src/lib/array/array.indexed.d.ts +66 -17
  9. package/src/lib/array/array.limit.d.ts +11 -0
  10. package/src/lib/array/array.make.d.ts +9 -3
  11. package/src/lib/array/array.map.d.ts +20 -8
  12. package/src/lib/array/array.number.d.ts +63 -5
  13. package/src/lib/array/array.random.d.ts +12 -9
  14. package/src/lib/array/array.set.d.ts +24 -1
  15. package/src/lib/array/array.string.d.ts +104 -0
  16. package/src/lib/array/array.unique.d.ts +60 -8
  17. package/src/lib/array/array.value.d.ts +20 -11
  18. package/src/lib/assertion/assertion.d.ts +30 -2
  19. package/src/lib/assertion/assertion.generic.d.ts +8 -0
  20. package/src/lib/assertion/assertion.number.d.ts +16 -0
  21. package/src/lib/auth/auth.role.claims.d.ts +14 -8
  22. package/src/lib/boolean.d.ts +54 -1
  23. package/src/lib/contact/domain.d.ts +22 -4
  24. package/src/lib/contact/random.d.ts +24 -0
  25. package/src/lib/date/date.d.ts +8 -13
  26. package/src/lib/date/hour.d.ts +51 -32
  27. package/src/lib/date/minute.d.ts +4 -4
  28. package/src/lib/date/time.d.ts +12 -3
  29. package/src/lib/date/week.d.ts +77 -10
  30. package/src/lib/error/error.d.ts +54 -3
  31. package/src/lib/error/error.server.d.ts +25 -2
  32. package/src/lib/filter/filter.d.ts +12 -7
  33. package/src/lib/function/function.boolean.d.ts +4 -4
  34. package/src/lib/function/function.d.ts +2 -5
  35. package/src/lib/function/function.forward.d.ts +19 -3
  36. package/src/lib/getter/getter.cache.d.ts +9 -5
  37. package/src/lib/getter/getter.d.ts +39 -22
  38. package/src/lib/getter/getter.map.d.ts +10 -4
  39. package/src/lib/getter/getter.util.d.ts +3 -3
  40. package/src/lib/grouping.d.ts +98 -31
  41. package/src/lib/hash.d.ts +15 -8
  42. package/src/lib/iterable/iterable.d.ts +62 -50
  43. package/src/lib/iterable/iterable.map.d.ts +4 -4
  44. package/src/lib/iterate.d.ts +17 -1
  45. package/src/lib/key.d.ts +32 -10
  46. package/src/lib/lifecycle.d.ts +10 -1
  47. package/src/lib/map/map.d.ts +17 -16
  48. package/src/lib/map/map.intersection.d.ts +5 -4
  49. package/src/lib/map/map.key.d.ts +16 -15
  50. package/src/lib/misc/host.d.ts +6 -3
  51. package/src/lib/model/id.batch.d.ts +7 -3
  52. package/src/lib/model/id.factory.d.ts +16 -1
  53. package/src/lib/model/model.conversion.d.ts +49 -6
  54. package/src/lib/model/model.conversion.field.d.ts +13 -3
  55. package/src/lib/model/model.copy.d.ts +11 -0
  56. package/src/lib/model/model.d.ts +174 -1
  57. package/src/lib/model/model.modify.d.ts +24 -5
  58. package/src/lib/nodejs/stream.d.ts +8 -6
  59. package/src/lib/number/bitwise.dencoder.d.ts +43 -3
  60. package/src/lib/number/bound.d.ts +34 -5
  61. package/src/lib/number/dollar.d.ts +13 -6
  62. package/src/lib/number/factory.d.ts +11 -3
  63. package/src/lib/number/number.d.ts +55 -32
  64. package/src/lib/number/random.d.ts +13 -3
  65. package/src/lib/number/round.d.ts +47 -26
  66. package/src/lib/number/sort.d.ts +7 -1
  67. package/src/lib/number/transform.d.ts +16 -0
  68. package/src/lib/object/object.array.d.ts +16 -2
  69. package/src/lib/object/object.array.delta.d.ts +6 -2
  70. package/src/lib/object/object.d.ts +33 -5
  71. package/src/lib/object/object.empty.d.ts +4 -2
  72. package/src/lib/object/object.equal.d.ts +21 -4
  73. package/src/lib/object/object.filter.tuple.d.ts +105 -3
  74. package/src/lib/object/object.key.d.ts +13 -6
  75. package/src/lib/object/object.map.d.ts +30 -19
  76. package/src/lib/page/page.d.ts +21 -0
  77. package/src/lib/page/page.filter.d.ts +16 -9
  78. package/src/lib/path/path.d.ts +101 -14
  79. package/src/lib/path/path.tree.d.ts +16 -0
  80. package/src/lib/promise/callback.d.ts +18 -0
  81. package/src/lib/promise/is.d.ts +10 -3
  82. package/src/lib/promise/map.d.ts +5 -3
  83. package/src/lib/promise/poll.d.ts +14 -4
  84. package/src/lib/promise/promise.d.ts +84 -18
  85. package/src/lib/promise/promise.factory.d.ts +18 -2
  86. package/src/lib/promise/promise.limit.d.ts +22 -2
  87. package/src/lib/promise/promise.loop.d.ts +69 -1
  88. package/src/lib/promise/promise.ref.d.ts +14 -2
  89. package/src/lib/promise/promise.task.d.ts +8 -4
  90. package/src/lib/promise/promise.type.d.ts +4 -4
  91. package/src/lib/promise/use.d.ts +6 -4
  92. package/src/lib/promise/wait.d.ts +5 -2
  93. package/src/lib/relation/relation.d.ts +98 -0
  94. package/src/lib/service/handler.config.d.ts +47 -9
  95. package/src/lib/service/handler.d.ts +43 -1
  96. package/src/lib/service/typed.service.d.ts +21 -2
  97. package/src/lib/set/set.allowed.d.ts +6 -4
  98. package/src/lib/set/set.d.ts +174 -46
  99. package/src/lib/set/set.decision.d.ts +4 -2
  100. package/src/lib/set/set.delta.d.ts +16 -3
  101. package/src/lib/set/set.hashset.d.ts +43 -0
  102. package/src/lib/set/set.selection.d.ts +7 -3
  103. package/src/lib/sort.d.ts +36 -16
  104. package/src/lib/string/char.d.ts +48 -34
  105. package/src/lib/string/dencoder.d.ts +84 -13
  106. package/src/lib/string/factory.d.ts +13 -4
  107. package/src/lib/string/html.d.ts +7 -6
  108. package/src/lib/string/mimetype.d.ts +65 -1
  109. package/src/lib/string/prefix.d.ts +21 -7
  110. package/src/lib/string/record.d.ts +7 -4
  111. package/src/lib/string/replace.d.ts +77 -33
  112. package/src/lib/string/search.d.ts +19 -9
  113. package/src/lib/string/sort.d.ts +10 -1
  114. package/src/lib/string/string.d.ts +74 -21
  115. package/src/lib/string/transform.d.ts +7 -0
  116. package/src/lib/string/tree.d.ts +91 -29
  117. package/src/lib/string/url.d.ts +148 -63
  118. package/src/lib/tree/tree.explore.d.ts +84 -17
  119. package/src/lib/tree/tree.flatten.d.ts +44 -7
  120. package/src/lib/type.d.ts +15 -12
  121. package/src/lib/value/address.d.ts +66 -17
  122. package/src/lib/value/bound.d.ts +253 -17
  123. package/src/lib/value/build.d.ts +30 -5
  124. package/src/lib/value/comparator.d.ts +53 -25
  125. package/src/lib/value/cron.d.ts +14 -6
  126. package/src/lib/value/decision.d.ts +57 -13
  127. package/src/lib/value/equal.d.ts +44 -13
  128. package/src/lib/value/indexed.d.ts +253 -82
  129. package/src/lib/value/label.d.ts +16 -5
  130. package/src/lib/value/map.d.ts +77 -20
  131. package/src/lib/value/maybe.d.ts +47 -49
  132. package/src/lib/value/modifier.d.ts +82 -27
  133. package/src/lib/value/point.d.ts +248 -54
  134. package/src/lib/value/url.d.ts +10 -3
  135. package/src/lib/value/use.d.ts +99 -8
  136. package/src/lib/value/vector.d.ts +71 -9
  137. package/test/index.cjs.js +86 -23
  138. package/test/index.esm.js +86 -23
  139. package/test/package.json +2 -2
  140. package/test/src/lib/shared/shared.d.ts +31 -5
  141. package/test/src/lib/shared/shared.fail.d.ts +72 -9
  142. package/test/src/lib/shared/shared.function.d.ts +40 -2
  143. package/test/src/lib/shared/shared.wrap.d.ts +20 -1
@@ -1,7 +1,13 @@
1
1
  import { type ArrayOrValue } from '../array/array';
2
2
  import { type Maybe } from '../value/maybe.type';
3
3
  import { type MapSameFunction } from '../value/map';
4
+ /**
5
+ * Function that replaces target substrings within an input string.
6
+ */
4
7
  export type ReplaceStringsFunction = MapSameFunction<string>;
8
+ /**
9
+ * Configuration for creating a {@link ReplaceStringsFunction}.
10
+ */
5
11
  export interface ReplaceStringsConfig {
6
12
  /**
7
13
  * Strings to target/replace.
@@ -12,15 +18,31 @@ export interface ReplaceStringsConfig {
12
18
  */
13
19
  readonly replaceWith: string;
14
20
  }
21
+ /**
22
+ * Creates a function that replaces all occurrences of the configured target strings with a replacement value.
23
+ *
24
+ * @param config - Configuration specifying strings to find and the replacement value.
25
+ * @returns A function that performs the configured replacements on an input string.
26
+ */
15
27
  export declare function replaceStringsFunction(config: ReplaceStringsConfig): (input: string) => string;
28
+ /**
29
+ * Array of characters that have special meaning in regular expressions and need escaping.
30
+ */
16
31
  export declare const REGEX_SPECIAL_CHARACTERS: string[];
32
+ /**
33
+ * Set of regex special characters for efficient lookup.
34
+ */
17
35
  export declare const REGEX_SPECIAL_CHARACTERS_SET: Set<string>;
18
36
  /**
19
- * Creates an escaped regex string joined with or values that finds all of the input values.
37
+ * Creates an escaped regex string that matches any of the input values, joined with the OR (`|`) operator.
20
38
  *
21
- * @param find
39
+ * @param find - One or more strings to create a matching regex pattern for.
40
+ * @returns A regex-compatible string with special characters escaped and values joined by `|`.
22
41
  */
23
42
  export declare function findStringsRegexString(find: ArrayOrValue<string>): string;
43
+ /**
44
+ * Configuration for creating an {@link EscapeStringCharactersFunction}.
45
+ */
24
46
  export interface EscapeStringCharactersFunctionConfig {
25
47
  /**
26
48
  * The set of characters to find and use the escapeCharacter() function on.
@@ -43,36 +65,51 @@ export interface EscapeStringCharactersFunctionConfig {
43
65
  */
44
66
  export type EscapeStringCharactersFunction = (input: string) => string;
45
67
  /**
46
- * Creates an EscapeStringCharactersFunction
68
+ * Creates an {@link EscapeStringCharactersFunction} that escapes specific characters in a string using the configured escape strategy.
47
69
  *
48
- * @param config
49
- * @returns
70
+ * @param config - Configuration specifying which characters to escape and how to escape them.
71
+ * @returns A function that escapes the configured characters in any input string.
50
72
  */
51
73
  export declare function escapeStringCharactersFunction(config: EscapeStringCharactersFunctionConfig): EscapeStringCharactersFunction;
52
74
  /**
53
- * Escapes the input string to be usable in a Regex value.
75
+ * Escapes the input string so it can be safely used as a literal value in a regular expression.
54
76
  *
55
- * For instance, 'hello.world' will be escaped to be 'hello\.world'
77
+ * For instance, `'hello.world'` will be escaped to `'hello\\.world'`.
56
78
  *
57
- * @param input
79
+ * @param input - The string to escape for regex use.
80
+ * @returns The escaped string with all regex special characters prefixed with a backslash.
58
81
  */
59
82
  export declare const escapeStringForRegex: EscapeStringCharactersFunction;
83
+ /**
84
+ * Function that finds all indices of characters from a pre-configured set within an input string.
85
+ *
86
+ * @param input - The string to search through.
87
+ * @param max - Optional maximum number of occurrences to return.
88
+ * @returns An array of zero-based indices where matching characters were found.
89
+ */
60
90
  export type FindAllCharacterOccurencesFunction = (input: string, max?: Maybe<number>) => number[];
91
+ /**
92
+ * Creates a {@link FindAllCharacterOccurencesFunction} that searches for characters from the given set.
93
+ *
94
+ * @param characterSet - The set of characters to search for.
95
+ * @returns A function that finds all occurrences of the configured characters in an input string.
96
+ */
61
97
  export declare function findAllCharacterOccurencesFunction(characterSet: Set<string>): FindAllCharacterOccurencesFunction;
62
98
  /**
63
- * First all occurences of the characters from the set in the input string.
99
+ * Finds all indices of characters from the set that appear in the input string.
64
100
  *
65
- * @param set
66
- * @param input
67
- * @returns
101
+ * @param set - The set of characters to search for.
102
+ * @param input - The string to search through.
103
+ * @param max - Optional maximum number of occurrences to return.
104
+ * @returns An array of zero-based indices where matching characters were found.
68
105
  */
69
106
  export declare function findAllCharacterOccurences(set: Set<string>, input: string, max?: number): number[];
70
107
  /**
71
- * First the first occurence of a character from the set in the input string.
108
+ * Finds the index of the first occurrence of any character from the set in the input string.
72
109
  *
73
- * @param set
74
- * @param input
75
- * @returns
110
+ * @param set - The set of characters to search for.
111
+ * @param input - The string to search through.
112
+ * @returns The zero-based index of the first matching character, or `undefined` if none found.
76
113
  */
77
114
  export declare function findFirstCharacterOccurence(set: Set<string>, input: string): Maybe<number>;
78
115
  /**
@@ -87,12 +124,19 @@ export type SplitStringAtFirstCharacterOccurenceResult = [string, string | undef
87
124
  */
88
125
  export type SplitStringAtFirstCharacterOccurenceFunction = (input: string) => SplitStringAtFirstCharacterOccurenceResult;
89
126
  /**
90
- * Splits the string into two parts at the first occurence of a string or any string in the set.
127
+ * Creates a function that splits a string into two parts at the first occurrence of any character in the configured set.
91
128
  *
92
- * @param set
93
- * @param input
129
+ * @param splitAt - A single character or set of characters to split on.
130
+ * @returns A function that splits input strings at the first matching character.
94
131
  */
95
132
  export declare function splitStringAtFirstCharacterOccurenceFunction(splitAt: string | Set<string>): SplitStringAtFirstCharacterOccurenceFunction;
133
+ /**
134
+ * Splits the input string into two parts at the first occurrence of any character in the split set.
135
+ *
136
+ * @param input - The string to split.
137
+ * @param splitAt - A single character or set of characters to split on.
138
+ * @returns A tuple of [before, after], where `after` is `undefined` if no split character was found.
139
+ */
96
140
  export declare function splitStringAtFirstCharacterOccurence(input: string, splitAt: string | Set<string>): [string, string | undefined];
97
141
  /**
98
142
  * Keeps all characters from the input string after the first character occurence pre-determined by the function.
@@ -101,18 +145,18 @@ export declare function splitStringAtFirstCharacterOccurence(input: string, spli
101
145
  */
102
146
  export type KeepCharactersAfterFirstCharacterOccurenceFunction = (input: string) => string;
103
147
  /**
104
- * Splits the string into two parts at the first occurence of a string or any string in the set.
148
+ * Creates a function that returns only the characters after the first occurrence of any character in the configured set.
105
149
  *
106
- * @param set
107
- * @param input
150
+ * @param findCharacters - A single character or set of characters to search for.
151
+ * @returns A function that extracts the substring after the first matching character, or an empty string if none found.
108
152
  */
109
153
  export declare function keepCharactersAfterFirstCharacterOccurenceFunction(findCharacters: string | Set<string>): KeepCharactersAfterFirstCharacterOccurenceFunction;
110
154
  /**
111
- * Keeps all characters from the input string after the first character occurence from findCharacters input.
155
+ * Returns only the characters after the first occurrence of any character from the find set.
112
156
  *
113
- * @param input
114
- * @param splitAt
115
- * @returns
157
+ * @param input - The string to search through.
158
+ * @param findCharacters - A single character or set of characters to search for.
159
+ * @returns The substring after the first matching character, or an empty string if none found.
116
160
  */
117
161
  export declare function keepCharactersAfterFirstCharacterOccurence(input: string, findCharacters: string | Set<string>): string;
118
162
  /**
@@ -120,17 +164,17 @@ export declare function keepCharactersAfterFirstCharacterOccurence(input: string
120
164
  */
121
165
  export type RemoveCharactersAfterFirstCharacterOccurenceFunction = (input: string) => string;
122
166
  /**
123
- * Splits the string into two parts at the first occurence of a string or any string in the set.
167
+ * Creates a function that removes all characters after (and including) the first occurrence of any character in the configured set.
124
168
  *
125
- * @param set
126
- * @param input
169
+ * @param findCharacters - A single character or set of characters to search for.
170
+ * @returns A function that truncates input strings at the first matching character.
127
171
  */
128
172
  export declare function removeCharactersAfterFirstCharacterOccurenceFunction(findCharacters: string | Set<string>): RemoveCharactersAfterFirstCharacterOccurenceFunction;
129
173
  /**
130
- * Removes all characters from the input string after the first character occurence from findCharacters input.
174
+ * Removes all characters after (and including) the first occurrence of any character from the find set.
131
175
  *
132
- * @param input
133
- * @param splitAt
134
- * @returns
176
+ * @param input - The string to truncate.
177
+ * @param findCharacters - A single character or set of characters to search for.
178
+ * @returns The substring before the first matching character, or the full string if none found.
135
179
  */
136
180
  export declare function removeCharactersAfterFirstCharacterOccurence(input: string, findCharacters: string | Set<string>): string;
@@ -8,30 +8,40 @@ export type SearchStringDecisionFunctionFactory = DecisionFunctionFactory<string
8
8
  * Filters values by the input filter text.
9
9
  */
10
10
  export type SearchStringFilterFunction<T> = (filterText: string, values: T[]) => T[];
11
+ /**
12
+ * Configuration for creating a {@link SearchStringFilterFunction}.
13
+ *
14
+ * @template T - The type of values being filtered.
15
+ */
11
16
  export interface SearchStringFilterConfig<T> {
12
17
  /**
13
- * Reads the search value(s) from the input
18
+ * Reads the search value(s) from the input item to compare against the filter text.
14
19
  */
15
20
  readStrings: ReadKeyFunction<T, string> | ReadMultipleKeysFunction<T, string>;
16
21
  /**
17
- * (Optional) decision function factory for the input.
22
+ * Optional decision function factory for matching logic.
18
23
  *
19
- * Defaults to caseInsensitiveFilterByIndexOfDecisionFactory() if not defined.
24
+ * Defaults to {@link caseInsensitiveFilterByIndexOfDecisionFactory} if not defined.
20
25
  */
21
26
  decisionFactory?: SearchStringDecisionFunctionFactory;
22
27
  }
28
+ /**
29
+ * Input for creating a {@link SearchStringFilterFunction}. Can be a read function directly or a full config object.
30
+ *
31
+ * @template T - The type of values being filtered.
32
+ */
23
33
  export type SearchStringFilterFunctionConfigInput<T> = ReadKeyFunction<T, string> | ReadMultipleKeysFunction<T, string> | SearchStringFilterConfig<T>;
24
34
  /**
25
- * Creates a SearchStringFilterFunction
35
+ * Creates a {@link SearchStringFilterFunction} that filters values based on whether their string representation matches the filter text.
26
36
  *
27
- * @param config
28
- * @returns
37
+ * @param config - A read function or full configuration specifying how to extract and match search strings.
38
+ * @returns A function that filters an array of values by a search/filter text string.
29
39
  */
30
40
  export declare function searchStringFilterFunction<T>(config: SearchStringFilterFunctionConfigInput<T>): SearchStringFilterFunction<T>;
31
41
  /**
32
- * SearchStringDecisionFunctionFactory that searches for string matches using the input search term/filter text.
42
+ * Default {@link SearchStringDecisionFunctionFactory} that performs case-insensitive substring matching using `indexOf`.
33
43
  *
34
- * @param filterText
35
- * @returns
44
+ * @param filterText - The search term to match against.
45
+ * @returns A decision function that returns `true` if the input string contains the filter text (case-insensitive).
36
46
  */
37
47
  export declare const caseInsensitiveFilterByIndexOfDecisionFactory: SearchStringDecisionFunctionFactory;
@@ -5,10 +5,19 @@ import { type ReadStringFunction } from './string';
5
5
  */
6
6
  export type SortByStringFunction<T> = SortCompareFunction<T>;
7
7
  /**
8
- * Creates a SortByStringFunction that sorts values in ascending order.
8
+ * Creates a {@link SortByStringFunction} that sorts values in ascending alphabetical order using `localeCompare`.
9
+ *
10
+ * @param readStringFn - Function to extract a string from each value for comparison.
11
+ * @returns A comparator function suitable for use with `Array.sort()`.
9
12
  */
10
13
  export declare function sortByStringFunction<T>(readStringFn: ReadStringFunction<T>): SortByStringFunction<T>;
14
+ /**
15
+ * Input type for objects that can be sorted by their `label` property.
16
+ */
11
17
  export interface SortByLabelInput {
12
18
  label: string;
13
19
  }
20
+ /**
21
+ * Pre-configured sort comparator that sorts objects by their `label` property in ascending alphabetical order.
22
+ */
14
23
  export declare const sortByLabelFunction: SortByStringFunction<SortByLabelInput>;
@@ -25,7 +25,16 @@ export type CommaSeparatedString<T = unknown> = string;
25
25
  * I.E. 0 1 2
26
26
  */
27
27
  export type SpaceSeparatedString<T = unknown> = string;
28
+ /**
29
+ * Default comma joiner character used by comma-related string functions.
30
+ */
28
31
  export declare const COMMA_JOINER = ",";
32
+ /**
33
+ * Converts a string to its lowercase equivalent for case-insensitive comparison.
34
+ *
35
+ * @param input - string to convert to lowercase
36
+ * @returns the lowercased string, or undefined if the input is undefined
37
+ */
29
38
  export declare function caseInsensitiveString(input: string): string;
30
39
  export declare function caseInsensitiveString(input: undefined): undefined;
31
40
  export declare function caseInsensitiveString(input: Maybe<string>): Maybe<string>;
@@ -57,40 +66,61 @@ export declare function joinStringsWithCommas(input: ArrayOrValue<Maybe<string>>
57
66
  */
58
67
  export declare function splitCommaSeparatedString(input: CommaSeparatedString<string>): string[];
59
68
  export declare function splitCommaSeparatedString<T = unknown>(input: CommaSeparatedString<T>, mapFn: MapStringFunction<T>): T[];
69
+ /**
70
+ * Splits a comma-separated string into a Set of unique trimmed string values.
71
+ *
72
+ * @param input - comma-separated string to split, or null/undefined
73
+ * @returns a Set of unique string values; empty Set if input is null/undefined
74
+ */
60
75
  export declare function splitCommaSeparatedStringToSet(input: Maybe<CommaSeparatedString>): Set<string>;
61
76
  /**
62
77
  * Adds a plus prefix to the input value and converts it to a string. If the value is negative or 0, no prefix is added.
63
78
  *
64
79
  * Undefined is returned if a null/undefined value is input.
80
+ *
81
+ * @param value - the number to prefix
82
+ * @param prefix - the prefix character to use for positive numbers; defaults to '+'
83
+ * @returns the prefixed string, or undefined if the input is null/undefined
65
84
  */
66
85
  export declare function addPlusPrefixToNumber(value?: Maybe<number>, prefix?: string): string | undefined;
67
86
  /**
68
- * Capitalizes the first letter of the input.
87
+ * Capitalizes the first letter of the input string.
69
88
  *
70
- * @param value
71
- * @returns
89
+ * @param value - string to capitalize
90
+ * @returns the input string with its first character uppercased
72
91
  */
73
92
  export declare function capitalizeFirstLetter(value: string): string;
74
93
  /**
75
- * Lowercases the first letter of the input.
94
+ * Lowercases the first letter of the input string.
76
95
  *
77
- * @param value
78
- * @returns
96
+ * @param value - string to modify
97
+ * @returns the input string with its first character lowercased
79
98
  */
80
99
  export declare function lowercaseFirstLetter(value: string): string;
81
100
  /**
82
- * Performs split, but joins the remainder instead of discarding them.
101
+ * Splits a string like {@link String.prototype.split}, but joins overflow segments back together
102
+ * instead of discarding them. Useful when you only want to split on the first N-1 occurrences.
83
103
  *
84
- * @param input
104
+ * @param input - string to split
105
+ * @param separator - delimiter to split on
106
+ * @param limit - maximum number of resulting segments; overflow segments are rejoined with the separator
107
+ * @returns array of string segments, with length at most equal to limit
85
108
  */
86
109
  export declare function splitJoinRemainder(input: string, separator: string, limit: number): string[];
110
+ /**
111
+ * A tuple of [firstName, lastName] where lastName may be undefined if the input has no space.
112
+ */
87
113
  export type FirstNameLastNameTuple = [string, string | undefined];
114
+ /**
115
+ * Default space joiner character used by space-related string functions.
116
+ */
88
117
  export declare const SPACE_JOINER = " ";
89
118
  /**
90
- * Splits the input string like it is a name with a space separating the first and last name string.
119
+ * Splits the input string into a first name and last name tuple using a space as the delimiter.
120
+ * If the name contains more than one space, the remainder is treated as the last name.
91
121
  *
92
- * @param input
93
- * @returns
122
+ * @param input - full name string to split
123
+ * @returns a tuple of [firstName, lastName], where lastName includes all text after the first space
94
124
  */
95
125
  export declare function splitJoinNameString(input: string): FirstNameLastNameTuple;
96
126
  /**
@@ -102,13 +132,16 @@ export declare function splitJoinNameString(input: string): FirstNameLastNameTup
102
132
  export declare function joinStringsWithSpaces(input: MaybeNot): MaybeNot;
103
133
  export declare function joinStringsWithSpaces(input: ArrayOrValue<Maybe<string>>): string;
104
134
  /**
105
- * Creates a string that repeats the given character a number of times.
135
+ * Creates a string that repeats the given string a specified number of times.
106
136
  *
107
- * @param char
108
- * @param reapeat
109
- * @returns
137
+ * @param string - the string to repeat
138
+ * @param reapeat - number of times to repeat the string
139
+ * @returns the repeated string concatenation
110
140
  */
111
141
  export declare function repeatString(string: string, reapeat: number): string;
142
+ /**
143
+ * Configuration for creating a {@link CutStringFunction}.
144
+ */
112
145
  export interface CutStringFunctionConfig {
113
146
  /**
114
147
  * Max length of the string.
@@ -127,23 +160,43 @@ export interface CutStringFunctionConfig {
127
160
  */
128
161
  readonly endText?: Maybe<string>;
129
162
  }
163
+ /**
164
+ * Default ellipsis text appended when a string is truncated by {@link cutStringFunction}.
165
+ */
130
166
  export declare const DEFAULT_CUT_STRING_END_TEXT = "...";
167
+ /**
168
+ * A function that truncates a string to a configured maximum length, optionally appending end text.
169
+ */
131
170
  export type CutStringFunction = ((input: string) => string) & ((input: Maybe<string>) => Maybe<string>);
171
+ /**
172
+ * Creates a {@link CutStringFunction} that truncates strings exceeding the configured maximum length.
173
+ *
174
+ * @param config - configuration controlling max length and end text behavior
175
+ * @returns a reusable function that truncates input strings
176
+ */
132
177
  export declare function cutStringFunction(config: CutStringFunctionConfig): CutStringFunction;
178
+ /**
179
+ * Truncates a string to the given maximum length, appending end text (defaults to "...") if truncated.
180
+ *
181
+ * @param input - the string to truncate, or null/undefined
182
+ * @param maxLength - maximum allowed length for the output string
183
+ * @param endText - text to append when truncated; defaults to "..."
184
+ * @returns the truncated string, or null/undefined if the input is null/undefined
185
+ */
133
186
  export declare function cutString(input: Maybe<string>, maxLength: number, endText?: Maybe<string>): Maybe<string>;
134
187
  /**
135
- * Replaces all whitespaces with a single space.
188
+ * Collapses consecutive whitespace characters (excluding newlines) into a single space, then trims.
136
189
  *
137
190
  * Newlines are preserved.
138
191
  *
139
- * @param input
140
- * @returns
192
+ * @param input - string to flatten
193
+ * @returns the string with collapsed whitespace
141
194
  */
142
195
  export declare function flattenWhitespace(input: string): string;
143
196
  /**
144
- * Reduces multiple newlines to a single newline and reduces multiple whitespaces to a single space.
197
+ * Reduces multiple consecutive newlines to a single newline and collapses multiple whitespace characters to a single space.
145
198
  *
146
- * @param input
147
- * @returns
199
+ * @param input - string to simplify
200
+ * @returns the string with simplified whitespace and newlines
148
201
  */
149
202
  export declare function simplifyWhitespace(input: string): string;
@@ -97,6 +97,13 @@ export declare function transformStringFunctionConfig<S extends string = string>
97
97
  * @returns A `TransformStringFunction` that applies the configured transformations.
98
98
  */
99
99
  export declare function transformStringFunction<S extends string = string>(config: TransformStringFunctionConfig<S>): TransformStringFunction<S>;
100
+ /**
101
+ * Adds a prefix to the input string if it does not already start with that prefix.
102
+ *
103
+ * @param prefix - The prefix to add.
104
+ * @param input - The string to modify.
105
+ * @returns The string with the prefix applied.
106
+ */
100
107
  export declare function addPrefix(prefix: string, input: string): string;
101
108
  /**
102
109
  * Function that adds a configured prefix to the input string if it does not exist on that string.
@@ -1,13 +1,28 @@
1
1
  import { type ArrayOrValue } from '../array/array';
2
2
  import { type Maybe } from '../value/maybe.type';
3
3
  /**
4
- * A tree node
4
+ * A string value representing a node in a split string tree.
5
5
  */
6
6
  export type SplitStringTreeNodeString = string;
7
+ /**
8
+ * The default value used for the root node of a split string tree.
9
+ */
7
10
  export declare const SPLIT_STRING_TREE_NODE_ROOT_VALUE = "";
11
+ /**
12
+ * Map of child nodes in a split string tree, keyed by their node value.
13
+ *
14
+ * @template M - The type of metadata attached to tree nodes.
15
+ */
8
16
  export type SplitStringTreeChildren<M = unknown> = {
9
17
  [key: string]: SplitStringTree<M>;
10
18
  };
19
+ /**
20
+ * A node in a tree structure built by splitting strings on a separator character.
21
+ *
22
+ * For example, splitting `"a/b/c"` on `"/"` produces a tree with nodes for `"a"`, `"b"`, and `"c"`.
23
+ *
24
+ * @template M - The type of metadata attached to tree nodes.
25
+ */
11
26
  export interface SplitStringTree<M = unknown> {
12
27
  /**
13
28
  * The full string value.
@@ -38,28 +53,69 @@ export interface SplitStringTree<M = unknown> {
38
53
  */
39
54
  readonly meta?: M;
40
55
  }
56
+ /**
57
+ * A root-level split string tree containing only children (no own value).
58
+ *
59
+ * @template M - The type of metadata attached to tree nodes.
60
+ */
41
61
  export type SplitStringTreeRoot<M = unknown> = Pick<SplitStringTree<M>, 'children'>;
62
+ /**
63
+ * Input for a {@link SplitStringTreeFactory}, specifying values to add and optional metadata.
64
+ *
65
+ * @template M - The type of metadata attached to tree nodes.
66
+ */
42
67
  export interface SplitStringTreeFactoryInput<M = unknown> extends Pick<AddToSplitStringTreeInputValueWithMeta<M>, 'leafMeta' | 'nodeMeta'> {
68
+ /** One or more string values to split and add to the tree. */
43
69
  readonly values: ArrayOrValue<SplitStringTreeNodeString>;
44
70
  }
71
+ /**
72
+ * Factory function that builds or extends a {@link SplitStringTree} from string values split on a configured separator.
73
+ *
74
+ * @template M - The type of metadata attached to tree nodes.
75
+ */
45
76
  export type SplitStringTreeFactory<M = unknown> = ((input: SplitStringTreeFactoryInput<M>, existing?: Maybe<SplitStringTree<M>>) => SplitStringTree<M>) & {
46
77
  readonly _separator: string;
47
78
  };
79
+ /**
80
+ * Configuration for a {@link SplitStringTreeFactory}.
81
+ *
82
+ * @template M - The type of metadata attached to tree nodes.
83
+ */
48
84
  export type SplitStringTreeFactoryConfig<M = unknown> = AddToSplitStringTreeInputConfig<M>;
49
85
  /**
50
- * Creates a SplitStringTreeFactory with the configured splitter.
86
+ * Creates a {@link SplitStringTreeFactory} that builds tree structures by splitting strings on the configured separator.
51
87
  *
52
- * @param config
53
- * @returns
88
+ * @param config - Configuration specifying the separator and optional metadata merge strategy.
89
+ * @returns A factory function that creates or extends split string trees.
54
90
  */
55
91
  export declare function splitStringTreeFactory<M = unknown>(config: SplitStringTreeFactoryConfig<M>): SplitStringTreeFactory<M>;
92
+ /**
93
+ * Input for {@link applySplitStringTreeWithMultipleValues}.
94
+ *
95
+ * @template M - The type of metadata attached to tree nodes.
96
+ */
56
97
  export interface ApplySplitStringTreeWithMultipleValuesInput<M = unknown> {
98
+ /** The entries to add to the tree, each potentially with different metadata. */
57
99
  readonly entries: SplitStringTreeFactoryInput<M>[];
100
+ /** The factory to use for building the tree. */
58
101
  readonly factory: SplitStringTreeFactory<M>;
102
+ /** An optional existing tree to extend rather than creating a new one. */
59
103
  readonly existing?: SplitStringTree<M>;
60
104
  }
105
+ /**
106
+ * Builds or extends a split string tree by applying multiple entry sets sequentially.
107
+ *
108
+ * @param input - The entries, factory, and optional existing tree.
109
+ * @returns The resulting split string tree with all entries applied.
110
+ */
61
111
  export declare function applySplitStringTreeWithMultipleValues<M = unknown>(input: ApplySplitStringTreeWithMultipleValuesInput<M>): SplitStringTree<M>;
112
+ /**
113
+ * A value and optional metadata to add to a split string tree.
114
+ *
115
+ * @template M - The type of metadata attached to tree nodes.
116
+ */
62
117
  export interface AddToSplitStringTreeInputValueWithMeta<M = unknown> {
118
+ /** The string value to split and insert into the tree. */
63
119
  readonly value: SplitStringTreeNodeString;
64
120
  /**
65
121
  * The meta value to merge/attach to each node in the tree
@@ -70,7 +126,13 @@ export interface AddToSplitStringTreeInputValueWithMeta<M = unknown> {
70
126
  */
71
127
  readonly leafMeta?: M;
72
128
  }
129
+ /**
130
+ * Configuration for splitting strings and adding them to a tree.
131
+ *
132
+ * @template M - The type of metadata attached to tree nodes.
133
+ */
73
134
  export interface AddToSplitStringTreeInputConfig<M = unknown> {
135
+ /** The separator character used to split string values into tree path segments. */
74
136
  readonly separator: string;
75
137
  /**
76
138
  * Used for merging the meta values of two nodes.
@@ -82,51 +144,51 @@ export interface AddToSplitStringTreeInputConfig<M = unknown> {
82
144
  readonly mergeMeta?: (current: M, next: M) => M;
83
145
  }
84
146
  /**
85
- * Adds a value to the target SplitStringTree.
147
+ * Adds a value to the target {@link SplitStringTree} by splitting it on the configured separator and inserting nodes along the path.
86
148
  *
87
- * @param tree
88
- * @param value
89
- * @param separator
90
- * @returns
149
+ * @param tree - The tree to add the value to.
150
+ * @param inputValue - The string value and optional metadata to insert.
151
+ * @param config - Configuration specifying the separator and optional metadata merge strategy.
152
+ * @returns The same tree instance with the new value added.
91
153
  */
92
154
  export declare function addToSplitStringTree<M = unknown>(tree: SplitStringTree<M>, inputValue: AddToSplitStringTreeInputValueWithMeta<M>, config: AddToSplitStringTreeInputConfig<M>): SplitStringTree<M>;
93
155
  /**
94
- * Returns the best match for the value in the tree, including the input tree value.
156
+ * Returns the deepest matching node for the value in the tree, including the input tree node itself.
95
157
  *
96
- * Only returns a result if there is match of any kind.
158
+ * Only returns a result if there is a match of any kind.
97
159
  *
98
- * @param tree
99
- * @param value
100
- * @returns
160
+ * @param tree - The tree to search.
161
+ * @param value - The string value to find a match for.
162
+ * @returns The best matching tree node, or `undefined` if no match is found.
101
163
  */
102
164
  export declare function findBestSplitStringTreeMatch<M = unknown>(tree: SplitStringTree<M>, value: SplitStringTreeNodeString): Maybe<SplitStringTree<M>>;
103
165
  /**
104
- * Returns the best match for the value in the true, excluding the input tree value.
166
+ * Returns the deepest matching child node for the value in the tree, excluding the input tree node itself.
105
167
  *
106
- * Only returns a result if there is match of any kind.
168
+ * Only returns a result if there is a match of any kind.
107
169
  *
108
- * @param tree
109
- * @param value
110
- * @returns
170
+ * @param tree - The tree to search.
171
+ * @param value - The string value to find a match for.
172
+ * @returns The best matching child tree node, or `undefined` if no match is found.
111
173
  */
112
174
  export declare function findBestSplitStringTreeChildMatch<M = unknown>(tree: SplitStringTree<M>, value: SplitStringTreeNodeString): Maybe<SplitStringTree<M>>;
113
175
  /**
114
- * Returns the best match for the value in the tree, including the input tree value.
176
+ * Returns the full path of matching nodes for the value in the tree, including the input tree node itself.
115
177
  *
116
- * Only returns a result if there is match of any kind.
178
+ * Only returns a result if there is a match of any kind.
117
179
  *
118
- * @param tree
119
- * @param value
120
- * @returns
180
+ * @param tree - The tree to search.
181
+ * @param value - The string value to find a match path for.
182
+ * @returns An array of tree nodes forming the match path from root to deepest match, or `undefined` if no match is found.
121
183
  */
122
184
  export declare function findBestSplitStringTreeMatchPath<M = unknown>(tree: SplitStringTree<M>, value: SplitStringTreeNodeString): Maybe<SplitStringTree<M>[]>;
123
185
  /**
124
- * Returns the best match for the value in the true, excluding the input tree value.
186
+ * Returns the full path of matching child nodes for the value in the tree, excluding the input tree node itself.
125
187
  *
126
- * Only returns a result if there is match of any kind.
188
+ * Only returns a result if there is a match of any kind.
127
189
  *
128
- * @param tree
129
- * @param value
130
- * @returns
190
+ * @param tree - The tree to search.
191
+ * @param value - The string value to find a match path for.
192
+ * @returns An array of child tree nodes forming the match path, or `undefined` if no match is found.
131
193
  */
132
194
  export declare function findBestSplitStringTreeChildMatchPath<M = unknown>(tree: SplitStringTree<M>, value: SplitStringTreeNodeString): Maybe<SplitStringTree<M>[]>;