@tempots/std 0.11.0 → 0.13.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.
package/string.d.ts CHANGED
@@ -1,314 +1,751 @@
1
1
  /**
2
2
  * Utility functions to manipulate string values.
3
+ *
4
+ * Use by importing the desired utility from "@tempots/std" or directly from "@tempots/std/string".
5
+ * @public
3
6
  */
4
7
  /**
5
8
  * Replaces all occurrances of `placeholder` in `subject` with the value `replacement`.
6
- * @param subject
7
- * @param placeholder
8
- * @param replacement
9
+ * @param subject - The string to search in.
10
+ * @param placeholder - The string to search for.
11
+ * @param replacement - The string to replace `placeholder` with.
12
+ * @returns The string with all occurrances of `placeholder` replaced by `replacement`.
13
+ * @public
9
14
  */
10
- export declare function replace(subject: string, placeholder: string, replacement: string): string;
15
+ export declare function replaceAll(subject: string, placeholder: string, replacement: string): string;
11
16
  /**
12
- * `after` searches for the first occurrance of `searchFor` and returns the text after that.
17
+ * `afterText` searches for the first occurrance of `searchFor` and returns the text after that.
13
18
  * If `searchFor` is not found, an empty string is returned.
19
+ *
20
+ * @param value - The string to search in.
21
+ * @param searchFor - The string to search for.
22
+ * @returns The text after the first occurrance of `searchFor` or an empty string if `searchFor` is not found.
23
+ * @public
14
24
  */
15
- export declare function after(value: string, searchFor: string): string;
25
+ export declare function afterText(value: string, searchFor: string): string;
16
26
  /**
17
- * `afterLast` searches for the last occurrance of `searchFor` and returns the text after that.
27
+ * `afterLastText` searches for the last occurrance of `searchFor` and returns the text after that.
18
28
  * If `searchFor` is not found, an empty string is returned.
29
+ *
30
+ * @param value - The string to search in.
31
+ * @param searchFor - The string to search for.
32
+ * @returns The text after the last occurrance of `searchFor` or an empty string if `searchFor` is not found.
33
+ * @public
19
34
  */
20
- export declare function afterLast(value: string, searchFor: string): string;
35
+ export declare function afterLastText(value: string, searchFor: string): string;
21
36
  /**
22
- * `before` searches for the first occurrance of `searchFor` and returns the text before that.
37
+ * `beforeText` searches for the first occurrance of `searchFor` and returns the text before that.
23
38
  * If `searchFor` is not found, an empty string is returned.
39
+ *
40
+ * @param value - The string to search in.
41
+ * @param searchFor - The string to search for.
42
+ * @returns The text before the first occurrance of `searchFor` or an empty string if `searchFor` is not found.
43
+ * @public
24
44
  */
25
- export declare function before(value: string, searchFor: string): string;
45
+ export declare function beforeText(value: string, searchFor: string): string;
26
46
  /**
27
- * `beforeLast` searches for the last occurrance of `searchFor` and returns the text before that.
47
+ * `beforeLastText` searches for the last occurrance of `searchFor` and returns the text before that.
28
48
  * If `searchFor` is not found, an empty string is returned.
49
+ *
50
+ * @param value - The string to search in.
51
+ * @param searchFor - The string to search for.
52
+ * @returns The text before the last occurrance of `searchFor` or an empty string if `searchFor` is not found.
53
+ * @public
29
54
  */
30
- export declare function beforeLast(value: string, searchFor: string): string;
55
+ export declare function beforeLastText(value: string, searchFor: string): string;
31
56
  /**
32
57
  * `capitalize` returns a string with the first character convert to upper case.
58
+ *
59
+ * @param s - The string to capitalize.
60
+ * @returns The capitalized string.
61
+ * @public
33
62
  */
34
63
  export declare function capitalize(s: string): string;
35
64
  /**
36
65
  * Capitalize the first letter of every word in `value`. If `whiteSpaceOnly` is set to `true`
37
66
  * the process is limited to whitespace separated words.
67
+ *
68
+ * @param value - The string to capitalize.
69
+ * @param whiteSpaceOnly - If `true`, only whitespace separated words will be capitalized.
70
+ * @returns The string with the first letter of each word capitalized.
71
+ * @public
38
72
  */
39
73
  export declare function capitalizeWords(value: string, whiteSpaceOnly?: boolean): string;
40
74
  /**
41
75
  * Replaces occurrances of `\r\n`, `\n\r`, `\r` with `\n`
76
+ *
77
+ * @param value - The string to normalize.
78
+ * @returns The string with normalized line endings.
79
+ * @public
42
80
  */
43
81
  export declare function canonicalizeNewlines(value: string): string;
