@zinaid/str 0.0.6 → 0.0.7
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/dist/ascii/index.d.ts +5 -0
- package/dist/ascii/index.d.ts.map +1 -1
- package/dist/base64/index.d.ts +16 -0
- package/dist/base64/index.d.ts.map +1 -1
- package/dist/base64/index.js +52 -51
- package/dist/convertcase/index.d.ts +10 -0
- package/dist/convertcase/index.d.ts.map +1 -1
- package/dist/index.js +106 -105
- package/dist/markdown/index.d.ts +23 -0
- package/dist/markdown/index.d.ts.map +1 -1
- package/dist/pluralizer/index.d.ts +61 -0
- package/dist/pluralizer/index.d.ts.map +1 -1
- package/dist/pluralizer/index.js +36 -27
- package/dist/replacer/index.d.ts +14 -14
- package/dist/str.d.ts +300 -60
- package/dist/str.d.ts.map +1 -1
- package/dist/str.js +182 -198
- package/dist/stringable/index.d.ts +398 -1
- package/dist/stringable/index.d.ts.map +1 -1
- package/dist/stringable/index.js +400 -13
- package/dist/transliterate/index.d.ts +5 -0
- package/dist/transliterate/index.d.ts.map +1 -1
- package/dist/trimmer/index.d.ts +21 -0
- package/dist/trimmer/index.d.ts.map +1 -1
- package/dist/ulid/index.d.ts +38 -0
- package/dist/ulid/index.d.ts.map +1 -1
- package/dist/ulid/index.js +37 -29
- package/dist/uuid/index.d.ts +34 -0
- package/dist/uuid/index.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -4,75 +4,138 @@ export type ConditionableClosure = ((instance: Stringable, value: ConditionableV
|
|
|
4
4
|
/**
|
|
5
5
|
* Get a new stringable object from the given string.
|
|
6
6
|
*
|
|
7
|
+
* @param value - The string value to wrap in a Stringable instance.
|
|
8
|
+
* @returns A new Stringable instance.
|
|
9
|
+
*
|
|
7
10
|
* @example
|
|
8
11
|
*
|
|
9
12
|
* of('foo').append('bar'); -> 'foobar'
|
|
10
13
|
*/
|
|
11
14
|
export declare function of(value: string): Stringable;
|
|
15
|
+
/**
|
|
16
|
+
* Get a new stringable object from the given string.
|
|
17
|
+
*
|
|
18
|
+
* @param value - The string value to wrap in a Stringable instance.
|
|
19
|
+
* @returns A new Stringable instance.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
*
|
|
23
|
+
* str('foo').append('bar'); -> 'foobar'
|
|
24
|
+
*/
|
|
25
|
+
export declare function str(value: string): Stringable;
|
|
12
26
|
export declare class Stringable {
|
|
13
27
|
private readonly _value;
|
|
14
28
|
/**
|
|
15
29
|
* Create a new instance of the class.
|
|
30
|
+
*
|
|
31
|
+
* @param _value - The initial string value. Defaults to an empty string.
|
|
16
32
|
*/
|
|
17
33
|
constructor(_value?: string);
|
|
18
34
|
/**
|
|
19
35
|
* Return the remainder of a string after the first occurrence of a given value.
|
|
36
|
+
*
|
|
37
|
+
* @param search - The substring to search for.
|
|
38
|
+
* @returns The portion of the string after the first occurrence of the search value.
|
|
20
39
|
*/
|
|
21
40
|
after(search: string | number): Stringable;
|
|
22
41
|
/**
|
|
23
42
|
* Return the remainder of a string after the last occurrence of a given value
|
|
43
|
+
*
|
|
44
|
+
* @param search - The substring to search for.
|
|
45
|
+
* @returns The portion of the string after the last occurrence of the search value.
|
|
24
46
|
*/
|
|
25
47
|
afterLast(search: string | number): Stringable;
|
|
26
48
|
/**
|
|
27
49
|
* Append the given values to the string.
|
|
50
|
+
*
|
|
51
|
+
* @param values - The values to append to the string.
|
|
52
|
+
* @returns The updated Stringable instance.
|
|
28
53
|
*/
|
|
29
54
|
append(...values: Array<string | number>): Stringable;
|
|
30
55
|
/**
|
|
31
56
|
* Append a new line to the string.
|
|
57
|
+
*
|
|
58
|
+
* @param count - The number of new lines to append. Defaults to 1.
|
|
59
|
+
* @returns The updated Stringable instance.
|
|
32
60
|
*/
|
|
33
61
|
newLine(count?: number): Stringable;
|
|
34
62
|
/**
|
|
35
63
|
* Transliterate a UTF-8 value to ASCII.
|
|
64
|
+
*
|
|
65
|
+
* @returns The transliterated string as a new Stringable instance.
|
|
36
66
|
*/
|
|
37
67
|
ascii(): Stringable;
|
|
38
68
|
/**
|
|
39
69
|
* Get the portion of a string before the first occurrence of a given value.
|
|
70
|
+
*
|
|
71
|
+
* @param search - The substring to search for.
|
|
72
|
+
* @returns The portion of the string before the first occurrence of the search value.
|
|
40
73
|
*/
|
|
41
74
|
before(search: string | number): Stringable;
|
|
42
75
|
/**
|
|
43
76
|
* Get the portion of a string before the last occurrence of a given value.
|
|
77
|
+
*
|
|
78
|
+
* @param search - The substring to search for.
|
|
79
|
+
* @returns The portion of the string before the last occurrence of the search value.
|
|
44
80
|
*/
|
|
45
81
|
beforeLast(search: string | number): Stringable;
|
|
46
82
|
/**
|
|
47
83
|
* Get the portion of a string between two given values.
|
|
84
|
+
*
|
|
85
|
+
* @param from - The starting substring.
|
|
86
|
+
* @param to - The ending substring.
|
|
87
|
+
* @returns The portion of the string between the two given values.
|
|
48
88
|
*/
|
|
49
89
|
between(from: string | number, to: string | number): Stringable;
|
|
50
90
|
/**
|
|
51
91
|
* Get the smallest possible portion of a string between two given values.
|
|
92
|
+
*
|
|
93
|
+
* @param from - The starting substring.
|
|
94
|
+
* @param to - The ending substring.
|
|
95
|
+
* @returns The smallest possible portion of the string between the two given values.
|
|
52
96
|
*/
|
|
53
97
|
betweenFirst(from: string | number, to: string | number): Stringable;
|
|
54
98
|
/**
|
|
55
99
|
* Convert a value to camel case.
|
|
100
|
+
*
|
|
101
|
+
* @returns The camel-cased string as a new Stringable instance.
|
|
56
102
|
*/
|
|
57
103
|
camel(): Stringable;
|
|
58
104
|
/**
|
|
59
105
|
* Get the character at the specified index.
|
|
106
|
+
*
|
|
107
|
+
* @param index - The index of the character to retrieve.
|
|
108
|
+
* @returns The character at the specified index, or false if the index is out of bounds.
|
|
60
109
|
*/
|
|
61
110
|
charAt(index: number): string | false;
|
|
62
111
|
/**
|
|
63
112
|
* Remove the given string if it exists at the start of the current string.
|
|
113
|
+
*
|
|
114
|
+
* @param needle - The string or array of strings to remove from the start.
|
|
115
|
+
* @returns The updated Stringable instance.
|
|
64
116
|
*/
|
|
65
117
|
chopStart(needle: string | string[]): Stringable;
|
|
66
118
|
/**
|
|
67
119
|
* Remove the given string if it exists at the end of the current string.
|
|
120
|
+
*
|
|
121
|
+
* @param needle - The string or array of strings to remove from the end.
|
|
122
|
+
* @returns The updated Stringable instance.
|
|
68
123
|
*/
|
|
69
124
|
chopEnd(needle: string | string[]): Stringable;
|
|
70
125
|
/**
|
|
71
126
|
* Determine if a given string contains a given substring.
|
|
127
|
+
*
|
|
128
|
+
* @param needles - The substring(s) to search for
|
|
129
|
+
* @param ignoreCase - Whether the search should be case-insensitive
|
|
130
|
+
* @returns boolean - True if the substring(s) are found, false otherwise
|
|
72
131
|
*/
|
|
73
132
|
contains(needles: string | Iterable<string>, ignoreCase?: boolean): boolean;
|
|
74
133
|
/**
|
|
75
134
|
* Determine if a given string contains all array values.
|
|
135
|
+
*
|
|
136
|
+
* @param needles - The substring(s) to search for
|
|
137
|
+
* @param ignoreCase - Whether the search should be case-insensitive
|
|
138
|
+
* @returns boolean - True if all substring(s) are found, false otherwise
|
|
76
139
|
*/
|
|
77
140
|
containsAll(needles: Iterable<string>, ignoreCase?: boolean): boolean;
|
|
78
141
|
/**
|
|
@@ -85,26 +148,45 @@ export declare class Stringable {
|
|
|
85
148
|
doesntContain(needles: string | Iterable<string>, ignoreCase?: boolean): boolean;
|
|
86
149
|
/**
|
|
87
150
|
* Convert the case of a string.
|
|
151
|
+
*
|
|
152
|
+
* @param mode - The case conversion mode to apply.
|
|
153
|
+
* @returns The converted string as a new Stringable instance.
|
|
88
154
|
*/
|
|
89
155
|
convertCase(mode: ConvertCaseMode): Stringable;
|
|
90
156
|
/**
|
|
91
157
|
* Replace consecutive instances of a given character with a single character.
|
|
158
|
+
*
|
|
159
|
+
* @param character - The character or array of characters to deduplicate. Defaults to a space.
|
|
160
|
+
* @returns The updated Stringable instance.
|
|
92
161
|
*/
|
|
93
162
|
deduplicate(character?: string | string[]): Stringable;
|
|
94
163
|
/**
|
|
95
164
|
* Determine if a given string ends with a given substring.
|
|
165
|
+
*
|
|
166
|
+
* @param needles - The substring(s) to search for
|
|
167
|
+
* @returns boolean - True if the substring(s) are found, false otherwise
|
|
96
168
|
*/
|
|
97
169
|
endsWith(needles: string | number | Iterable<string>): boolean;
|
|
98
170
|
/**
|
|
99
171
|
* Determine if a given string doesn't end with a given substring.
|
|
172
|
+
*
|
|
173
|
+
* @param needles - The substring(s) to search for
|
|
174
|
+
* @returns boolean - True if the substring(s) are not found, false otherwise
|
|
100
175
|
*/
|
|
101
176
|
doesntEndWith(needles: string | number | Iterable<string>): boolean;
|
|
102
177
|
/**
|
|
103
178
|
* Determine if the string is an exact match with the given value.
|
|
179
|
+
*
|
|
180
|
+
* @param value - The value to compare against.
|
|
181
|
+
* @returns True if the strings are exactly the same, false otherwise.
|
|
104
182
|
*/
|
|
105
183
|
exactly(value: Stringable | string): boolean;
|
|
106
184
|
/**
|
|
107
185
|
* Extracts an excerpt from text that matches the first instance of a phrase.
|
|
186
|
+
*
|
|
187
|
+
* @param phrase - The phrase to search for within the text.
|
|
188
|
+
* @param options - Options to customize the excerpt extraction, including radius and omission string.
|
|
189
|
+
* @returns The extracted excerpt or null if the phrase is not found.
|
|
108
190
|
*/
|
|
109
191
|
excerpt(phrase?: string | null, options?: {
|
|
110
192
|
radius?: number;
|
|
@@ -112,170 +194,309 @@ export declare class Stringable {
|
|
|
112
194
|
}): string | null;
|
|
113
195
|
/**
|
|
114
196
|
* Explode the string into an array
|
|
197
|
+
*
|
|
198
|
+
* @param delimiter - The delimiter string to split the string by.
|
|
199
|
+
* @param limit - The maximum number of elements to return. Defaults to Number.MAX_SAFE_INTEGER.
|
|
200
|
+
* @returns An array of strings obtained by splitting the original string.
|
|
115
201
|
*/
|
|
116
202
|
explode(delimiter: string, limit?: number): string[];
|
|
117
203
|
/**
|
|
118
204
|
* Split a string using a regular expression or by length.
|
|
205
|
+
*
|
|
206
|
+
* @param pattern - The regex pattern or length to split the string by.
|
|
207
|
+
* @param limit - The maximum number of splits to perform. Defaults to null (no limit).
|
|
208
|
+
* @returns An array of strings obtained by splitting the original string.
|
|
119
209
|
*/
|
|
120
210
|
split(pattern: string | number, limit?: number | null): string[];
|
|
121
211
|
/**
|
|
122
212
|
* Cap a string with a single instance of a given value.
|
|
213
|
+
*
|
|
214
|
+
* @param cap - The string to cap the original string with.
|
|
215
|
+
* @returns The updated Stringable instance.
|
|
123
216
|
*/
|
|
124
217
|
finish(cap: string): Stringable;
|
|
125
218
|
/**
|
|
126
219
|
* Determine if a given string matches a given pattern.
|
|
220
|
+
*
|
|
221
|
+
* @param pattern - The pattern(s) to match against
|
|
222
|
+
* @returns boolean - True if the pattern(s) match, false otherwise
|
|
127
223
|
*/
|
|
128
224
|
is(pattern: string | Iterable<string>, ignoreCase?: boolean): boolean;
|
|
129
225
|
/**
|
|
130
226
|
* Determine if a given string is 7 bit ASCII.
|
|
227
|
+
*
|
|
228
|
+
* @returns True if the string is ASCII, false otherwise.
|
|
131
229
|
*/
|
|
132
230
|
isAscii(): boolean;
|
|
133
231
|
/**
|
|
134
232
|
* Determine if a given string is valid JSON.
|
|
233
|
+
*
|
|
234
|
+
* @returns True if the string is valid JSON, false otherwise.
|
|
135
235
|
*/
|
|
136
236
|
isJson(): boolean;
|
|
137
237
|
/**
|
|
138
238
|
* Determine if a given value is a valid URL.
|
|
239
|
+
*
|
|
240
|
+
* @param protocols - An array of allowed protocols (e.g., ['http', 'https']).
|
|
241
|
+
* @returns True if the string is a valid URL, false otherwise.
|
|
139
242
|
*/
|
|
140
243
|
isUrl(protocols?: string[]): boolean;
|
|
141
244
|
/**
|
|
142
245
|
* Determine if a given string is a valid UUID.
|
|
246
|
+
*
|
|
247
|
+
* @param version - The UUID version to validate against (1-5), "nil", "max", or null for any version.
|
|
248
|
+
* @returns True if the string is a valid UUID, false otherwise.
|
|
143
249
|
*/
|
|
144
250
|
isUuid(version?: number | "nil" | "max" | null): boolean;
|
|
145
251
|
/**
|
|
146
252
|
* Determine if a given string is a valid ULID.
|
|
253
|
+
*
|
|
254
|
+
* @return True if the string is a valid ULID, false otherwise.
|
|
147
255
|
*/
|
|
148
256
|
isUlid(): boolean;
|
|
149
257
|
/**
|
|
150
258
|
* Determine if the given string is empty.
|
|
259
|
+
*
|
|
260
|
+
* @return True if the string is empty, false otherwise.
|
|
151
261
|
*/
|
|
152
262
|
isEmpty(): boolean;
|
|
153
263
|
/**
|
|
154
264
|
* Determine if the given string is not empty.
|
|
265
|
+
*
|
|
266
|
+
* @return True if the string is not empty, false otherwise.
|
|
155
267
|
*/
|
|
156
268
|
isNotEmpty(): boolean;
|
|
157
269
|
/**
|
|
158
270
|
* Convert a string to kebab case.
|
|
271
|
+
*
|
|
272
|
+
* @returns The kebab-cased string as a new Stringable instance.
|
|
159
273
|
*/
|
|
160
274
|
kebab(): Stringable;
|
|
161
275
|
/**
|
|
162
276
|
* Return the length of the given string.
|
|
277
|
+
*
|
|
278
|
+
* @returns The length of the string.
|
|
163
279
|
*/
|
|
164
280
|
length(): number;
|
|
165
281
|
/**
|
|
166
282
|
* Limit the number of characters in a string.
|
|
283
|
+
*
|
|
284
|
+
* @param limitValue - The maximum number of characters allowed.
|
|
285
|
+
* @param end - The string to append if the original string exceeds the limit.
|
|
286
|
+
* @param preserveWords - Whether to avoid cutting off in the middle of a word.
|
|
287
|
+
* @returns A new Stringable instance with the limited string.
|
|
167
288
|
*/
|
|
168
289
|
limit(limitValue?: number, end?: string, preserveWords?: boolean): Stringable;
|
|
169
290
|
/**
|
|
170
291
|
* Convert the given string to lower-case.
|
|
292
|
+
*
|
|
293
|
+
* @returns The lower-cased string as a new Stringable instance.
|
|
171
294
|
*/
|
|
172
295
|
lower(): Stringable;
|
|
173
296
|
/**
|
|
174
297
|
* Convert GitHub flavored Markdown into HTML.
|
|
298
|
+
*
|
|
299
|
+
* @param options - Options to customize the markdown rendering. Defaults to GFM enabled and no anchors.
|
|
300
|
+
* @param extensions - An array of markdown-it extensions to apply during rendering.
|
|
301
|
+
* @returns The resulting HTML string as a new Stringable instance.
|
|
175
302
|
*/
|
|
176
303
|
markdown(options?: MarkDownOptions, extensions?: MarkDownExtensions): Stringable;
|
|
177
304
|
/**
|
|
178
305
|
* Convert inline Markdown into HTML.
|
|
306
|
+
*
|
|
307
|
+
* @param options - Options to customize the markdown rendering. Defaults to GFM enabled.
|
|
308
|
+
* @param extensions - An array of markdown-it extensions to apply during rendering.
|
|
309
|
+
* @returns The resulting HTML string as a new Stringable instance.
|
|
179
310
|
*/
|
|
180
311
|
inlineMarkdown(options?: MarkDownOptions, extensions?: MarkDownExtensions): Stringable;
|
|
181
312
|
/**
|
|
182
313
|
* Masks a portion of a string with a repeated character.
|
|
314
|
+
*
|
|
315
|
+
* @param character - The character to use for masking.
|
|
316
|
+
* @param index - The starting index to begin masking.
|
|
317
|
+
* @param length - The number of characters to mask. If null, masks to the end of the string.
|
|
318
|
+
* @returns The masked string as a new Stringable instance.
|
|
183
319
|
*/
|
|
184
320
|
mask(character: string, index: number, length?: number | null): Stringable;
|
|
185
321
|
/**
|
|
186
322
|
* Get the string matching the given pattern.
|
|
323
|
+
*
|
|
324
|
+
* @param pattern - The pattern to match against.
|
|
325
|
+
* @returns A new Stringable instance containing the matched string.
|
|
187
326
|
*/
|
|
188
327
|
match(pattern: string): Stringable;
|
|
189
328
|
/**
|
|
190
329
|
* Determine if a given string matches a given pattern.
|
|
330
|
+
*
|
|
331
|
+
* @param pattern - The pattern(s) to match against
|
|
332
|
+
* @returns boolean - True if the pattern(s) match, false otherwise
|
|
191
333
|
*/
|
|
192
334
|
isMatch(pattern: string | Iterable<string>): boolean;
|
|
193
335
|
/**
|
|
194
336
|
* Get the string matching the given pattern.
|
|
337
|
+
*
|
|
338
|
+
* @param pattern - The pattern to match against.
|
|
339
|
+
* @returns An array of all matched strings.
|
|
195
340
|
*/
|
|
196
341
|
matchAll(pattern: string): string[];
|
|
197
342
|
/**
|
|
198
343
|
* Determine if the string matches the given pattern.
|
|
344
|
+
*
|
|
345
|
+
* @param pattern - The pattern(s) to match against
|
|
346
|
+
* @returns boolean - True if the pattern(s) match, false otherwise
|
|
199
347
|
*/
|
|
200
348
|
test(pattern: string): boolean;
|
|
201
349
|
/**
|
|
202
350
|
* Remove all non-numeric characters from a string.
|
|
351
|
+
*
|
|
352
|
+
* @returns The numeric string as a new Stringable instance.
|
|
203
353
|
*/
|
|
204
354
|
numbers(): Stringable;
|
|
205
355
|
/**
|
|
206
356
|
* Pad both sides of the string with another.
|
|
357
|
+
*
|
|
358
|
+
* @param length - The desired total length of the string after padding.
|
|
359
|
+
* @param pad - The string to use for padding. Defaults to a space.
|
|
360
|
+
* @returns The padded string as a new Stringable instance.
|
|
207
361
|
*/
|
|
208
362
|
padBoth(length: number, pad?: string): Stringable;
|
|
209
363
|
/**
|
|
210
364
|
* Pad the left side of the string with another.
|
|
365
|
+
*
|
|
366
|
+
* @param length - The desired total length of the string after padding.
|
|
367
|
+
* @param pad - The string to use for padding. Defaults to a space.
|
|
368
|
+
* @returns The padded string as a new Stringable instance.
|
|
211
369
|
*/
|
|
212
370
|
padLeft(length: number, pad?: string): Stringable;
|
|
213
371
|
/**
|
|
214
372
|
* Pad the right side of the string with another.
|
|
373
|
+
*
|
|
374
|
+
* @param length - The desired total length of the string after padding.
|
|
375
|
+
* @param pad - The string to use for padding. Defaults to a space.
|
|
376
|
+
* @returns The padded string as a new Stringable instance.
|
|
215
377
|
*/
|
|
216
378
|
padRight(length: number, pad?: string): Stringable;
|
|
217
379
|
/**
|
|
218
380
|
* Call the given callback and return a new string.
|
|
381
|
+
*
|
|
382
|
+
* @param callback - The callback function to process the string.
|
|
383
|
+
* @returns The processed string as a new Stringable instance.
|
|
219
384
|
*/
|
|
220
385
|
pipe<T = Stringable | string>(callback: (s: Stringable) => T): Stringable;
|
|
221
386
|
/**
|
|
222
387
|
* Get the plural form of an English word.
|
|
388
|
+
*
|
|
389
|
+
* @param count - The count to determine singular or plural form. Defaults to 2.
|
|
390
|
+
* @param prependCount - Whether to prepend the count to the result. Defaults to false.
|
|
391
|
+
* @returns The pluralized string as a new Stringable instance.
|
|
223
392
|
*/
|
|
224
393
|
plural(count?: number, prependCount?: boolean): Stringable;
|
|
225
394
|
/**
|
|
226
395
|
* Pluralize the last word of an English, studly caps case string.
|
|
396
|
+
*
|
|
397
|
+
* @param count - The count to determine singular or plural form. Defaults to 2.
|
|
398
|
+
* @returns The pluralized string as a new Stringable instance.
|
|
227
399
|
*/
|
|
228
400
|
pluralStudly(count?: number): Stringable;
|
|
229
401
|
/**
|
|
230
402
|
* Pluralize the last word of an English, Pascal caps case string.
|
|
403
|
+
*
|
|
404
|
+
* @param count - The count to determine singular or plural form. Defaults to 2.
|
|
405
|
+
* @returns The pluralized string as a new Stringable instance.
|
|
231
406
|
*/
|
|
232
407
|
pluralPascal(count?: number): Stringable;
|
|
233
408
|
/**
|
|
234
409
|
* Find the multi-byte safe position of the first occurrence of the given substring.
|
|
410
|
+
*
|
|
411
|
+
* @param needle - The substring to search for.
|
|
412
|
+
* @param offset - The offset from which to start the search. Defaults to 0.
|
|
413
|
+
* @returns The position of the first occurrence of the substring, or false if not found.
|
|
235
414
|
*/
|
|
236
415
|
position(needle: string, offset?: number): number | false;
|
|
237
416
|
/**
|
|
238
417
|
* Prepend the given values to the string.
|
|
418
|
+
*
|
|
419
|
+
* @param values - The values to prepend to the string.
|
|
420
|
+
* @returns The updated Stringable instance.
|
|
239
421
|
*/
|
|
240
422
|
prepend(...values: Array<string | number>): Stringable;
|
|
241
423
|
/**
|
|
242
424
|
* Remove any occurrence of the given string in the subject.
|
|
425
|
+
*
|
|
426
|
+
* @param search - The string or iterable of strings to remove.
|
|
427
|
+
* @param caseSensitive - Whether the search should be case-sensitive. Defaults to true.
|
|
428
|
+
* @returns The updated Stringable instance.
|
|
243
429
|
*/
|
|
244
430
|
remove(search: string | Iterable<string>, caseSensitive?: boolean): Stringable;
|
|
245
431
|
/**
|
|
246
432
|
* Reverse the string.
|
|
433
|
+
*
|
|
434
|
+
* @returns The reversed string as a new Stringable instance.
|
|
247
435
|
*/
|
|
248
436
|
reverse(): Stringable;
|
|
249
437
|
/**
|
|
250
438
|
* Repeat the string.
|
|
439
|
+
*
|
|
440
|
+
* @param times - The number of times to repeat the string.
|
|
441
|
+
* @returns The repeated string as a new Stringable instance.
|
|
251
442
|
*/
|
|
252
443
|
repeat(times: number): Stringable;
|
|
253
444
|
/**
|
|
254
445
|
* Replace the given value in the given string.
|
|
446
|
+
*
|
|
447
|
+
* @param search - The value or iterable of values to search for.
|
|
448
|
+
* @param replacement - The replacement value or iterable of values.
|
|
449
|
+
* @param caseSensitive - Whether the search should be case-sensitive. Defaults to true.
|
|
450
|
+
* @returns The updated Stringable instance.
|
|
255
451
|
*/
|
|
256
452
|
replace(search: string | Iterable<string>, replacement: string | Iterable<string>, caseSensitive?: boolean): Stringable;
|
|
257
453
|
/**
|
|
258
454
|
* Replace a given value in the string sequentially with an array.
|
|
455
|
+
*
|
|
456
|
+
* @param search - The value to search for.
|
|
457
|
+
* @param replace - The array or record of replacements.
|
|
458
|
+
* @returns The updated Stringable instance.
|
|
259
459
|
*/
|
|
260
460
|
replaceArray(search: string, replace: Record<string, string> | Iterable<string>): Stringable;
|
|
261
461
|
/**
|
|
262
462
|
* Replace the first occurrence of a given value in the string.
|
|
463
|
+
*
|
|
464
|
+
* @param search - The value to search for.
|
|
465
|
+
* @param replace - The replacement value.
|
|
466
|
+
* @returns The updated Stringable instance.
|
|
263
467
|
*/
|
|
264
468
|
replaceFirst(search: string | number, replace: string): Stringable;
|
|
265
469
|
/**
|
|
266
470
|
* Replace the first occurrence of the given value if it appears at the start of the string.
|
|
471
|
+
*
|
|
472
|
+
* @param search - The value to search for.
|
|
473
|
+
* @param replace - The replacement value.
|
|
474
|
+
* @returns The updated Stringable instance.
|
|
267
475
|
*/
|
|
268
476
|
replaceStart(search: string | number, replace: string): Stringable;
|
|
269
477
|
/**
|
|
270
478
|
* Replace the last occurrence of a given value in the string.
|
|
479
|
+
*
|
|
480
|
+
* @param search - The value to search for.
|
|
481
|
+
* @param replace - The replacement value.
|
|
482
|
+
* @returns The updated Stringable instance.
|
|
271
483
|
*/
|
|
272
484
|
replaceLast(search: string | number, replace: string): Stringable;
|
|
273
485
|
/**
|
|
274
486
|
* Replace the last occurrence of a given value if it appears at the end of the string.
|
|
487
|
+
*
|
|
488
|
+
* @param search - The value to search for.
|
|
489
|
+
* @param replace - The replacement value.
|
|
490
|
+
* @returns The updated Stringable instance.
|
|
275
491
|
*/
|
|
276
492
|
replaceEnd(search: string | number, replace: string): Stringable;
|
|
277
493
|
/**
|
|
278
494
|
* Replace the patterns matching the given regular expression.
|
|
495
|
+
*
|
|
496
|
+
* @param pattern - The pattern(s) to search for.
|
|
497
|
+
* @param replace - The replacement string(s) or a callback function.
|
|
498
|
+
* @param limit - The maximum number of replacements to perform. Defaults to -1 (no limit).
|
|
499
|
+
* @returns The updated Stringable instance.
|
|
279
500
|
*/
|
|
280
501
|
replaceMatches(pattern: string | string[] | RegExp | RegExp[], replace: string | string[] | ((match: string[]) => string), limit?: number): Stringable;
|
|
281
502
|
/**
|
|
@@ -293,110 +514,183 @@ export declare class Stringable {
|
|
|
293
514
|
scan(format: string): string[];
|
|
294
515
|
/**
|
|
295
516
|
* Remove all "extra" blank space from the given string.
|
|
517
|
+
*
|
|
518
|
+
* @returns The updated Stringable instance.
|
|
296
519
|
*/
|
|
297
520
|
squish(): Stringable;
|
|
298
521
|
/**
|
|
299
522
|
* Begin a string with a single instance of a given value.
|
|
523
|
+
*
|
|
524
|
+
* @param prefix - The string to start the original string with.
|
|
525
|
+
* @returns The updated Stringable instance.
|
|
300
526
|
*/
|
|
301
527
|
start(prefix: string): Stringable;
|
|
302
528
|
/**
|
|
303
529
|
* Strip HTML and PHP tags from the given string.
|
|
530
|
+
*
|
|
531
|
+
* @returns The updated Stringable instance.
|
|
304
532
|
*/
|
|
305
533
|
stripTags(): Stringable;
|
|
306
534
|
/**
|
|
307
535
|
* Convert the given string to upper-case.
|
|
536
|
+
*
|
|
537
|
+
* @returns The upper-cased string as a new Stringable instance.
|
|
308
538
|
*/
|
|
309
539
|
upper(): Stringable;
|
|
310
540
|
/**
|
|
311
541
|
* Convert the given string to proper case.
|
|
542
|
+
*
|
|
543
|
+
* @returns The title-cased string as a new Stringable instance.
|
|
312
544
|
*/
|
|
313
545
|
title(): Stringable;
|
|
314
546
|
/**
|
|
315
547
|
* Convert the given string to proper case for each word.
|
|
548
|
+
*
|
|
549
|
+
* @returns The headline-cased string as a new Stringable instance.
|
|
316
550
|
*/
|
|
317
551
|
headline(): Stringable;
|
|
318
552
|
/**
|
|
319
553
|
* Convert the given string to APA-style title case.
|
|
554
|
+
*
|
|
555
|
+
* @returns The APA title-cased string as a new Stringable instance.
|
|
320
556
|
*/
|
|
321
557
|
apa(): Stringable;
|
|
322
558
|
/**
|
|
323
559
|
* Transliterate a string to its closest ASCII representation.
|
|
560
|
+
*
|
|
561
|
+
* @returns The transliterated string as a new Stringable instance.
|
|
324
562
|
*/
|
|
325
563
|
transliterate(): Stringable;
|
|
326
564
|
/**
|
|
327
565
|
* Get the singular form of an English word.
|
|
566
|
+
*
|
|
567
|
+
* @returns The singularized string as a new Stringable instance.
|
|
328
568
|
*/
|
|
329
569
|
singular(): Stringable;
|
|
330
570
|
/**
|
|
331
571
|
* Generate a URL friendly "slug" from a given string.
|
|
572
|
+
*
|
|
573
|
+
* @param separator - The separator to use in the slug. Defaults to "-".
|
|
574
|
+
* @param dictionary - A dictionary of characters to replace. Defaults to { "@": "at" }.
|
|
575
|
+
* @returns The slugified string as a new Stringable instance.
|
|
332
576
|
*/
|
|
333
577
|
slug(separator?: string, dictionary?: Record<string, string>): Stringable;
|
|
334
578
|
/**
|
|
335
579
|
* Convert a string to snake case.
|
|
580
|
+
*
|
|
581
|
+
* @param delimiter - The delimiter to use in the snake case. Defaults to "_".
|
|
582
|
+
* @returns The snake-cased string as a new Stringable instance.
|
|
336
583
|
*/
|
|
337
584
|
snake(delimiter?: string): Stringable;
|
|
338
585
|
/**
|
|
339
586
|
* Determine if a given string starts with a given substring.
|
|
587
|
+
*
|
|
588
|
+
* @param needles - The substring(s) to search for
|
|
589
|
+
* @returns boolean - True if the substring(s) are found, false otherwise
|
|
340
590
|
*/
|
|
341
591
|
startsWith(needles: string | number | null | Iterable<string | number | null>): boolean;
|
|
342
592
|
/**
|
|
343
593
|
* Determine if a given string doesn't start with a given substring.
|
|
594
|
+
*
|
|
595
|
+
* @param needles - The substring(s) to search for
|
|
596
|
+
* @returns boolean - True if the substring(s) are not found, false otherwise
|
|
344
597
|
*/
|
|
345
598
|
doesntStartWith(needles: string | number | null | Iterable<string | number | null>): boolean;
|
|
346
599
|
/**
|
|
347
600
|
* Convert a value to studly caps case.
|
|
601
|
+
*
|
|
602
|
+
* @returns The studly-cased string as a new Stringable instance.
|
|
348
603
|
*/
|
|
349
604
|
studly(): Stringable;
|
|
350
605
|
/**
|
|
351
606
|
* Convert the string to Pascal case.
|
|
607
|
+
*
|
|
608
|
+
* @returns The pascal-cased string as a new Stringable instance.
|
|
352
609
|
*/
|
|
353
610
|
pascal(): Stringable;
|
|
354
611
|
/**
|
|
355
612
|
* Returns the portion of the string specified by the start and length parameters.
|
|
613
|
+
*
|
|
614
|
+
* @param start - The starting position of the substring.
|
|
615
|
+
* @param length - The length of the substring. If null, extracts to the end of the string.
|
|
616
|
+
* @returns The extracted substring as a new Stringable instance.
|
|
356
617
|
*/
|
|
357
618
|
substr(start: number, length?: number | null): Stringable;
|
|
358
619
|
/**
|
|
359
620
|
* Returns the number of substring occurrences.
|
|
621
|
+
*
|
|
622
|
+
* @param needle - The substring to search for.
|
|
623
|
+
* @param offset - The offset to start searching from. Defaults to 0.
|
|
624
|
+
* @param length - The length of the string to search within. If null, searches to the end of the string.
|
|
625
|
+
* @returns The number of occurrences of the substring.
|
|
360
626
|
*/
|
|
361
627
|
substrCount(needle: string, offset?: number, length?: number | null): number;
|
|
362
628
|
/**
|
|
363
629
|
* Replace text within a portion of a string.
|
|
630
|
+
*
|
|
631
|
+
* @param replace - The replacement string.
|
|
632
|
+
* @param offset - The starting position to begin replacing.
|
|
633
|
+
* @param length - The number of characters to replace. If null, replaces to the end of the string.
|
|
634
|
+
* @returns The updated Stringable instance.
|
|
364
635
|
*/
|
|
365
636
|
substrReplace(replace: string, offset?: number | number[], length?: number | number[] | null): Stringable;
|
|
366
637
|
/**
|
|
367
638
|
* Swap multiple keywords in a string with other keywords.
|
|
639
|
+
*
|
|
640
|
+
* @param map - A record of keywords to swap (key: search, value: replacement).
|
|
641
|
+
* @returns The updated Stringable instance.
|
|
368
642
|
*/
|
|
369
643
|
swap(map: Record<string, string>): Stringable;
|
|
370
644
|
/**
|
|
371
645
|
* Take the first or last {$limit} characters.
|
|
646
|
+
*
|
|
647
|
+
* @param limit - The number of characters to take. Positive for start, negative for end.
|
|
648
|
+
* @returns The resulting substring as a new Stringable instance.
|
|
372
649
|
*/
|
|
373
650
|
take(limit: number): Stringable;
|
|
374
651
|
/**
|
|
375
652
|
* Trim the string of the given characters.
|
|
653
|
+
*
|
|
654
|
+
* @param charlist - The characters to trim from the string. If null, trims whitespace.
|
|
655
|
+
* @returns The trimmed string as a new Stringable instance.
|
|
376
656
|
*/
|
|
377
657
|
trim(charlist?: string | null): Stringable;
|
|
378
658
|
/**
|
|
379
659
|
* Left trim the string of the given characters.
|
|
660
|
+
*
|
|
661
|
+
* @param charlist - The characters to trim from the start of the string. If null, trims whitespace.
|
|
662
|
+
* @returns The left-trimmed string as a new Stringable instance.
|
|
380
663
|
*/
|
|
381
664
|
ltrim(charlist?: string | null): Stringable;
|
|
382
665
|
/**
|
|
383
666
|
* Right trim the string of the given characters.
|
|
667
|
+
*
|
|
668
|
+
* @param charlist - The characters to trim from the end of the string. If null, trims whitespace.
|
|
669
|
+
* @returns The right-trimmed string as a new Stringable instance.
|
|
384
670
|
*/
|
|
385
671
|
rtrim(charlist?: string | null): Stringable;
|
|
386
672
|
/**
|
|
387
673
|
* Make a string's first character lowercase.
|
|
674
|
+
*
|
|
675
|
+
* @returns The updated Stringable instance.
|
|
388
676
|
*/
|
|
389
677
|
lcfirst(): Stringable;
|
|
390
678
|
/**
|
|
391
679
|
* Make a string's first character uppercase.
|
|
680
|
+
*
|
|
681
|
+
* @returns The updated Stringable instance.
|
|
392
682
|
*/
|
|
393
683
|
ucfirst(): Stringable;
|
|
394
684
|
/**
|
|
395
685
|
* Split a string by uppercase characters.
|
|
686
|
+
*
|
|
687
|
+
* @returns An array of substrings split at uppercase characters.
|
|
396
688
|
*/
|
|
397
689
|
ucsplit(): string[];
|
|
398
690
|
/**
|
|
399
691
|
* Uppercase the first character of each word in a string.
|
|
692
|
+
*
|
|
693
|
+
* @returns The updated Stringable instance.
|
|
400
694
|
*/
|
|
401
695
|
ucwords(): Stringable;
|
|
402
696
|
/**
|
|
@@ -439,116 +733,219 @@ export declare class Stringable {
|
|
|
439
733
|
unless<TUnlessParameter, TUnlessReturnType>(value: ((instance: this) => TUnlessParameter) | TUnlessParameter | null, callback?: ((instance: this, value: TUnlessParameter) => TUnlessReturnType) | null, defaultCallback?: ((instance: this, value: TUnlessParameter) => TUnlessReturnType) | null): Stringable;
|
|
440
734
|
/**
|
|
441
735
|
* Execute the given callback if the string contains a given substring.
|
|
736
|
+
*
|
|
737
|
+
* @param needles - The substring(s) to search for
|
|
738
|
+
* @param callback - The callback to execute if the substring(s) are found
|
|
739
|
+
* @param defaultCallback - The callback to execute if the substring(s) are not found
|
|
740
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
442
741
|
*/
|
|
443
742
|
whenContains(needles: string | Iterable<string>, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
444
743
|
/**
|
|
445
744
|
* Execute the given callback if the string contains all array values.
|
|
745
|
+
*
|
|
746
|
+
* @param needles - The substring(s) to search for
|
|
747
|
+
* @param callback - The callback to execute if all substring(s) are found
|
|
748
|
+
* @param defaultCallback - The callback to execute if not all substring(s) are found
|
|
749
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
446
750
|
*/
|
|
447
751
|
whenContainsAll(needles: string | Iterable<string>, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
448
752
|
/**
|
|
449
753
|
* Execute the given callback if the string is empty.
|
|
754
|
+
*
|
|
755
|
+
* @param callback - The callback to execute if the string is empty
|
|
756
|
+
* @param defaultCallback - The callback to execute if the string is not empty
|
|
757
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
450
758
|
*/
|
|
451
759
|
whenEmpty(callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
452
760
|
/**
|
|
453
761
|
* Execute the given callback if the string is not empty.
|
|
762
|
+
*
|
|
763
|
+
* @param callback - The callback to execute if the string is not empty
|
|
764
|
+
* @param defaultCallback - The callback to execute if the string is empty
|
|
765
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
454
766
|
*/
|
|
455
767
|
whenNotEmpty(callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
456
768
|
/**
|
|
457
769
|
* Execute the given callback if the string ends with a given substring.
|
|
770
|
+
*
|
|
771
|
+
* @param needles - The substring(s) to search for
|
|
772
|
+
* @param callback - The callback to execute if the substring(s) are found
|
|
773
|
+
* @param defaultCallback - The callback to execute if the substring(s) are not found
|
|
774
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
458
775
|
*/
|
|
459
776
|
whenEndsWith(needles: string | Iterable<string>, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
460
777
|
/**
|
|
461
778
|
* Execute the given callback if the string doesn't end with a given substring.
|
|
779
|
+
*
|
|
780
|
+
* @param needles - The substring(s) to search for
|
|
781
|
+
* @param callback - The callback to execute if the substring(s) are not found
|
|
782
|
+
* @param defaultCallback - The callback to execute if the substring(s) are found
|
|
783
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
462
784
|
*/
|
|
463
785
|
whenDoesntEndWith(needles: string | Iterable<string>, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
464
786
|
/**
|
|
465
787
|
* Execute the given callback if the string is an exact match with the given value.
|
|
788
|
+
*
|
|
789
|
+
* @param value - The value to compare against
|
|
790
|
+
* @param callback - The callback to execute if the string matches the value
|
|
791
|
+
* @param defaultCallback - The callback to execute if the string does not match the value
|
|
792
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
466
793
|
*/
|
|
467
794
|
whenExactly(value: string, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
468
795
|
/**
|
|
469
796
|
* Execute the given callback if the string is not an exact match with the given value.
|
|
797
|
+
*
|
|
798
|
+
* @param value - The value to compare against
|
|
799
|
+
* @param callback - The callback to execute if the string does not match the value
|
|
800
|
+
* @param defaultCallback - The callback to execute if the string matches the value
|
|
801
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
470
802
|
*/
|
|
471
803
|
whenNotExactly(value: string, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
472
804
|
/**
|
|
473
805
|
* Execute the given callback if the string matches a given pattern.
|
|
806
|
+
*
|
|
807
|
+
* @param pattern - The pattern(s) to match against
|
|
808
|
+
* @param callback - The callback to execute if the pattern(s) match
|
|
809
|
+
* @param defaultCallback - The callback to execute if the pattern(s) do not match
|
|
810
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
474
811
|
*/
|
|
475
812
|
whenIs(pattern: string | Iterable<string>, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
476
813
|
/**
|
|
477
814
|
* Execute the given callback if the string is 7 bit ASCII.
|
|
815
|
+
*
|
|
816
|
+
* @param callback - The callback to execute if the string is ASCII
|
|
817
|
+
* @param defaultCallback - The callback to execute if the string is not ASCII
|
|
818
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
478
819
|
*/
|
|
479
820
|
whenIsAscii(callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
480
821
|
/**
|
|
481
822
|
* Execute the given callback if the string is a valid UUID.
|
|
823
|
+
*
|
|
824
|
+
* @param callback - The callback to execute if the string is a UUID
|
|
825
|
+
* @param defaultCallback - The callback to execute if the string is not a UUID
|
|
826
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
482
827
|
*/
|
|
483
828
|
whenIsUuid(callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
484
829
|
/**
|
|
485
830
|
* Execute the given callback if the string is a valid ULID.
|
|
831
|
+
*
|
|
832
|
+
* @param callback - The callback to execute if the string is a ULID
|
|
833
|
+
* @param defaultCallback - The callback to execute if the string is not a ULID
|
|
834
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
486
835
|
*/
|
|
487
836
|
whenIsUlid(callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
488
837
|
/**
|
|
489
838
|
* Execute the given callback if the string starts with a given substring.
|
|
839
|
+
*
|
|
840
|
+
* @param needles - The substring(s) to search for
|
|
841
|
+
* @param callback - The callback to execute if the substring(s) are found
|
|
842
|
+
* @param defaultCallback - The callback to execute if the substring(s) are not found
|
|
843
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
490
844
|
*/
|
|
491
845
|
whenStartsWith(needles: string | Iterable<string>, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
492
846
|
/**
|
|
493
847
|
* Execute the given callback if the string matches the given pattern.
|
|
848
|
+
*
|
|
849
|
+
* @param pattern - The pattern(s) to match against
|
|
850
|
+
* @param callback - The callback to execute if the pattern(s) match
|
|
851
|
+
* @param defaultCallback - The callback to execute if the pattern(s) do not match
|
|
852
|
+
* @returns Stringable - The current instance or the result of the callback
|
|
494
853
|
*/
|
|
495
854
|
whenTest(pattern: string, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
|
|
496
855
|
/**
|
|
497
856
|
* Limit the number of words in a string.
|
|
857
|
+
*
|
|
858
|
+
* @param wordsValue - The maximum number of words allowed. Defaults to 100.
|
|
859
|
+
* @param end - The string to append if the string is truncated. Defaults to "...".
|
|
860
|
+
* @returns The truncated string as a new Stringable instance.
|
|
498
861
|
*/
|
|
499
862
|
words(wordsValue?: number, end?: string): Stringable;
|
|
500
863
|
/**
|
|
501
864
|
* Get the number of words a string contains.
|
|
865
|
+
*
|
|
866
|
+
* @param characters - The characters to consider as word boundaries. If null, defaults to standard word boundaries.
|
|
867
|
+
* @returns The number of words in the string.
|
|
502
868
|
*/
|
|
503
869
|
wordCount(characters?: string | null): number;
|
|
504
870
|
/**
|
|
505
871
|
* Wrap a string to a given number of characters.
|
|
872
|
+
*
|
|
873
|
+
* @param characters - The number of characters at which to wrap the string. Defaults to 75.
|
|
874
|
+
* @param breakStr - The string to insert as a break. Defaults to "\n".
|
|
875
|
+
* @param cutLongWords - Whether to cut words longer than the specified length. Defaults to false.
|
|
876
|
+
* @returns The wrapped string as a new Stringable instance.
|
|
506
877
|
*/
|
|
507
878
|
wordWrap(characters?: number, breakStr?: string, cutLongWords?: boolean): Stringable;
|
|
508
879
|
/**
|
|
509
880
|
* Wrap the string with the given strings.
|
|
881
|
+
*
|
|
882
|
+
* @param before - The string to prepend
|
|
883
|
+
* @param after - The string to append. Defaults to the value of `before`
|
|
884
|
+
* @returns The wrapped string as a new Stringable instance.
|
|
510
885
|
*/
|
|
511
886
|
wrap(before: string, after?: string | null): Stringable;
|
|
512
887
|
/**
|
|
513
888
|
* Unwrap the string with the given strings.
|
|
889
|
+
*
|
|
890
|
+
* @param before - The string to remove from the start
|
|
891
|
+
* @param after - The string to remove from the end. Defaults to the value of `before`
|
|
892
|
+
* @returns The unwrapped string as a new Stringable instance.
|
|
514
893
|
*/
|
|
515
894
|
unwrap(before: string, after?: string | null): Stringable;
|
|
516
895
|
/**
|
|
517
896
|
* Convert the string to Base64 encoding.
|
|
897
|
+
*
|
|
898
|
+
* @returns The Base64 encoded string as a new Stringable instance.
|
|
518
899
|
*/
|
|
519
900
|
toBase64(): Stringable;
|
|
520
901
|
/**
|
|
521
902
|
* Decode the Base64 encoded string.
|
|
903
|
+
*
|
|
904
|
+
* @param strict - Whether to use strict decoding. Defaults to false.
|
|
905
|
+
* @returns The decoded string as a new Stringable instance, or false on failure.
|
|
522
906
|
*/
|
|
523
907
|
fromBase64(strict?: boolean): Stringable | false;
|
|
524
908
|
/**
|
|
525
909
|
* Get the underlying string value.
|
|
910
|
+
*
|
|
911
|
+
* @returns The string representation of the object.
|
|
526
912
|
*/
|
|
527
913
|
toString(): string;
|
|
528
914
|
/**
|
|
529
915
|
* Get the underlying string value.
|
|
916
|
+
*
|
|
917
|
+
* @returns The string value.
|
|
530
918
|
*/
|
|
531
919
|
value(): string;
|
|
532
920
|
/**
|
|
533
921
|
* Get the underlying string value as an integer.
|
|
922
|
+
*
|
|
923
|
+
* @param base - The base to use for conversion. Defaults to 10.
|
|
924
|
+
* @returns The integer value.
|
|
534
925
|
*/
|
|
535
926
|
toInteger(base?: number): number;
|
|
536
927
|
/**
|
|
537
928
|
* Get the underlying string value as a float.
|
|
929
|
+
*
|
|
930
|
+
* @returns The float value.
|
|
538
931
|
*/
|
|
539
932
|
toFloat(): number;
|
|
540
933
|
/**
|
|
541
934
|
* Get the underlying string value as a boolean.
|
|
542
935
|
*
|
|
543
|
-
*
|
|
936
|
+
* @returns true when value is "1", "true", "on", and "yes". Otherwise, returns false.
|
|
544
937
|
*/
|
|
545
938
|
toBoolean(): boolean;
|
|
546
939
|
/**
|
|
547
940
|
* Get the underlying string value as a Carbon instance.
|
|
941
|
+
*
|
|
942
|
+
* @returns The Date instance or null if parsing fails.
|
|
548
943
|
*/
|
|
549
944
|
toDate(): Date | null;
|
|
550
945
|
/**
|
|
551
946
|
* Convert the object to a string when JSON encoded.
|
|
947
|
+
*
|
|
948
|
+
* @returns The string representation of the object.
|
|
552
949
|
*/
|
|
553
950
|
jsonSerialize(): string;
|
|
554
951
|
}
|