@tempots/std 0.10.7 → 0.12.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/README.md +2 -0
- package/array.cjs +1 -1
- package/array.d.ts +357 -35
- package/array.js +148 -152
- package/async-result.cjs +1 -1
- package/async-result.d.ts +161 -23
- package/async-result.js +119 -13
- package/bigint.cjs +1 -1
- package/bigint.d.ts +155 -18
- package/bigint.js +37 -37
- package/boolean.cjs +1 -1
- package/boolean.d.ts +39 -7
- package/boolean.js +10 -10
- package/domain.d.ts +149 -5
- package/equal.d.ts +26 -0
- package/function.cjs +1 -1
- package/function.d.ts +24 -1
- package/function.js +15 -19
- package/index.cjs +1 -1
- package/index.d.ts +13 -0
- package/index.js +185 -1
- package/json.d.ts +20 -1
- package/number.d.ts +324 -55
- package/object.cjs +1 -1
- package/object.d.ts +53 -5
- package/object.js +15 -15
- package/package.json +26 -19
- package/regexp.cjs +1 -1
- package/regexp.d.ts +5 -4
- package/regexp.js +8 -8
- package/result-Czm7RKNP.js +230 -0
- package/result-DzdZiQoR.cjs +1 -0
- package/result.cjs +1 -1
- package/result.d.ts +132 -8
- package/result.js +3 -54
- package/string.cjs +4 -3
- package/string.d.ts +220 -10
- package/string.js +166 -160
- package/validation.cjs +1 -1
- package/validation.d.ts +72 -4
- package/validation.js +2 -23
- package/maybe.cjs +0 -1
- package/maybe.d.ts +0 -9
- package/maybe.js +0 -9
package/string.d.ts
CHANGED
|
@@ -1,60 +1,104 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility functions to manipulate string values.
|
|
3
|
+
* @public
|
|
3
4
|
*/
|
|
4
5
|
/**
|
|
5
6
|
* Replaces all occurrances of `placeholder` in `subject` with the value `replacement`.
|
|
6
|
-
* @param subject
|
|
7
|
-
* @param placeholder
|
|
8
|
-
* @param replacement
|
|
7
|
+
* @param subject -
|
|
8
|
+
* @param placeholder -
|
|
9
|
+
* @param replacement -
|
|
10
|
+
* @public
|
|
9
11
|
*/
|
|
10
12
|
export declare function replace(subject: string, placeholder: string, replacement: string): string;
|
|
11
13
|
/**
|
|
12
14
|
* `after` searches for the first occurrance of `searchFor` and returns the text after that.
|
|
13
15
|
* If `searchFor` is not found, an empty string is returned.
|
|
16
|
+
* @public
|
|
14
17
|
*/
|
|
15
18
|
export declare function after(value: string, searchFor: string): string;
|
|
16
19
|
/**
|
|
17
20
|
* `afterLast` searches for the last occurrance of `searchFor` and returns the text after that.
|
|
18
21
|
* If `searchFor` is not found, an empty string is returned.
|
|
22
|
+
* @public
|
|
19
23
|
*/
|
|
20
24
|
export declare function afterLast(value: string, searchFor: string): string;
|
|
21
25
|
/**
|
|
22
26
|
* `before` searches for the first occurrance of `searchFor` and returns the text before that.
|
|
23
27
|
* If `searchFor` is not found, an empty string is returned.
|
|
28
|
+
* @public
|
|
24
29
|
*/
|
|
25
30
|
export declare function before(value: string, searchFor: string): string;
|
|
26
31
|
/**
|
|
27
32
|
* `beforeLast` searches for the last occurrance of `searchFor` and returns the text before that.
|
|
28
33
|
* If `searchFor` is not found, an empty string is returned.
|
|
34
|
+
* @public
|
|
29
35
|
*/
|
|
30
36
|
export declare function beforeLast(value: string, searchFor: string): string;
|
|
31
37
|
/**
|
|
32
38
|
* `capitalize` returns a string with the first character convert to upper case.
|
|
39
|
+
* @public
|
|
33
40
|
*/
|
|
34
41
|
export declare function capitalize(s: string): string;
|
|
35
42
|
/**
|
|
36
43
|
* Capitalize the first letter of every word in `value`. If `whiteSpaceOnly` is set to `true`
|
|
37
44
|
* the process is limited to whitespace separated words.
|
|
45
|
+
* @public
|
|
38
46
|
*/
|
|
39
47
|
export declare function capitalizeWords(value: string, whiteSpaceOnly?: boolean): string;
|
|
40
48
|
/**
|
|
41
49
|
* Replaces occurrances of `\r\n`, `\n\r`, `\r` with `\n`
|
|
50
|
+
* @public
|
|
42
51
|
*/
|
|
43
52
|
export declare function canonicalizeNewlines(value: string): string;
|
|
44
53
|
/**
|
|
45
54
|
* Compares two strings ignoring their case.
|
|
55
|
+
* @public
|
|
46
56
|
*/
|
|
47
57
|
export declare function compareCaseInsensitive(a: string, b: string): number;
|
|
58
|
+
/**
|
|
59
|
+
* Checks if a string ends with a specified suffix.
|
|
60
|
+
*
|
|
61
|
+
* @param s - The string to check.
|
|
62
|
+
* @param end - The suffix to check against.
|
|
63
|
+
* @returns `true` if the string ends with the specified suffix, `false` otherwise.
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
48
66
|
export declare function endsWith(s: string, end: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Checks if a string ends with another string in a case-insensitive manner.
|
|
69
|
+
*
|
|
70
|
+
* @param s - The string to check.
|
|
71
|
+
* @param end - The string to check if it is the ending of `s`.
|
|
72
|
+
* @returns `true` if `s` ends with `end` (case-insensitive), otherwise `false`.
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
49
75
|
export declare function endsWithCaseInsensitive(s: string, end: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Checks if a string starts with a specified substring.
|
|
78
|
+
*
|
|
79
|
+
* @param s - The string to check.
|
|
80
|
+
* @param start - The substring to check for at the beginning of the string.
|
|
81
|
+
* @returns `true` if the string starts with the specified substring, `false` otherwise.
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
50
84
|
export declare function startsWith(s: string, start: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Checks if a string starts with another string in a case-insensitive manner.
|
|
87
|
+
*
|
|
88
|
+
* @param s - The string to check.
|
|
89
|
+
* @param start - The string to compare with the start of `s`.
|
|
90
|
+
* @returns `true` if `s` starts with `start` (case-insensitive), `false` otherwise.
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
51
93
|
export declare function startsWithCaseInsensitive(s: string, start: string): boolean;
|
|
52
94
|
/**
|
|
53
95
|
* Compares a string `s` with many `values` and see if one of them matches its end ignoring their case.
|
|
96
|
+
* @public
|
|
54
97
|
*/
|
|
55
98
|
export declare function endsWithAnyCaseInsensitive(s: string, values: string[]): boolean;
|
|
56
99
|
/**
|
|
57
100
|
* Compares a string `s` with many `values` and see if one of them matches its beginning ignoring their case.
|
|
101
|
+
* @public
|
|
58
102
|
*/
|
|
59
103
|
export declare function startsWithAnyCaseInsensitive(s: string, values: string[]): boolean;
|
|
60
104
|
/**
|
|
@@ -62,50 +106,63 @@ export declare function startsWithAnyCaseInsensitive(s: string, values: string[]
|
|
|
62
106
|
* - remove trailing/leading whitespaces
|
|
63
107
|
* - within the string, it collapses seqeunces of whitespaces into a single space character
|
|
64
108
|
* For whitespaces in this description, it is intended to be anything that is matched by the regular expression `\s`.
|
|
109
|
+
* @public
|
|
65
110
|
*/
|
|
66
111
|
export declare function collapse(value: string): string;
|
|
67
112
|
/**
|
|
68
113
|
* It compares to string and it returns a negative number if `a` is inferior to `b`, zero if they are the same,
|
|
69
114
|
* or otherwise a positive non-sero number.
|
|
115
|
+
* @public
|
|
70
116
|
*/
|
|
71
|
-
export declare function
|
|
117
|
+
export declare function compareStrings(a: string, b: string): number;
|
|
72
118
|
/**
|
|
73
119
|
* `contains` returns `true` if `s` contains one or more occurrences of `test` regardless of the text case.
|
|
120
|
+
* @public
|
|
74
121
|
*/
|
|
75
122
|
export declare function containsCaseInsensitive(s: string, test: string): boolean;
|
|
76
123
|
/**
|
|
77
124
|
* `contains` returns `true` if `s` contains one or more occurrences of `test`.
|
|
125
|
+
* @public
|
|
78
126
|
*/
|
|
79
127
|
export declare function contains(s: string, test: string): boolean;
|
|
80
128
|
/**
|
|
81
129
|
* Return the number of occurances of `test` in `s`.
|
|
130
|
+
* @public
|
|
82
131
|
*/
|
|
83
132
|
export declare function count(s: string, test: string): number;
|
|
84
133
|
/**
|
|
85
134
|
* `contains` returns `true` if `s` contains any of the strings in `tests` regardless of the text case
|
|
135
|
+
* @public
|
|
86
136
|
*/
|
|
87
137
|
export declare function containsAnyCaseInsensitive(s: string, tests: string[]): boolean;
|
|
88
138
|
/**
|
|
89
139
|
* `contains` returns `true` if `s` contains any of the strings in `tests`
|
|
140
|
+
* @public
|
|
90
141
|
*/
|
|
91
142
|
export declare function containsAny(s: string, tests: string[]): boolean;
|
|
92
143
|
/**
|
|
93
144
|
* `contains` returns `true` if `s` contains all of the strings in `tests` regardless of the text case
|
|
145
|
+
* @public
|
|
94
146
|
*/
|
|
95
147
|
export declare function containsAllCaseInsensitive(s: string, tests: string[]): boolean;
|
|
96
148
|
/**
|
|
97
149
|
* `contains` returns `true` if `s` contains all of the strings in `tests`
|
|
150
|
+
* @public
|
|
98
151
|
*/
|
|
99
152
|
export declare function containsAll(s: string, tests: string[]): boolean;
|
|
100
153
|
/**
|
|
101
154
|
* `dasherize` replaces all the occurrances of `_` with `-`
|
|
155
|
+
* @public
|
|
102
156
|
*/
|
|
103
157
|
export declare function dasherize(s: string): string;
|
|
104
158
|
/**
|
|
105
159
|
* Compares strings `a` and `b` and returns the position where they differ.
|
|
160
|
+
* If the strings are equal, it returns `-1`.
|
|
161
|
+
*
|
|
106
162
|
* ```ts
|
|
107
163
|
* diffIndex('abcdef', 'abc123') // returns 3
|
|
108
164
|
* ```
|
|
165
|
+
* @public
|
|
109
166
|
*/
|
|
110
167
|
export declare function diffIndex(a: string, b: string): number;
|
|
111
168
|
/**
|
|
@@ -114,6 +171,7 @@ export declare function diffIndex(a: string, b: string): number;
|
|
|
114
171
|
* ```ts
|
|
115
172
|
* ellipsis('tempo is a nice library', 9) // returns 'tempo is …'
|
|
116
173
|
* ```
|
|
174
|
+
* @public
|
|
117
175
|
*/
|
|
118
176
|
export declare function ellipsis(s: string, maxlen?: number, symbol?: string): string;
|
|
119
177
|
/**
|
|
@@ -121,104 +179,147 @@ export declare function ellipsis(s: string, maxlen?: number, symbol?: string): s
|
|
|
121
179
|
* ```ts
|
|
122
180
|
* ellipsisMiddle('tempo is a nice library', 18) // returns 'tempo is … library'
|
|
123
181
|
* ```
|
|
182
|
+
* @public
|
|
124
183
|
*/
|
|
125
184
|
export declare function ellipsisMiddle(s: string, maxlen?: number, symbol?: string): string;
|
|
126
185
|
/**
|
|
127
186
|
* Returns `true` if `s` ends with any of the values in `values`.
|
|
187
|
+
* @public
|
|
128
188
|
*/
|
|
129
189
|
export declare function endsWithAny(s: string, values: string[]): boolean;
|
|
130
190
|
/**
|
|
131
191
|
* `filter` applies `predicate` character by character to `s` and it returns a filtered
|
|
132
192
|
* version of the string.
|
|
193
|
+
* @public
|
|
133
194
|
*/
|
|
134
195
|
export declare function filter(s: string, predicate: (s: string) => boolean): string;
|
|
135
196
|
/**
|
|
136
197
|
* Same as `filter` but `predicate` operates on integer char codes instead of string characters.
|
|
198
|
+
* @public
|
|
137
199
|
*/
|
|
138
200
|
export declare function filterCharcode(s: string, predicate: (n: number) => boolean): string;
|
|
139
201
|
/**
|
|
140
202
|
* `from` searches for the first occurrance of `searchFor` and returns the text from that point on.
|
|
141
203
|
* If `searchFor` is not found, an empty string is returned.
|
|
204
|
+
* @public
|
|
142
205
|
*/
|
|
143
206
|
export declare function from(value: string, searchFor: string): string;
|
|
207
|
+
/**
|
|
208
|
+
* Calculates the hash code for a given string.
|
|
209
|
+
*
|
|
210
|
+
* @param value - The string to calculate the hash code for.
|
|
211
|
+
* @param seed - The seed value for the hash code calculation. Default is 0x811c9dc5.
|
|
212
|
+
* @returns The calculated hash code as a number.
|
|
213
|
+
* @public
|
|
214
|
+
*/
|
|
144
215
|
export declare function hashCode(value: string, seed?: number): number;
|
|
145
216
|
/**
|
|
146
217
|
* Returns `true` if `value` is not `null` and contains at least one character.
|
|
218
|
+
* @public
|
|
147
219
|
*/
|
|
148
220
|
export declare function hasContent(value: string): boolean;
|
|
149
221
|
/**
|
|
150
222
|
* Works the same as `underscore` but also replaces underscores with whitespaces.
|
|
223
|
+
* @public
|
|
151
224
|
*/
|
|
152
225
|
export declare function humanize(s: string): string;
|
|
153
226
|
/**
|
|
154
227
|
* Checks if `s` contains only (and at least one) alphabetical characters.
|
|
228
|
+
* @public
|
|
155
229
|
*/
|
|
156
230
|
export declare function isAlpha(s: string): boolean;
|
|
157
231
|
/**
|
|
158
232
|
* `isAlphaNum` returns `true` if the string only contains alpha-numeric characters.
|
|
233
|
+
* @public
|
|
159
234
|
*/
|
|
160
235
|
export declare function isAlphaNum(value: string): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Checks if a string contains any breaking whitespace characters.
|
|
238
|
+
*
|
|
239
|
+
* @param value - The string to check.
|
|
240
|
+
* @returns `true` if the string contains breaking whitespace characters, `false` otherwise.
|
|
241
|
+
* @public
|
|
242
|
+
*/
|
|
161
243
|
export declare function isBreakingWhitespace(value: string): boolean;
|
|
162
244
|
/**
|
|
163
245
|
* Returns `true` if the value string is composed of only lower cased characters
|
|
164
246
|
* or case neutral characters.
|
|
247
|
+
* @public
|
|
165
248
|
*/
|
|
166
249
|
export declare function isLowerCase(value: string): boolean;
|
|
167
250
|
/**
|
|
168
251
|
* Returns `true` if the value string is composed of only upper cased characters
|
|
169
252
|
* or case neutral characters.
|
|
253
|
+
* @public
|
|
170
254
|
*/
|
|
171
255
|
export declare function isUpperCase(value: string): boolean;
|
|
172
256
|
/**
|
|
173
257
|
* `ifEmpty` returns `value` if it is neither `null` or empty, otherwise it returns `alt`
|
|
258
|
+
* @public
|
|
174
259
|
*/
|
|
175
260
|
export declare function ifEmpty(value: string, alt: string): string;
|
|
176
261
|
/**
|
|
177
262
|
* `isDigitsOnly` returns `true` if the string only contains digits.
|
|
263
|
+
* @public
|
|
178
264
|
*/
|
|
179
265
|
export declare function isDigitsOnly(value: string): boolean;
|
|
180
266
|
/**
|
|
181
267
|
* `isEmpty` returns true if either `value` is null or is an empty string.
|
|
268
|
+
* @public
|
|
182
269
|
*/
|
|
183
270
|
export declare function isEmpty(value: string): boolean;
|
|
184
271
|
/**
|
|
185
272
|
* Convert first letter in `value` to lower case.
|
|
273
|
+
* @public
|
|
186
274
|
*/
|
|
187
275
|
export declare function lowerCaseFirst(value: string): string;
|
|
188
276
|
/**
|
|
189
277
|
* Returns a random substring from the `value` argument. The length of such value is by default `1`.
|
|
278
|
+
* @public
|
|
190
279
|
*/
|
|
191
280
|
export declare function random(value: string, length?: number): string;
|
|
192
281
|
/**
|
|
193
282
|
* Returns a random sampling of the specified length from the seed string.
|
|
283
|
+
* @public
|
|
194
284
|
*/
|
|
195
285
|
export declare function randomSequence(alphabet: string, length: number): string;
|
|
196
286
|
/**
|
|
197
287
|
* Like `randomSequence`, but automatically uses the base64 sequence as the seed string.
|
|
288
|
+
* @public
|
|
198
289
|
*/
|
|
199
290
|
export declare function randomSequence64(length: number): string;
|
|
200
291
|
/**
|
|
201
292
|
* It maps a string character by character using `callback`.
|
|
293
|
+
*
|
|
294
|
+
* @param callback - The function to apply to each character in the string.
|
|
295
|
+
* @param value - The string to map.
|
|
296
|
+
* @returns An array of the mapped characters.
|
|
297
|
+
* @public
|
|
202
298
|
*/
|
|
203
299
|
export declare function map<T>(callback: (c: string) => T, value: string): T[];
|
|
204
300
|
/**
|
|
205
301
|
* If present, it removes all the occurrences of `toremove` from `value`.
|
|
302
|
+
* @public
|
|
206
303
|
*/
|
|
207
304
|
export declare function remove(value: string, toremove: string): string;
|
|
208
305
|
/**
|
|
209
306
|
* If present, it removes the `toremove` text from the end of `value`.
|
|
307
|
+
* @public
|
|
210
308
|
*/
|
|
211
309
|
export declare function removeAfter(value: string, toremove: string): string;
|
|
212
310
|
/**
|
|
213
311
|
* Removes a slice from `index` to `index + length` from `value`.
|
|
312
|
+
* @public
|
|
214
313
|
*/
|
|
215
314
|
export declare function removeAt(value: string, index: number, length: number): string;
|
|
216
315
|
/**
|
|
217
316
|
* If present, it removes the `toremove` text from the beginning of `value`.
|
|
317
|
+
* @public
|
|
218
318
|
*/
|
|
219
319
|
export declare function removeBefore(value: string, toremove: string): string;
|
|
220
320
|
/**
|
|
221
321
|
* If present, it removes the first occurrence of `toremove` from `value`.
|
|
322
|
+
* @public
|
|
222
323
|
*/
|
|
223
324
|
export declare function removeOne(value: string, toremove: string): string;
|
|
224
325
|
/**
|
|
@@ -226,87 +327,196 @@ export declare function removeOne(value: string, toremove: string): string;
|
|
|
226
327
|
* ```ts
|
|
227
328
|
* repeat('Xy', 3) // generates 'XyXyXy'
|
|
228
329
|
* ```
|
|
330
|
+
* @public
|
|
229
331
|
*/
|
|
230
332
|
export declare function repeat(s: string, times: number): string;
|
|
231
333
|
/**
|
|
232
334
|
* Returns a new string whose characters are in reverse order.
|
|
335
|
+
* @public
|
|
233
336
|
*/
|
|
234
337
|
export declare function reverse(s: string): string;
|
|
235
338
|
/**
|
|
236
339
|
* Converts a string in a quoted string.
|
|
340
|
+
* @public
|
|
341
|
+
*/
|
|
342
|
+
export declare function smartQuote(s: string, prefer?: string): string;
|
|
343
|
+
/**
|
|
344
|
+
* Returns a quoted version of the input string.
|
|
345
|
+
*
|
|
346
|
+
* @param s - The input string to be quoted.
|
|
347
|
+
* @param quoteChar - The character used for quoting. Defaults to single quote (').
|
|
348
|
+
* @returns The quoted string.
|
|
349
|
+
* @public
|
|
350
|
+
*/
|
|
351
|
+
export declare function quote(s: string, quoteChar?: string): string;
|
|
352
|
+
/**
|
|
353
|
+
* Quotes a string for use in JavaScript code.
|
|
354
|
+
* If the string contains a newline character, it will be quoted using backticks.
|
|
355
|
+
* Otherwise, it will be quoted using single quotes (`'`) or double quotes (`"`) based on the `prefer` parameter.
|
|
356
|
+
*
|
|
357
|
+
* @param s - The string to be quoted.
|
|
358
|
+
* @param prefer - The preferred quote character. Defaults to single quote (`'`).
|
|
359
|
+
* @returns The quoted string.
|
|
360
|
+
* @public
|
|
237
361
|
*/
|
|
238
|
-
export declare function
|
|
362
|
+
export declare function jsQuote(s: string, prefer?: string): string;
|
|
239
363
|
/**
|
|
240
364
|
* It only splits on the first occurrance of separator.
|
|
365
|
+
* @public
|
|
241
366
|
*/
|
|
242
367
|
export declare function splitOnce(s: string, separator: string): [string] | [string, string];
|
|
243
368
|
/**
|
|
244
369
|
* Returns `true` if `s` starts with any of the values in `values`.
|
|
370
|
+
* @public
|
|
245
371
|
*/
|
|
246
372
|
export declare function startsWithAny(s: string, values: string[]): boolean;
|
|
247
|
-
/**
|
|
248
|
-
* `stripTags` removes any HTML/XML markup from the string leaving only the concatenation
|
|
249
|
-
* of the existing text nodes.
|
|
250
|
-
*/
|
|
251
|
-
export declare function stripTags(s: string): string;
|
|
252
373
|
/**
|
|
253
374
|
* Surrounds a string with the contents of `left` and `right`. If `right` is omitted,
|
|
254
375
|
* `left` will be used on both sides
|
|
376
|
+
* @public
|
|
255
377
|
*/
|
|
256
378
|
export declare function surround(s: string, left: string, right?: string): string;
|
|
257
379
|
/**
|
|
258
380
|
* It transforms a string into an `Array` of characters.
|
|
381
|
+
* @public
|
|
259
382
|
*/
|
|
260
383
|
export declare function toArray(s: string): string[];
|
|
261
384
|
/**
|
|
262
385
|
* It transforms a string into an `Array` of char codes in integer format.
|
|
386
|
+
* @public
|
|
263
387
|
*/
|
|
264
388
|
export declare function toCharcodes(s: string): number[];
|
|
265
389
|
/**
|
|
266
390
|
* Returns an array of `string` whose elements are equally long (using `len`). If the string `s`
|
|
267
391
|
* is not exactly divisible by `len` the last element of the array will be shorter.
|
|
392
|
+
* @public
|
|
268
393
|
*/
|
|
269
394
|
export declare function toChunks(s: string, len: number): string[];
|
|
270
395
|
/**
|
|
271
396
|
* Returns an array of `string` split by line breaks.
|
|
397
|
+
* @public
|
|
272
398
|
*/
|
|
273
399
|
export declare function toLines(s: string): string[];
|
|
274
400
|
/**
|
|
275
401
|
* `trimChars` removes from the beginning and the end of the string any character that is present in `charlist`.
|
|
402
|
+
* @public
|
|
276
403
|
*/
|
|
277
404
|
export declare function trimChars(value: string, charlist: string): string;
|
|
278
405
|
/**
|
|
279
406
|
* `trimCharsLeft` removes from the beginning of the string any character that is present in `charlist`.
|
|
407
|
+
* @public
|
|
280
408
|
*/
|
|
281
409
|
export declare function trimCharsLeft(value: string, charlist: string): string;
|
|
282
410
|
/**
|
|
283
411
|
* `trimCharsRight` removes from the end of the string any character that is present in `charlist`.
|
|
412
|
+
* @public
|
|
284
413
|
*/
|
|
285
414
|
export declare function trimCharsRight(value: string, charlist: string): string;
|
|
286
415
|
/**
|
|
287
416
|
* `underscore` finds UpperCase characters and turns them into LowerCase and prepends them with a whtiespace.
|
|
288
417
|
* Sequences of more than one UpperCase character are left untouched.
|
|
418
|
+
* @public
|
|
289
419
|
*/
|
|
290
420
|
export declare function underscore(s: string): string;
|
|
291
421
|
/**
|
|
292
422
|
* Convert first letter in `value` to upper case.
|
|
423
|
+
* @public
|
|
293
424
|
*/
|
|
294
425
|
export declare function upperCaseFirst(value: string): string;
|
|
295
426
|
/**
|
|
296
427
|
* `upTo` searches for the first occurrance of `searchFor` and returns the text up to that point.
|
|
297
428
|
* If `searchFor` is not found, the entire string is returned.
|
|
429
|
+
* @public
|
|
298
430
|
*/
|
|
299
431
|
export declare function upTo(value: string, searchFor: string): string;
|
|
300
432
|
/**
|
|
301
433
|
* `wrapColumns` splits a long string into lines that are at most `columns` long.
|
|
302
434
|
* Words whose length exceeds `columns` are not split.
|
|
435
|
+
* @public
|
|
303
436
|
*/
|
|
304
437
|
export declare function wrapColumns(s: string, columns?: number, indent?: string, newline?: string): string;
|
|
438
|
+
/**
|
|
439
|
+
* Checks if the character at the specified position in a string is a whitespace character.
|
|
440
|
+
*
|
|
441
|
+
* @param s - The input string.
|
|
442
|
+
* @param pos - The position of the character to check.
|
|
443
|
+
* @returns A boolean indicating whether the character at the specified position is a whitespace character.
|
|
444
|
+
* @public
|
|
445
|
+
*/
|
|
305
446
|
export declare function isSpaceAt(s: string, pos: number): boolean;
|
|
447
|
+
/**
|
|
448
|
+
* Encodes a string to base64.
|
|
449
|
+
*
|
|
450
|
+
* @param s - The string to encode.
|
|
451
|
+
* @returns The base64 encoded string.
|
|
452
|
+
* @throws Error if no implementation is found for base64 encoding.
|
|
453
|
+
* @public
|
|
454
|
+
*/
|
|
306
455
|
export declare function encodeBase64(s: string): string;
|
|
456
|
+
/**
|
|
457
|
+
* Decodes a base64 encoded string.
|
|
458
|
+
*
|
|
459
|
+
* @param s - The base64 encoded string to decode.
|
|
460
|
+
* @returns The decoded string.
|
|
461
|
+
* @throws An error if no implementation is found for base64 decoding.
|
|
462
|
+
* @public
|
|
463
|
+
*/
|
|
307
464
|
export declare function decodeBase64(s: string): string;
|
|
465
|
+
/**
|
|
466
|
+
* Wraps a string into multiple lines based on the specified number of columns,
|
|
467
|
+
* indentation, and newline character.
|
|
468
|
+
*
|
|
469
|
+
* @param s - The string to wrap.
|
|
470
|
+
* @param columns - The number of columns per line.
|
|
471
|
+
* @param indent - The indentation string to prepend to each line.
|
|
472
|
+
* @param newline - The newline character to use for line breaks.
|
|
473
|
+
* @returns The wrapped string.
|
|
474
|
+
* @public
|
|
475
|
+
*/
|
|
308
476
|
export declare function wrapLine(s: string, columns: number, indent: string, newline: string): string;
|
|
477
|
+
/**
|
|
478
|
+
* Pads a string on the left with a specified character until it reaches a specified length.
|
|
479
|
+
* If the string is already longer than the specified length, it is returned as is.
|
|
480
|
+
*
|
|
481
|
+
* @param s - The string to pad.
|
|
482
|
+
* @param char - The character to use for padding.
|
|
483
|
+
* @param length - The desired length of the padded string.
|
|
484
|
+
* @returns The padded string.
|
|
485
|
+
* @public
|
|
486
|
+
*/
|
|
309
487
|
export declare function lpad(s: string, char: string, length: number): string;
|
|
488
|
+
/**
|
|
489
|
+
* Pads a string on the right with a specified character until it reaches a specified length.
|
|
490
|
+
* If the string is already longer than the specified length, it is returned as is.
|
|
491
|
+
*
|
|
492
|
+
* @param s - The string to pad.
|
|
493
|
+
* @param char - The character to use for padding.
|
|
494
|
+
* @param length - The desired length of the padded string.
|
|
495
|
+
* @returns The padded string.
|
|
496
|
+
* @public
|
|
497
|
+
*/
|
|
310
498
|
export declare function rpad(s: string, char: string, length: number): string;
|
|
499
|
+
/**
|
|
500
|
+
* Splits a string into two parts at the last occurrence of a specified substring.
|
|
501
|
+
* If the substring is found, the function returns an array with two elements:
|
|
502
|
+
* the part of the string before the substring and the part after the substring.
|
|
503
|
+
* If the substring is not found, the function returns an array with a single element,
|
|
504
|
+
* which is the original string.
|
|
505
|
+
*
|
|
506
|
+
* @param s - The string to split.
|
|
507
|
+
* @param find - The substring to search for.
|
|
508
|
+
* @returns An array containing the split parts of the string.
|
|
509
|
+
* @public
|
|
510
|
+
*/
|
|
311
511
|
export declare function splitOnLast(s: string, find: string): [string] | [string, string];
|
|
512
|
+
/**
|
|
513
|
+
* Splits a string into two parts based on the first occurrence of a specified substring.
|
|
514
|
+
* 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.
|
|
515
|
+
* If the substring is not found, returns an array with a single element: the original string.
|
|
516
|
+
*
|
|
517
|
+
* @param s - The string to split.
|
|
518
|
+
* @param find - The substring to search for.
|
|
519
|
+
* @returns An array containing the split parts of the string.
|
|
520
|
+
* @public
|
|
521
|
+
*/
|
|
312
522
|
export declare function splitOnFirst(s: string, find: string): [string] | [string, string];
|