44
82
  /**
45
83
  * Compares two strings ignoring their case.
84
+ *
85
+ * @param a - The first string to compare.
86
+ * @param b - The second string to compare.
87
+ * @returns A negative number if `a` is less than `b`, zero if they are equal, or a positive number if `a` is greater than `b`.
88
+ * @public
46
89
  */
47
90
  export declare function compareCaseInsensitive(a: string, b: string): number;
48
- export declare function endsWith(s: string, end: string): boolean;
49
- export declare function endsWithCaseInsensitive(s: string, end: string): boolean;
50
- export declare function startsWith(s: string, start: string): boolean;
51
- export declare function startsWithCaseInsensitive(s: string, start: string): boolean;
52
91
  /**
53
- * Compares a string `s` with many `values` and see if one of them matches its end ignoring their case.
54
- */
55
- export declare function endsWithAnyCaseInsensitive(s: string, values: string[]): boolean;
56
- /**
57
- * Compares a string `s` with many `values` and see if one of them matches its beginning ignoring their case.
58
- */
59
- export declare function startsWithAnyCaseInsensitive(s: string, values: string[]): boolean;
60
- /**
61
- * It cleans up all the whitespaces in the passed `value`. `collapse` does the following:
62
- * - remove trailing/leading whitespaces
63
- * - within the string, it collapses seqeunces of whitespaces into a single space character
64
- * For whitespaces in this description, it is intended to be anything that is matched by the regular expression `\s`.
65
- */
66
- export declare function collapse(value: string): string;
67
- /**
68
- * It compares to string and it returns a negative number if `a` is inferior to `b`, zero if they are the same,
69
- * or otherwise a positive non-sero number.
92
+ * Checks if a string ends with a specified suffix.
93
+ *
94
+ * @param s - The string to check.
95
+ * @param end - The suffix to check against.
96
+ * @returns `true` if the string ends with the specified suffix, `false` otherwise.
97
+ * @public
70
98
  */
71
- export declare function compare(a: string, b: string): number;
99
+ export declare function textEndsWith(s: string, end: string): boolean;
72
100
  /**
73
- * `contains` returns `true` if `s` contains one or more occurrences of `test` regardless of the text case.
101
+ * Checks if a string ends with another string in a case-insensitive manner.
102
+ *
103
+ * @param s - The string to check.
104
+ * @param end - The string to check if it is the ending of `s`.
105
+ * @returns `true` if `s` ends with `end` (case-insensitive), otherwise `false`.
106
+ * @public
74
107
  */
75
- export declare function containsCaseInsensitive(s: string, test: string): boolean;
108
+ export declare function textEndsWithCaseInsensitive(s: string, end: string): boolean;
76
109
  /**
77
- * `contains` returns `true` if `s` contains one or more occurrences of `test`.
110
+ * Checks if a string starts with a specified substring.
111
+ *
112
+ * @param s - The string to check.
113
+ * @param start - The substring to check for at the beginning of the string.
114
+ * @returns `true` if the string starts with the specified substring, `false` otherwise.
115
+ * @public
78
116
  */
79
- export declare function contains(s: string, test: string): boolean;
117
+ export declare function textStartsWith(s: string, start: string): boolean;
80
118
  /**
81
- * Return the number of occurances of `test` in `s`.
119
+ * Checks if a string starts with another string in a case-insensitive manner.
120
+ *
121
+ * @param s - The string to check.
122
+ * @param start - The string to compare with the start of `s`.
123
+ * @returns `true` if `s` starts with `start` (case-insensitive), `false` otherwise.
124
+ * @public
82
125
  */
83
- export declare function count(s: string, test: string): number;
126
+ export declare function textStartsWithCaseInsensitive(s: string, start: string): boolean;
84
127
  /**
85
- * `contains` returns `true` if `s` contains any of the strings in `tests` regardless of the text case
128
+ * Compares a string `s` with many `values` and see if one of them matches its end ignoring their case.
129
+ *
130
+ * @param s - The string to compare.
131
+ * @param values - The values to compare with the end of `s`.
132
+ * @returns `true` if `s` ends with any of the values in `values` (case-insensitive), `false` otherwise.
133
+ * @public
86
134
  */
87
- export declare function containsAnyCaseInsensitive(s: string, tests: string[]): boolean;
135
+ export declare function textEndsWithAnyCaseInsensitive(s: string, values: string[]): boolean;
88
136
  /**
89
- * `contains` returns `true` if `s` contains any of the strings in `tests`
137
+ * Compares a string `s` with many `values` and see if one of them matches its beginning ignoring their case.
138
+ *
139
+ * @param s - The string to compare.
140
+ * @param values - The values to compare with the start of `s`.
141
+ * @returns `true` if `s` starts with any of the values in `values` (case-insensitive), `false` otherwise.
142
+ * @public
90
143
  */
91
- export declare function containsAny(s: string, tests: string[]): boolean;
144
+ export declare function textStartsWithAnyCaseInsensitive(s: string, values: string[]): boolean;
92
145
  /**
93
- * `contains` returns `true` if `s` contains all of the strings in `tests` regardless of the text case
146
+ * It cleans up all the whitespaces in the passed `value`. `collapse` does the following:
147
+ * - remove trailing/leading whitespaces
148
+ * - within the string, it collapses seqeunces of whitespaces into a single space character
149
+ * For whitespaces in this description, it is intended to be anything that is matched by the regular expression `\s`.
150
+ *
151
+ * @param value - The string to collapse.
152
+ * @returns The string with all whitespaces collapsed.
153
+ * @public
94
154
  */
95
- export declare function containsAllCaseInsensitive(s: string, tests: string[]): boolean;
155
+ export declare function textCollapse(value: string): string;
96
156
  /**
97
- * `contains` returns `true` if `s` contains all of the strings in `tests`
98
- */
99
- export declare function containsAll(s: string, tests: string[]): boolean;
157
+ * It compares to string and it returns a negative number if `a` is inferior to `b`, zero if they are the same,
158
+ * or otherwise a positive non-sero number.
159
+ *
160
+ * @param a - The first string to compare.
161
+ * @param b - The second string to compare.
162
+ * @returns A negative number if `a` is less than `b`, zero if they are equal, or a positive number if `a` is greater than `b`.
163
+ * @public
164
+ */
165
+ export declare function compareStrings(a: string, b: string): number;
166
+ /**
167
+ * `textContainsCaseInsensitive` returns `true` if `s` contains one or more occurrences of `test` regardless of the text case.
168
+ *
169
+ * @param s - The string to search in.
170
+ * @param test - The string to search for.
171
+ * @returns `true` if `s` contains `test` (case-insensitive), `false` otherwise.
172
+ * @public
173
+ */
174
+ export declare function textContainsCaseInsensitive(s: string, test: string): boolean;
175
+ /**
176
+ * `textContains` returns `true` if `s` contains one or more occurrences of `test`.
177
+ *
178
+ * @param s - The string to search in.
179
+ * @param test - The string to search for.
180
+ * @returns `true` if `s` contains `test`, `false` otherwise.
181
+ * @public
182
+ */
183
+ export declare function textContains(s: string, test: string): boolean;
184
+ /**
185
+ * Return the number of occurrences of `test` in `s`.
186
+ *
187
+ * @param s - The string to search in.
188
+ * @param test - The string to search for.
189
+ * @returns The number of occurrences of `test` in `s`.
190
+ * @public
191
+ */
192
+ export declare function countTextOccurrences(s: string, test: string): number;
193
+ /**
194
+ * `containsAnyTextCaseInsensitive` returns `true` if `s` contains any of the strings in `tests` regardless of the text case
195
+ *
196
+ * @param s - The string to search in.
197
+ * @param tests - The strings to search for.
198
+ * @returns `true` if `s` contains any of the strings in `tests` (case-insensitive), `false` otherwise.
199
+ * @public
200
+ */
201
+ export declare function containsAnyTextCaseInsensitive(s: string, tests: string[]): boolean;
202
+ /**
203
+ * `containsAnyText` returns `true` if `s` contains any of the strings in `tests`
204
+ *
205
+ * @param s - The string to search in.
206
+ * @param tests - The strings to search for.
207
+ * @returns `true` if `s` contains any of the strings in `tests`, `false` otherwise.
208
+ * @public
209
+ */
210
+ export declare function containsAnyText(s: string, tests: string[]): boolean;
211
+ /**
212
+ * `containsAllTextCaseInsensitive` returns `true` if `s` contains all of the strings in `tests` regardless of the text case
213
+ *
214
+ * @param s - The string to search in.
215
+ * @param tests - The strings to search for.
216
+ * @returns `true` if `s` contains all of the strings in `tests` (case-insensitive), `false` otherwise.
217
+ * @public
218
+ */
219
+ export declare function containsAllTextCaseInsensitive(s: string, tests: string[]): boolean;
220
+ /**
221
+ * `containsAllText` returns `true` if `s` contains all of the strings in `tests`
222
+ *
223
+ * @param s - The string to search in.
224
+ * @param tests - The strings to search for.
225
+ * @returns `true` if `s` contains all of the strings in `tests`, `false` otherwise.
226
+ * @public
227
+ */
228
+ export declare function containsAllText(s: string, tests: string[]): boolean;
100
229
  /**
101
230
  * `dasherize` replaces all the occurrances of `_` with `-`
231
+ *
232
+ * @param s - The string to dasherize.
233
+ * @returns The dasherized string.
234
+ * @public
102
235
  */
103
236
  export declare function dasherize(s: string): string;
104
237
  /**
105
238
  * Compares strings `a` and `b` and returns the position where they differ.
239
+ * If the strings are equal, it returns `-1`.
240
+ *
241
+ * @remarks
242
+ * @example
106
243
  * ```ts
107
- * diffIndex('abcdef', 'abc123') // returns 3
244
+ * stringsDifferAtIndex('abcdef', 'abc123') // returns 3
108
245
  * ```
246
+ * @public
247
+ *
248
+ * @param a - The first string to compare.
249
+ * @param b - The second string to compare.
250
+ * @returns The position where the strings differ, or `-1` if they are equal.
251
+ *
109
252
  */
110
- export declare function diffIndex(a: string, b: string): number;
253
+ export declare function stringsDifferAtIndex(a: string, b: string): number;
111
254
  /**
112
255
  * `ellipsis` truncates `s` at len `maxlen` replaces the last characters with the content
113
256
  * of `symbol`.
257
+ *
258
+ * @remarks
259
+ * @example
114
260
  * ```ts
115
261
  * ellipsis('tempo is a nice library', 9) // returns 'tempo is …'
116
262
  * ```
263
+ *
264
+ * @param s - The string to truncate.
265
+ * @param maxlen - The maximum length of the string.
266
+ * @param symbol - The symbol to replace the truncated characters with.
267
+ * @returns The truncated string.
268
+ * @public
117
269
  */
118
270
  export declare function ellipsis(s: string, maxlen?: number, symbol?: string): string;
119
271
  /**
120
272
  * Same as `ellipsis` but puts the symbol in the middle of the string and not to the end.
273
+ *
274
+ * @remarks
275
+ * @example
121
276
  * ```ts
122
277
  * ellipsisMiddle('tempo is a nice library', 18) // returns 'tempo is … library'
123
278
  * ```
279
+ *
280
+ * @param s - The string to truncate.
281
+ * @param maxlen - The maximum length of the string.
282
+ * @param symbol - The symbol to replace the truncated characters with.
283
+ * @returns The truncated string.
284
+ * @public
124
285
  */
125
286
  export declare function ellipsisMiddle(s: string, maxlen?: number, symbol?: string): string;
126
287
  /**
127
288
  * Returns `true` if `s` ends with any of the values in `values`.
289
+ *
290
+ * @param s - The string to compare.
291
+ * @param values - The values to compare with the end of `s`.
292
+ * @returns `true` if `s` ends with any of the values in `values`, `false` otherwise.
293
+ * @public
128
294
  */
129
- export declare function endsWithAny(s: string, values: string[]): boolean;
295
+ export declare function endsWithAnyText(s: string, values: string[]): boolean;
130
296
  /**
131
- * `filter` applies `predicate` character by character to `s` and it returns a filtered
297
+ * `filterString` applies `predicate` character by character to `s` and it returns a filtered
132
298
  * version of the string.
299
+ *
300
+ * @param s - The string to filter.
301
+ * @param predicate - The function to apply to each character in the string.
302
+ * @returns The filtered string.
303
+ * @public
133
304
  */
134
- export declare function filter(s: string, predicate: (s: string) => boolean): string;
305
+ export declare function filterText(s: string, predicate: (s: string) => boolean): string;
135
306
  /**
136
- * Same as `filter` but `predicate` operates on integer char codes instead of string characters.
307
+ * Same as `filterCharcode` but `predicate` operates on integer char codes instead of string characters.
308
+ *
309
+ * @param s - The string to filter.
310
+ * @param predicate - The function to apply to each character code in the string.
311
+ * @returns The filtered string.
312
+ * @public
137
313
  */
138
314
  export declare function filterCharcode(s: string, predicate: (n: number) => boolean): string;
139
315
  /**
140
- * `from` searches for the first occurrance of `searchFor` and returns the text from that point on.
141
- * If `searchFor` is not found, an empty string is returned.
316
+ * Calculates the hash code for a given string.
317
+ *
318
+ * @param value - The string to calculate the hash code for.
319
+ * @param seed - The seed value for the hash code calculation. Default is 0x811c9dc5.
320
+ * @returns The calculated hash code as a number.
321
+ * @public
142
322
  */
143
- export declare function from(value: string, searchFor: string): string;
144
- export declare function hashCode(value: string, seed?: number): number;
323
+ export declare function stringHashCode(value: string, seed?: number): number;
145
324
  /**
146
325
  * Returns `true` if `value` is not `null` and contains at least one character.
326
+ *
327
+ * @param value - The string to check.
328
+ * @returns `true` if the string is not `null` and contains at least one character, `false` otherwise.
329
+ * @public
147
330
  */
148
- export declare function hasContent(value: string): boolean;
331
+ export declare function stringHasContent(value: string): boolean;
149
332
  /**
150
333
  * Works the same as `underscore` but also replaces underscores with whitespaces.
334
+ *
335
+ * @param s - The string to convert.
336
+ * @returns The converted string.
337
+ * @public
151
338
  */
152
339
  export declare function humanize(s: string): string;
153
340
  /**
154
341
  * Checks if `s` contains only (and at least one) alphabetical characters.
342
+ *
343
+ * @param s - The string to check.
344
+ * @returns `true` if the string contains only alphabetical characters, `false` otherwise.
345
+ * @public
155
346
  */
156
347
  export declare function isAlpha(s: string): boolean;
157
348
  /**
158
349
  * `isAlphaNum` returns `true` if the string only contains alpha-numeric characters.
350
+ *
351
+ * @param value - The string to check.
352
+ * @returns `true` if the string contains only alpha-numeric characters, `false` otherwise.
353
+ * @public
159
354
  */
160
355
  export declare function isAlphaNum(value: string): boolean;
356
+ /**
357
+ * Checks if a string contains any breaking whitespace characters.
358
+ *
359
+ * @param value - The string to check.
360
+ * @returns `true` if the string contains breaking whitespace characters, `false` otherwise.
361
+ * @public
362
+ */
161
363
  export declare function isBreakingWhitespace(value: string): boolean;
162
364
  /**
163
365
  * Returns `true` if the value string is composed of only lower cased characters
164
366
  * or case neutral characters.
367
+ *
368
+ * @param value - The string to check.
369
+ * @returns `true` if the string contains only lower case characters, `false` otherwise.
370
+ * @public
165
371
  */
166
372
  export declare function isLowerCase(value: string): boolean;
167
373
  /**
168
374
  * Returns `true` if the value string is composed of only upper cased characters
169
375
  * or case neutral characters.
376
+ *
377
+ * @param value - The string to check.
378
+ * @returns `true` if the string contains only upper case characters, `false` otherwise.
379
+ * @public
170
380
  */
171
381
  export declare function isUpperCase(value: string): boolean;
172
382
  /**
173
383
  * `ifEmpty` returns `value` if it is neither `null` or empty, otherwise it returns `alt`
384
+ *
385
+ * @param value - The string to check.
386
+ * @param alt - The alternative value to return if `value` is `null` or empty.
387
+ * @returns The original string if it is not `null` or empty, otherwise the alternative value.
388
+ * @public
174
389
  */
175
- export declare function ifEmpty(value: string, alt: string): string;
390
+ export declare function ifEmptyString(value: string, alt: string): string;
176
391
  /**
177
392
  * `isDigitsOnly` returns `true` if the string only contains digits.
393
+ *
394
+ * @param value - The string to check.
395
+ * @returns `true` if the string contains only digits, `false` otherwise.
396
+ * @public
178
397
  */
179
398
  export declare function isDigitsOnly(value: string): boolean;
180
399
  /**
181
400
  * `isEmpty` returns true if either `value` is null or is an empty string.
401
+ *
402
+ * @param value - The string to check.
403
+ * @returns `true` if the string is `null` or empty, `false` otherwise.
404
+ * @public
182
405
  */
183
- export declare function isEmpty(value: string): boolean;
406
+ export declare function isEmptyString(value: string): boolean;
184
407
  /**
185
408
  * Convert first letter in `value` to lower case.
409
+ *
410
+ * @param value - The string to convert.
411
+ * @returns The string with the first letter in lower case.
412
+ * @public
186
413
  */
187
414
  export declare function lowerCaseFirst(value: string): string;
188
415
  /**
189
416
  * Returns a random substring from the `value` argument. The length of such value is by default `1`.
417
+ *
418
+ * @param value - The string to extract the random substring from.
419
+ * @param length - The length of the random substring to extract.
420
+ * @returns The random substring.
421
+ * @public
190
422
  */
191
- export declare function random(value: string, length?: number): string;
423
+ export declare function randomString(value: string, length?: number): string;
192
424
  /**
193
425
  * Returns a random sampling of the specified length from the seed string.
426
+ *
427
+ * @param alphabet - The seed string to sample from.
428
+ * @param length - The length of the random string to generate.
429
+ * @returns The random string.
430
+ * @public
194
431
  */
195
- export declare function randomSequence(alphabet: string, length: number): string;
432
+ export declare function randomStringSequence(alphabet: string, length: number): string;
196
433
  /**
197
434
  * Like `randomSequence`, but automatically uses the base64 sequence as the seed string.
435
+ *
436
+ * @param length - The length of the random string to generate.
437
+ * @returns The random string.
438
+ * @public
198
439
  */
199
- export declare function randomSequence64(length: number): string;
440
+ export declare function randomStringSequenceBase64(length: number): string;
200
441
  /**
201
442
  * It maps a string character by character using `callback`.
443
+ *
444
+ * @param callback - The function to apply to each character in the string.
445
+ * @param value - The string to map.
446
+ * @returns An array of the mapped characters.
447
+ * @public
202
448
  */
203
- export declare function map<T>(callback: (c: string) => T, value: string): T[];
449
+ export declare function mapChars<T>(callback: (c: string) => T, value: string): T[];
204
450
  /**
205
451
  * If present, it removes all the occurrences of `toremove` from `value`.
452
+ *
453
+ * @param value - The string to remove the occurrences from.
454
+ * @param toremove - The string to remove from `value`.
455
+ * @returns The string with all occurrences of `toremove` removed.
456
+ * @public
206
457
  */
207
- export declare function remove(value: string, toremove: string): string;
458
+ export declare function removeFromString(value: string, toremove: string): string;
208
459
  /**
209
460
  * If present, it removes the `toremove` text from the end of `value`.
461
+ *
462
+ * @param value - The string to remove the text from.
463
+ * @param toremove - The text to remove from the end of `value`.
464
+ * @returns The string with the text removed.
465
+ * @public
210
466
  */
211
- export declare function removeAfter(value: string, toremove: string): string;
467
+ export declare function removeFromStringAfter(value: string, toremove: string): string;
212
468
  /**
213
469
  * Removes a slice from `index` to `index + length` from `value`.
470
+ *
471
+ * @param value - The string to remove the slice from.
472
+ * @param index - The starting index of the slice to remove.
473
+ * @param length - The length of the slice to remove.
474
+ * @returns The string with the slice removed.
475
+ * @public
214
476
  */
215
- export declare function removeAt(value: string, index: number, length: number): string;
477
+ export declare function removeSliceFromString(value: string, index: number, length: number): string;
216
478
  /**
217
479
  * If present, it removes the `toremove` text from the beginning of `value`.
480
+ *
481
+ * @param value - The string to remove the text from.
482
+ * @param toremove - The text to remove from the beginning of `value`.
483
+ * @returns The string with the text removed.
484
+ * @public
218
485
  */
219
- export declare function removeBefore(value: string, toremove: string): string;
486
+ export declare function removeFromStringBefore(value: string, toremove: string): string;
220
487
  /**
221
488
  * If present, it removes the first occurrence of `toremove` from `value`.
222
- */
223
- export declare function removeOne(value: string, toremove: string): string;
224
- /**
225
- * `repeat` builds a new string by repeating the argument `s`, n `times`.
489
+ *
490
+ * @param value - The string to remove the text from.
491
+ * @param toremove - The text to remove from `value`.
492
+ * @returns The string with the text removed.
493
+ * @public
494
+ */
495
+ export declare function removeFirstFromString(value: string, toremove: string): string;
496
+ /**
497
+ * `repeatString` builds a new string by repeating the argument `s`, n `times`.
498
+ *
499
+ * @remarks
500
+ * @example
226
501
  * ```ts
227
- * repeat('Xy', 3) // generates 'XyXyXy'
502
+ * repeatString('Xy', 3) // generates 'XyXyXy'
228
503
  * ```
504
+ *
505
+ * @param s - The string to repeat.
506
+ * @param times - The number of times to repeat the string.
507
+ * @returns The repeated string.
508
+ * @public
229
509
  */
230
- export declare function repeat(s: string, times: number): string;
510
+ export declare function repeatString(s: string, times: number): string;
231
511
  /**
232
512
  * Returns a new string whose characters are in reverse order.
513
+ *
514
+ * @param s - The string to reverse.
515
+ * @returns The reversed string.
516
+ * @public
233
517
  */
234
- export declare function reverse(s: string): string;
518
+ export declare function reverseString(s: string): string;
235
519
  /**
236
520
  * Converts a string in a quoted string.
521
+ *
522
+ * @param s - The string to quote.
523
+ * @param prefer - The preferred quote character. Defaults to single quote (`'`).
524
+ * @returns The quoted string.
525
+ * @public
237
526
  */
238
527
  export declare function smartQuote(s: string, prefer?: string): string;
528
+ /**
529
+ * Returns a quoted version of the input string.
530
+ *
531
+ * @param s - The input string to be quoted.
532
+ * @param quoteChar - The character used for quoting. Defaults to single quote (').
533
+ * @returns The quoted string.
534
+ * @public
535
+ */
239
536
  export declare function quote(s: string, quoteChar?: string): string;
537
+ /**
538
+ * Quotes a string for use in JavaScript code.
539
+ * If the string contains a newline character, it will be quoted using backticks.
540
+ * Otherwise, it will be quoted using single quotes (`'`) or double quotes (`"`) based on the `prefer` parameter.
541
+ *
542
+ * @param s - The string to be quoted.
543
+ * @param prefer - The preferred quote character. Defaults to single quote (`'`).
544
+ * @returns The quoted string.
545
+ * @public
546
+ */
240
547
  export declare function jsQuote(s: string, prefer?: string): string;
241
548
  /**
242
549
  * It only splits on the first occurrance of separator.
550
+ *
551
+ * @param s - The string to split.
552
+ * @param separator - The separator to split the string on.
553
+ * @returns An array with the split string.
554
+ * @public
243
555
  */
244
- export declare function splitOnce(s: string, separator: string): [string] | [string, string];
556
+ export declare function splitStringOnce(s: string, separator: string): [string] | [string, string];
245
557
  /**
246
558
  * Returns `true` if `s` starts with any of the values in `values`.
559
+ *
560
+ * @param s - The string to compare.
561
+ * @param values - The values to compare with the start of `s`.
562
+ * @returns `true` if `s` starts with any of the values in `values`, `false` otherwise.
563
+ * @public
247
564
  */
248
- export declare function startsWithAny(s: string, values: string[]): boolean;
249
- /**
250
- * `stripTags` removes any HTML/XML markup from the string leaving only the concatenation
251
- * of the existing text nodes.
252
- */
253
- export declare function stripTags(s: string): string;
565
+ export declare function textStartsWithAny(s: string, values: string[]): boolean;
254
566
  /**
255
567
  * Surrounds a string with the contents of `left` and `right`. If `right` is omitted,
256
568
  * `left` will be used on both sides
569
+ *
570
+ * @param s - The string to surround.
571
+ * @param left - The left side of the surrounding text.
572
+ * @param right - The right side of the surrounding text. Defaults to `left`.
573
+ * @returns The surrounded string.
574
+ * @public
257
575
  */
258
- export declare function surround(s: string, left: string, right?: string): string;
576
+ export declare function surroundText(s: string, left: string, right?: string): string;
259
577
  /**
260
578
  * It transforms a string into an `Array` of characters.
579
+ *
580
+ * @param s - The string to transform.
581
+ * @returns An array of characters.
582
+ * @public
261
583
  */
262
- export declare function toArray(s: string): string[];
584
+ export declare function stringToChars(s: string): string[];
263
585
  /**
264
586
  * It transforms a string into an `Array` of char codes in integer format.
587
+ *
588
+ * @param s - The string to transform.
589
+ * @returns An array of char codes.
590
+ * @public
265
591
  */
266
- export declare function toCharcodes(s: string): number[];
592
+ export declare function stringToCharcodes(s: string): number[];
267
593
  /**
268
594
  * Returns an array of `string` whose elements are equally long (using `len`). If the string `s`
269
595
  * is not exactly divisible by `len` the last element of the array will be shorter.
596
+ *
597
+ * @param s - The string to chunk.
598
+ * @param len - The length of each chunk.
599
+ * @returns An array of chunks.
600
+ * @public
270
601
  */
271
- export declare function toChunks(s: string, len: number): string[];
602
+ export declare function chunkText(s: string, len: number): string[];
272
603
  /**
273
604
  * Returns an array of `string` split by line breaks.
605
+ *
606
+ * @param s - The string to split.
607
+ * @returns An array of lines.
608
+ * @public
274
609
  */
275
- export declare function toLines(s: string): string[];
610
+ export declare function stringToLines(s: string): string[];
276
611
  /**
277
612
  * `trimChars` removes from the beginning and the end of the string any character that is present in `charlist`.
613
+ *
614
+ * @param value - The string to trim.
615
+ * @param charlist - The characters to remove from the beginning and end of the string.
616
+ * @returns The trimmed string.
617
+ * @public
278
618
  */
279
619
  export declare function trimChars(value: string, charlist: string): string;
280
620
  /**
281
621
  * `trimCharsLeft` removes from the beginning of the string any character that is present in `charlist`.
622
+ *
623
+ * @param value - The string to trim.
624
+ * @param charlist - The characters to remove from the beginning of the string.
625
+ * @returns The trimmed string.
626
+ * @public
282
627
  */
283
628
  export declare function trimCharsLeft(value: string, charlist: string): string;
284
629
  /**
285
630
  * `trimCharsRight` removes from the end of the string any character that is present in `charlist`.
631
+ *
632
+ * @param value - The string to trim.
633
+ * @param charlist - The characters to remove from the end of the string.
634
+ * @returns The trimmed string.
635
+ * @public
286
636
  */
287
637
  export declare function trimCharsRight(value: string, charlist: string): string;
288
638
  /**
289
639
  * `underscore` finds UpperCase characters and turns them into LowerCase and prepends them with a whtiespace.
290
640
  * Sequences of more than one UpperCase character are left untouched.
641
+ *
642
+ * @param s - The string to underscore.
643
+ * @returns The underscored string.
644
+ * @public
291
645
  */
292
646
  export declare function underscore(s: string): string;
293
647
  /**
294
648
  * Convert first letter in `value` to upper case.
649
+ *
650
+ * @param value - The string to convert.
651
+ * @returns The string with the first letter in upper case.
652
+ * @public
295
653
  */
296
654
  export declare function upperCaseFirst(value: string): string;
297
- /**
298
- * `upTo` searches for the first occurrance of `searchFor` and returns the text up to that point.
299
- * If `searchFor` is not found, the entire string is returned.
300
- */
301
- export declare function upTo(value: string, searchFor: string): string;
302
655
  /**
303
656
  * `wrapColumns` splits a long string into lines that are at most `columns` long.
304
- * Words whose length exceeds `columns` are not split.
657
+ * Individual words whose length exceeds `columns` are not split.
658
+ *
659
+ * @param s - The string to wrap.
660
+ * @param columns - The number of columns per line.
661
+ * @param indent - The indentation string to prepend to each line.
662
+ * @param newline - The newline character to use for line breaks.
663
+ * @returns The wrapped string.
664
+ * @public
305
665
  */
306
666
  export declare function wrapColumns(s: string, columns?: number, indent?: string, newline?: string): string;
667
+ /**
668
+ * Checks if the character at the specified position in a string is a whitespace character.
669
+ *
670
+ * @param s - The input string.
671
+ * @param pos - The position of the character to check.
672
+ * @returns A boolean indicating whether the character at the specified position is a whitespace character.
673
+ * @public
674
+ */
307
675
  export declare function isSpaceAt(s: string, pos: number): boolean;
676
+ /**
677
+ * Encodes a string to base64.
678
+ *
679
+ * @param s - The string to encode.
680
+ * @returns The base64 encoded string.
681
+ * @throws Error if no implementation is found for base64 encoding.
682
+ * @public
683
+ */
308
684
  export declare function encodeBase64(s: string): string;
685
+ /**
686
+ * Decodes a base64 encoded string.
687
+ *
688
+ * @param s - The base64 encoded string to decode.
689
+ * @returns The decoded string.
690
+ * @throws An error if no implementation is found for base64 decoding.
691
+ * @public
692
+ */
309
693
  export declare function decodeBase64(s: string): string;
694
+ /**
695
+ * Wraps a string into multiple lines based on the specified number of columns,
696
+ * indentation, and newline character.
697
+ *
698
+ * @param s - The string to wrap.
699
+ * @param columns - The number of columns per line.
700
+ * @param indent - The indentation string to prepend to each line.
701
+ * @param newline - The newline character to use for line breaks.
702
+ * @returns The wrapped string.
703
+ * @public
704
+ */
310
705
  export declare function wrapLine(s: string, columns: number, indent: string, newline: string): string;
706
+ /**
707
+ * Pads a string on the left with a specified character until it reaches a specified length.
708
+ * If the string is already longer than the specified length, it is returned as is.
709
+ *
710
+ * @param s - The string to pad.
711
+ * @param char - The character to use for padding.
712
+ * @param length - The desired length of the padded string.
713
+ * @returns The padded string.
714
+ * @public
715
+ */
311
716
  export declare function lpad(s: string, char: string, length: number): string;
717
+ /**
718
+ * Pads a string on the right with a specified character until it reaches a specified length.
719
+ * If the string is already longer than the specified length, it is returned as is.
720
+ *
721
+ * @param s - The string to pad.
722
+ * @param char - The character to use for padding.
723
+ * @param length - The desired length of the padded string.
724
+ * @returns The padded string.
725
+ * @public
726
+ */
312
727
  export declare function rpad(s: string, char: string, length: number): string;
728
+ /**
729
+ * Splits a string into two parts at the last occurrence of a specified substring.
730
+ * If the substring is found, the function returns an array with two elements:
731
+ * the part of the string before the substring and the part after the substring.
732
+ * If the substring is not found, the function returns an array with a single element,
733
+ * which is the original string.
734
+ *
735
+ * @param s - The string to split.
736
+ * @param find - The substring to search for.
737
+ * @returns An array containing the split parts of the string.
738
+ * @public
739
+ */
313
740
  export declare function splitOnLast(s: string, find: string): [string] | [string, string];
741
+ /**
742
+ * Splits a string into two parts based on the first occurrence of a specified substring.
743
+ * If the substring is found, returns an array with two elements: the part of the string before the substring and the part after the substring.
744
+ * If the substring is not found, returns an array with a single element: the original string.
745
+ *
746
+ * @param s - The string to split.
747
+ * @param find - The substring to search for.
748
+ * @returns An array containing the split parts of the string.
749
+ * @public
750
+ */
314
751
  export declare function splitOnFirst(s: string, find: string): [string] | [string, string];