@zinaid/str 0.0.1
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/LICENSE +21 -0
- package/README.md +0 -0
- package/dist/base64.d.ts +7 -0
- package/dist/base64.d.ts.map +1 -0
- package/dist/base64.js +123 -0
- package/dist/convertcase.d.ts +38 -0
- package/dist/convertcase.d.ts.map +1 -0
- package/dist/convertcase.js +49 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +133 -0
- package/dist/markdown.d.ts +26 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +32 -0
- package/dist/pluralizer.d.ts +39 -0
- package/dist/pluralizer.d.ts.map +1 -0
- package/dist/pluralizer.js +90 -0
- package/dist/random.d.ts +28 -0
- package/dist/random.d.ts.map +1 -0
- package/dist/random.js +44 -0
- package/dist/replacer.d.ts +31 -0
- package/dist/replacer.d.ts.map +1 -0
- package/dist/replacer.js +42 -0
- package/dist/str.d.ts +846 -0
- package/dist/str.d.ts.map +1 -0
- package/dist/str.js +1096 -0
- package/dist/stringable.d.ts +555 -0
- package/dist/stringable.d.ts.map +1 -0
- package/dist/stringable.js +862 -0
- package/dist/trimmer.d.ts +4 -0
- package/dist/trimmer.d.ts.map +1 -0
- package/dist/trimmer.js +128 -0
- package/package.json +43 -0
package/dist/str.d.ts
ADDED
|
@@ -0,0 +1,846 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the remainder of a string after the last occurrence of a given value.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* after('A house on a lake', 'house '); -> 'on a lake'
|
|
7
|
+
*/
|
|
8
|
+
export declare function after(subject: string, search: string | number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Return the remainder of a string after the last occurrence of a given value.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* afterLast('A house on a lake', 'a'); -> ' lake'
|
|
15
|
+
*/
|
|
16
|
+
export declare function afterLast(subject: string, search: string | number): string;
|
|
17
|
+
/**
|
|
18
|
+
* Transliterate a UTF-8 value to ASCII.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
*
|
|
22
|
+
* ascii('Héllo Wörld'); -> 'Hello World'
|
|
23
|
+
*/
|
|
24
|
+
export declare function ascii(value: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Transliterate a string to its closest ASCII representation.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
*
|
|
30
|
+
* transliterate('ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ'); -> 'test@laravel.com'
|
|
31
|
+
*/
|
|
32
|
+
export declare function transliterate(value: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get the portion of a string before the first occurrence of a given value.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
*
|
|
38
|
+
* before('hannah', 'nah'); -> 'han'
|
|
39
|
+
*/
|
|
40
|
+
export declare function before(subject: string, search: string | number): string;
|
|
41
|
+
/**
|
|
42
|
+
* Get the portion of a string before the last occurrence of a given value.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
*
|
|
46
|
+
* beforeLast('yvette', 'tte'); -> 'yve'
|
|
47
|
+
*/
|
|
48
|
+
export declare function beforeLast(subject: string, search: string | number): string;
|
|
49
|
+
/**
|
|
50
|
+
* Get the portion of a string between two given values.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
*
|
|
54
|
+
* between('foofoobar', 'foo', 'bar'); -> 'foo'
|
|
55
|
+
*/
|
|
56
|
+
export declare function between(subject: string, from: string | number, to: string | number): string;
|
|
57
|
+
/**
|
|
58
|
+
* Get the smallest possible portion of a string between two given values.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
*
|
|
62
|
+
* betweenFirst('foofoobar', 'foo', 'bar'); -> 'foo'
|
|
63
|
+
*/
|
|
64
|
+
export declare function betweenFirst(subject: string, from: string | number, to: string | number): string;
|
|
65
|
+
/**
|
|
66
|
+
* Convert a value to camel case.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
*
|
|
70
|
+
* camel('foo_bar'); -> 'fooBar'
|
|
71
|
+
*/
|
|
72
|
+
export declare function camel(value: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Get the character at the specified index.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
*
|
|
78
|
+
* charAt('hello', 1); -> 'e'
|
|
79
|
+
*/
|
|
80
|
+
export declare function charAt(subject: string, index: number): string | false;
|
|
81
|
+
/**
|
|
82
|
+
* Remove the given string(s) if it exists at the start of the haystack.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
*
|
|
86
|
+
* chopStart('foobar', 'foo'); -> 'bar'
|
|
87
|
+
*/
|
|
88
|
+
export declare function chopStart(subject: string, needle: string | string[]): string;
|
|
89
|
+
/**
|
|
90
|
+
* Remove the given string(s) if it exists at the end of the haystack.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
*
|
|
94
|
+
* chopEnd('foobar', 'bar'); -> 'foo'
|
|
95
|
+
*/
|
|
96
|
+
export declare function chopEnd(subject: string, needle: string | string[]): string;
|
|
97
|
+
/**
|
|
98
|
+
* Determine if a given string contains a given substring.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
*
|
|
102
|
+
* contains('Minion', 'ni'); -> true
|
|
103
|
+
* contains('Minion', 'Ni', true); -> true
|
|
104
|
+
* contains('Minion', 'Ni', false); -> false
|
|
105
|
+
*/
|
|
106
|
+
export declare function contains(haystack: string, needles: string | Iterable<string>, ignoreCase?: boolean): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Extracts an excerpt from text that matches the first instance of a phrase.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* excerpt('The quick brown fox', 'brown', { radius: 5 });
|
|
112
|
+
*/
|
|
113
|
+
export declare function excerpt(text: string | null, phrase?: string | null, options?: {
|
|
114
|
+
radius?: number;
|
|
115
|
+
omission?: string;
|
|
116
|
+
}): string | null;
|
|
117
|
+
/**
|
|
118
|
+
* Determine if a given string contains all array values.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
*
|
|
122
|
+
* containsAll('Taylor Otwell', ['taylor', 'otwell'], false); -> true
|
|
123
|
+
* containsAll('Taylor Otwell', ['taylor', 'xxx'], true); -> false
|
|
124
|
+
*/
|
|
125
|
+
export declare function containsAll(haystack: string, needles: Iterable<string>, ignoreCase?: boolean): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Determine if a given string doesn't contain a given substring.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
*
|
|
131
|
+
* doesntContain('Minion', 'ni'); -> false
|
|
132
|
+
* doesntContain('Minion', 'Ni', true); -> false
|
|
133
|
+
* doesntContain('Minion', 'Ni', false); -> true
|
|
134
|
+
*/
|
|
135
|
+
export declare function doesntContain(haystack: string, needles: string | Iterable<string>, ignoreCase?: boolean): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Replace consecutive instances of a given character with a single character in the given string.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
*
|
|
141
|
+
* deduplicate('hello world'); -> 'hello world'
|
|
142
|
+
* deduplicate('hello---world', '-'); -> 'hello-world'
|
|
143
|
+
* deduplicate('hello___world', '_'); -> 'hello-world'
|
|
144
|
+
* deduplicate('hello world', ' '); -> 'hello world'
|
|
145
|
+
*/
|
|
146
|
+
export declare function deduplicate(value: string, character?: string | string[]): string;
|
|
147
|
+
/**
|
|
148
|
+
* Determine if a given string ends with a given substring.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
*
|
|
152
|
+
* endsWith("Jason", "on"); -> true
|
|
153
|
+
* endsWith("Jason", "ON"); -> false
|
|
154
|
+
*/
|
|
155
|
+
export declare function endsWith(haystack: string | number | null, needles: string | number | Iterable<string>): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Determine if a given string doesn't end with a given substring.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
*
|
|
161
|
+
* doesntEndWith("Jason", "on"); -> false
|
|
162
|
+
* doesntEndWith("Jason", "ON"); -> true
|
|
163
|
+
*/
|
|
164
|
+
export declare function doesntEndWith(haystack: string | number | null, needles: string | number | Iterable<string>): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Cap a string with a single instance of a given value.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
*
|
|
170
|
+
* finish('hello', '!'); -> 'hello!'
|
|
171
|
+
*/
|
|
172
|
+
export declare function finish(value: string, cap: string): string;
|
|
173
|
+
/**
|
|
174
|
+
* Wrap the string with the given strings.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
*
|
|
178
|
+
* wrap('hello', '[', ']'); -> '[hello]'
|
|
179
|
+
*/
|
|
180
|
+
export declare function wrap(value: string, before: string, after?: string | null): string;
|
|
181
|
+
/**
|
|
182
|
+
* Unwrap the string with the given strings.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
*
|
|
186
|
+
* unwrap('[hello]', '[', ']'); -> 'hello'
|
|
187
|
+
*/
|
|
188
|
+
export declare function unwrap(value: string, before: string, after?: string | null): string;
|
|
189
|
+
/**
|
|
190
|
+
* Determine if a given string matches a given pattern.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
*
|
|
194
|
+
* is('hello', 'hello'); -> true
|
|
195
|
+
* is('hello', 'Hello', true); -> true
|
|
196
|
+
* is('hello', 'world'); -> false
|
|
197
|
+
*/
|
|
198
|
+
export declare function is(pattern: string | Iterable<string>, value: string | number, ignoreCase?: boolean): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Determine if a given string is 7 bit ASCII.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
*
|
|
204
|
+
* isAscii("Hello World"); -> true
|
|
205
|
+
* isAscii("こんにちは"); -> false
|
|
206
|
+
* isAscii("12345"); -> true
|
|
207
|
+
* isAscii("!@#$%"); -> true
|
|
208
|
+
* isAscii("Hello こんにちは"); -> false
|
|
209
|
+
*/
|
|
210
|
+
export declare function isAscii(value: string): boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Determine if a given value is valid JSON.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
*
|
|
216
|
+
* isJson('{"name": "John", "age": 30}'); -> true
|
|
217
|
+
* isJson('{"name": "John", "age": 30'); -> false
|
|
218
|
+
* isJson('Hello World'); -> false
|
|
219
|
+
*/
|
|
220
|
+
export declare function isJson(value: unknown): boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Determine if a given value is a valid URL.
|
|
223
|
+
*
|
|
224
|
+
* @param value - The value to check if it's URL
|
|
225
|
+
* @param protocols - An optional array of allowed protocols (e.g., ['http', 'https'])
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
*
|
|
229
|
+
* isUrl('https://laravel.com'); -> true
|
|
230
|
+
* isUrl('http://localhost'); -> true
|
|
231
|
+
* isUrl('invalid url'); -> false
|
|
232
|
+
*/
|
|
233
|
+
export declare function isUrl(value: string | unknown, protocols?: string[]): boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Determine if a given value is a valid UUID.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
*
|
|
239
|
+
* isUuid("550e8400-e29b-41d4-a716-446655440000", 4); -> true
|
|
240
|
+
* isUuid("550e8400-e29b-41d4-a716-446655440000", 5); -> false
|
|
241
|
+
*/
|
|
242
|
+
export declare function isUuid(value: string | unknown, version?: number | "nil" | "max" | null): boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Determine if a given value is a valid ULID.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
*
|
|
248
|
+
* isUlid("01F8MECHZX2D7J8F8C8D4B8F8C"); -> true
|
|
249
|
+
*/
|
|
250
|
+
export declare function isUlid(value: unknown): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Convert a string to kebab case.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
*
|
|
256
|
+
* kebab("Laravel PHP Framework"); -> "laravel-php-framework"
|
|
257
|
+
*/
|
|
258
|
+
export declare function kebab(value: string): string;
|
|
259
|
+
/**
|
|
260
|
+
* Return the length of the given string.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
*
|
|
264
|
+
* length("Hello World"); -> 11
|
|
265
|
+
*/
|
|
266
|
+
export declare function length(value: string): number;
|
|
267
|
+
/**
|
|
268
|
+
* Limit the number of characters in a string.
|
|
269
|
+
*
|
|
270
|
+
* @param string $value
|
|
271
|
+
* @param int $limit
|
|
272
|
+
* @param string $end
|
|
273
|
+
* @param bool $preserveWords
|
|
274
|
+
* @return string
|
|
275
|
+
*/
|
|
276
|
+
export declare function limit(value: string, limit?: number, end?: string, preserveWords?: boolean): string;
|
|
277
|
+
/**
|
|
278
|
+
* Convert the given string to lower-case.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
*
|
|
282
|
+
* lower("Hello World"); -> "hello world"
|
|
283
|
+
*/
|
|
284
|
+
export declare function lower(value: string): string;
|
|
285
|
+
/**
|
|
286
|
+
* Limit the number of words in a string.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
*
|
|
290
|
+
* words("Laravel PHP Framework", 2); -> "Laravel PHP Framework"
|
|
291
|
+
* words("Laravel PHP Framework", 1); -> "Laravel..."
|
|
292
|
+
*/
|
|
293
|
+
export declare function words(value: string, words?: number, end?: string): string;
|
|
294
|
+
/**
|
|
295
|
+
* Masks a portion of a string with a repeated character.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
*
|
|
299
|
+
* mask("taylor@email.com", "*", 3); -> "tay*************"
|
|
300
|
+
* mask("taylor@email.com", "*", 0, 6); -> "******@email.com"
|
|
301
|
+
* mask("taylor@email.com", "*", -13); -> "tay*************"
|
|
302
|
+
* mask("taylor@email.com", "*", -13, 3); -> "tay***@email.com"
|
|
303
|
+
*/
|
|
304
|
+
export declare function mask(value: string, character: string, index: number, length?: number | null): string;
|
|
305
|
+
/**
|
|
306
|
+
* Get the string matching the given pattern.
|
|
307
|
+
*
|
|
308
|
+
* @param string $pattern
|
|
309
|
+
* @param string $subject
|
|
310
|
+
* @return string
|
|
311
|
+
*/
|
|
312
|
+
export declare function match(pattern: string, subject: string): string;
|
|
313
|
+
/**
|
|
314
|
+
* Determine if a given string matches a given pattern.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
*
|
|
318
|
+
* Str::isMatch('/foo/', 'foo bar'); // true
|
|
319
|
+
* Str::isMatch('/bar/', 'foo bar'); // false
|
|
320
|
+
*/
|
|
321
|
+
export declare function isMatch(pattern: string | Iterable<string>, value: string): boolean;
|
|
322
|
+
/**
|
|
323
|
+
* Get the string matching the given pattern.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
*
|
|
327
|
+
* matchAll("/foo (.*)/", "foo bar baz"); -> ["foo bar baz"]
|
|
328
|
+
*/
|
|
329
|
+
export declare function matchAll(pattern: string, subject: string): string[];
|
|
330
|
+
/**
|
|
331
|
+
* Remove all non-numeric characters from a string.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
*
|
|
335
|
+
* numbers("foo123bar"); -> "123"
|
|
336
|
+
* numbers(["foo123bar", "abc456"]); -> ["123", "456"]
|
|
337
|
+
*/
|
|
338
|
+
export declare function numbers(value: string | string[]): string | string[];
|
|
339
|
+
/**
|
|
340
|
+
* Pad both sides of a string with another.
|
|
341
|
+
*
|
|
342
|
+
* @param string $value
|
|
343
|
+
* @param int $length
|
|
344
|
+
* @param string $pad
|
|
345
|
+
* @return string
|
|
346
|
+
*/
|
|
347
|
+
export declare function padBoth(value: string, length: number, pad?: string): string;
|
|
348
|
+
/**
|
|
349
|
+
* Pad the left side of a string with another.
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
*
|
|
353
|
+
* padLeft("Alien", 10, "-="); -> "-=-=-Alien"
|
|
354
|
+
* padLeft("Alien", 10); -> " Alien"
|
|
355
|
+
* padLeft("❤MultiByte☆", 16); -> " ❤MultiByte☆"
|
|
356
|
+
* padLeft("❤MultiByte☆", 16, "❤☆"); -> "❤☆❤☆❤❤MultiByte☆"
|
|
357
|
+
*/
|
|
358
|
+
export declare function padLeft(value: string, length: number, pad?: string): string;
|
|
359
|
+
/**
|
|
360
|
+
* Pad the right side of a string with another.
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
*
|
|
364
|
+
* padRight("Alien", 10, "-="); -> "Alien-=-="
|
|
365
|
+
* padRight("Alien", 10); -> "Alien "
|
|
366
|
+
* padRight("❤MultiByte☆", 16); -> "❤MultiByte☆ "
|
|
367
|
+
* padRight("❤MultiByte☆", 16, "❤☆"); -> "❤MultiByte☆❤☆❤☆"
|
|
368
|
+
*/
|
|
369
|
+
export declare function padRight(value: string, length: number, pad?: string): string;
|
|
370
|
+
/**
|
|
371
|
+
* Create a padding string.
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
*
|
|
375
|
+
* makePad(" ", 5); -> " "
|
|
376
|
+
* makePad("-", 5); -> "-----"
|
|
377
|
+
* makePad("❤", 5); -> "❤❤❤❤❤"
|
|
378
|
+
*/
|
|
379
|
+
export declare function makePad(padStr: string, needed: number): string;
|
|
380
|
+
/**
|
|
381
|
+
* Pluralize the last word of an English, studly caps case string.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
*
|
|
385
|
+
* pluralStudly("These are the school", 4); -> "These are the schools"
|
|
386
|
+
*/
|
|
387
|
+
export declare function pluralStudly(value: string, count?: number): string;
|
|
388
|
+
/**
|
|
389
|
+
* Pluralize the last word of an English, Pascal caps case string.
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
*
|
|
393
|
+
* pluralPascal("These are the school", 4); -> "These are the schools"
|
|
394
|
+
*/
|
|
395
|
+
export declare function pluralPascal(value: string, count?: number): string;
|
|
396
|
+
/**
|
|
397
|
+
* Generate a random, secure password.
|
|
398
|
+
*
|
|
399
|
+
* Mirrors Laravel's Str::password behavior:
|
|
400
|
+
* - Ensures at least one character from each enabled set
|
|
401
|
+
* - Uses a combined pool for remaining characters
|
|
402
|
+
* - Shuffles result and returns a string of requested length
|
|
403
|
+
*
|
|
404
|
+
* @param length The desired length of the password (default: 32)
|
|
405
|
+
* @param letters Whether to include letters (default: true)
|
|
406
|
+
* @param numbers Whether to include numbers (default: true)
|
|
407
|
+
* @param symbols Whether to include symbols (default: true)
|
|
408
|
+
* @param spaces Whether to include spaces (default: false)
|
|
409
|
+
* @return The generated password string
|
|
410
|
+
*/
|
|
411
|
+
export declare function password(length?: number, letters?: boolean, numbers?: boolean, symbols?: boolean, spaces?: boolean): string;
|
|
412
|
+
/**
|
|
413
|
+
* Find the multi-byte safe position of the first occurrence of a given substring in a string.
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
*
|
|
417
|
+
* position('Hello, World!', 'World!'); -> 7
|
|
418
|
+
* position('Hello, World!', 'world!', 0); -> false
|
|
419
|
+
*/
|
|
420
|
+
export declare function position(haystack: string, needle: string, offset?: number): number | false;
|
|
421
|
+
/**
|
|
422
|
+
* Generate a more truly "random" alpha-numeric string.
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
*
|
|
426
|
+
* random(); -> "a1b2c3d4e5f6g7h8"
|
|
427
|
+
*/
|
|
428
|
+
export declare function random(length?: number): string;
|
|
429
|
+
/**
|
|
430
|
+
* Set the callable that will be used to generate random strings.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
*
|
|
434
|
+
* createRandomStringsUsing((length) => "x".repeat(length));
|
|
435
|
+
*/
|
|
436
|
+
export declare function createRandomStringsUsing(factory: ((length: number) => string) | null): void;
|
|
437
|
+
/**
|
|
438
|
+
* Set the sequence that will be used to generate random strings.
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
*
|
|
442
|
+
* createRandomStringsUsingSequence(['a', 'b', 'c']);
|
|
443
|
+
* createRandomStringsUsingSequence(['x', 'y', 'z'], (length) => "z".repeat(length));
|
|
444
|
+
*/
|
|
445
|
+
export declare function createRandomStringsUsingSequence(sequence: string[], whenMissing?: (length: number) => string): void;
|
|
446
|
+
/**
|
|
447
|
+
* Indicate that random strings should be created normally and not using a custom factory.
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
*
|
|
451
|
+
* createRandomStringsNormally();
|
|
452
|
+
*/
|
|
453
|
+
export declare function createRandomStringsNormally(): void;
|
|
454
|
+
/**
|
|
455
|
+
* Repeat the given string.
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
*
|
|
459
|
+
* repeat("foo", 3); -> "foofoofoo"
|
|
460
|
+
*/
|
|
461
|
+
export declare function repeat(string: string, times: number): string;
|
|
462
|
+
/**
|
|
463
|
+
* Replace a given value in the string sequentially with an array.
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
*
|
|
467
|
+
* replaceArray('?', ['foo', 'bar', 'baz'], '?/?/?'); -> 'foo/bar/baz'
|
|
468
|
+
* replaceArray('?', ['foo', 'bar', 'baz'], '?/?/?/?'); -> 'foo/bar/baz/?'
|
|
469
|
+
* replaceArray('?', {'x' => 'foo', 'y' => 'bar'}, '?/?'); -> 'foo/bar'
|
|
470
|
+
*/
|
|
471
|
+
export declare function replaceArray(search: string, replace: Record<string, string> | Iterable<string>, subject: string): string;
|
|
472
|
+
/**
|
|
473
|
+
* Convert the given value to a string or return the given fallback on failure.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
*
|
|
477
|
+
* toStringOr(123);
|
|
478
|
+
*/
|
|
479
|
+
export declare function toStringOr(value: unknown, fallback: string): string;
|
|
480
|
+
/**
|
|
481
|
+
* Replace the given value in the given string.
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
*
|
|
485
|
+
* replace("foo", "bar", "foo baz"); -> "bar baz"
|
|
486
|
+
*/
|
|
487
|
+
export declare function replace<T extends string | Iterable<string>>(search: string | Iterable<string>, replacement: string | Iterable<string>, subject: T, caseSensitive?: boolean): T extends string ? string : string[];
|
|
488
|
+
/**
|
|
489
|
+
* Replace the first occurrence of a given value in the string.
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
*
|
|
493
|
+
* replaceFirst('bar', 'qux', 'foobar foobar'); -> 'fooqux foobar'
|
|
494
|
+
*/
|
|
495
|
+
export declare function replaceFirst(search: string | number, replace: string, subject: string): string;
|
|
496
|
+
/**
|
|
497
|
+
* Replace the first occurrence of the given value if it appears at the start of the string.
|
|
498
|
+
*
|
|
499
|
+
* @param string $search
|
|
500
|
+
* @param string $replace
|
|
501
|
+
* @param string $subject
|
|
502
|
+
* @return string
|
|
503
|
+
*/
|
|
504
|
+
export declare function replaceStart(search: string | number, replace: string, subject: string): string;
|
|
505
|
+
/**
|
|
506
|
+
* Replace the last occurrence of a given value in the string.
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
*
|
|
510
|
+
* replaceLast('bar', 'qux', 'foobar foobar'); -> 'foobar foobarqux'
|
|
511
|
+
*/
|
|
512
|
+
export declare function replaceLast(search: string | number, replace: string, subject: string): string;
|
|
513
|
+
/**
|
|
514
|
+
* Replace the last occurrence of a given value if it appears at the end of the string.
|
|
515
|
+
*
|
|
516
|
+
* @example
|
|
517
|
+
*
|
|
518
|
+
* replaceEnd('bar', 'qux', 'foobar foobar'); -> 'foobar fooqux'
|
|
519
|
+
*/
|
|
520
|
+
export declare function replaceEnd(search: string | number, replace: string, subject: string): string;
|
|
521
|
+
/**
|
|
522
|
+
* Replace the patterns matching the given regular expression.
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
*
|
|
526
|
+
* replaceMatches(/foo/, 'bar', 'foobar'); -> 'barbar'
|
|
527
|
+
* replaceMatches(/foo/, ['bar', 'baz'], 'foobar'); -> ['barbar', 'foobaz']
|
|
528
|
+
* replaceMatches(/foo/, (match) => match[1]!.toUpperCase(), 'foobar'); -> 'Bar'
|
|
529
|
+
*/
|
|
530
|
+
export declare function replaceMatches(pattern: string | string[] | RegExp | RegExp[], replace: string | string[] | ((match: string[]) => string), subject: string | string[], limit?: number): string | string[] | null;
|
|
531
|
+
/**
|
|
532
|
+
* Strip HTML tags from a string.
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
*
|
|
536
|
+
* stripTags("<p>Hello World</p>"); -> "Hello World"
|
|
537
|
+
*/
|
|
538
|
+
export declare function stripTags(value: string): string;
|
|
539
|
+
/**
|
|
540
|
+
* Remove any occurrence of the given string in the subject.
|
|
541
|
+
*
|
|
542
|
+
* @example
|
|
543
|
+
*
|
|
544
|
+
* remove("foo", "foobar"); -> "bar"
|
|
545
|
+
* remove(["foo", "bar"], "foobar"); -> ""
|
|
546
|
+
*/
|
|
547
|
+
export declare function remove(search: string | Iterable<string>, subject: string | Iterable<string>, caseSensitive?: boolean): string | string[];
|
|
548
|
+
/**
|
|
549
|
+
* Reverse the given string.
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
*
|
|
553
|
+
* reverse("hello"); -> "olleh"
|
|
554
|
+
* reverse("world"); -> "dlrow"
|
|
555
|
+
* reverse(""); -> ""
|
|
556
|
+
*/
|
|
557
|
+
export declare function reverse(value: string): string;
|
|
558
|
+
/**
|
|
559
|
+
* Begin a string with a single instance of a given value.
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
*
|
|
563
|
+
* start("test/string", "/"); -> "/test/string"
|
|
564
|
+
* start("/test/string", "/"); -> "/test/string"
|
|
565
|
+
* start("//test/string", "/"); -> "/test/string"
|
|
566
|
+
*/
|
|
567
|
+
export declare function start(value: string, prefix: string): string;
|
|
568
|
+
/**
|
|
569
|
+
* Convert the given string to proper case for each word.
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
*
|
|
573
|
+
* headline("foo bar baz"); -> "Foo Bar Baz"
|
|
574
|
+
* headline("foO bAr BaZ"); -> "Foo Bar Baz"
|
|
575
|
+
*/
|
|
576
|
+
export declare function headline(value: string): string;
|
|
577
|
+
/**
|
|
578
|
+
* Convert the given string to APA-style title case.
|
|
579
|
+
*
|
|
580
|
+
* See: https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
*
|
|
584
|
+
* apa("foo bar baz"); -> "Foo Bar Baz"
|
|
585
|
+
* apa("foO bAr BaZ"); -> "Foo Bar Baz"
|
|
586
|
+
*/
|
|
587
|
+
export declare function apa(value: string): string;
|
|
588
|
+
/**
|
|
589
|
+
* Generate a URL friendly "slug" from a given string.
|
|
590
|
+
*
|
|
591
|
+
* @param string $title
|
|
592
|
+
* @param string $separator
|
|
593
|
+
* @param array<string, string> $dictionary
|
|
594
|
+
* @return string
|
|
595
|
+
*/
|
|
596
|
+
export declare function slug(title: string, separator?: string, dictionary?: Record<string, string>): string;
|
|
597
|
+
/**
|
|
598
|
+
* Convert a string to snake case.
|
|
599
|
+
*
|
|
600
|
+
* @param string $value
|
|
601
|
+
* @param string $delimiter
|
|
602
|
+
* @return string
|
|
603
|
+
*/
|
|
604
|
+
export declare function snake(value: string, delimiter?: string): string;
|
|
605
|
+
/**
|
|
606
|
+
* Remove all "extra" blank space from the given string.
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
*
|
|
610
|
+
* squish(`
|
|
611
|
+
foo
|
|
612
|
+
bar
|
|
613
|
+
`); -> "foo bar"
|
|
614
|
+
*/
|
|
615
|
+
export declare function squish(value: string): string;
|
|
616
|
+
/**
|
|
617
|
+
* Determine if a given string starts with a given substring.
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
*
|
|
621
|
+
* startsWith("hello world", "hello"); -> true
|
|
622
|
+
* startsWith("hello world", "world"); -> false
|
|
623
|
+
*/
|
|
624
|
+
export declare function startsWith(haystack: string | number | null, needles: string | number | null | Iterable<string | number | null>): boolean;
|
|
625
|
+
/**
|
|
626
|
+
* Determine if a given string doesn't start with a given substring.
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
*
|
|
630
|
+
* expect(doesntStartWith("jason", ["day"])).toBe(true);
|
|
631
|
+
*/
|
|
632
|
+
export declare function doesntStartWith(haystack: string | number | null, needles: string | number | null | Iterable<string | number | null>): boolean;
|
|
633
|
+
/**
|
|
634
|
+
* Convert a value to studly caps case.
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
*
|
|
638
|
+
* studly("fooBar"); -> "FooBar"
|
|
639
|
+
* studly("foo_bar"); -> "FooBar"
|
|
640
|
+
* studly("foo-barBaz"); -> "FooBarBaz"
|
|
641
|
+
*/
|
|
642
|
+
export declare function studly(value: string): string;
|
|
643
|
+
/**
|
|
644
|
+
* Convert a value to Pascal case.
|
|
645
|
+
*
|
|
646
|
+
* @param string $value
|
|
647
|
+
* @return string
|
|
648
|
+
*/
|
|
649
|
+
export declare function pascal(value: string): string;
|
|
650
|
+
/**
|
|
651
|
+
* Swap multiple keywords in a string with other keywords.
|
|
652
|
+
*
|
|
653
|
+
* @example
|
|
654
|
+
*
|
|
655
|
+
* swap(
|
|
656
|
+
* {
|
|
657
|
+
* 'foo': 'bar',
|
|
658
|
+
* 'baz': 'qux',
|
|
659
|
+
* },
|
|
660
|
+
* 'foo baz'
|
|
661
|
+
* ); -> 'bar qux'
|
|
662
|
+
*/
|
|
663
|
+
export declare function swap(map: Record<string, string>, subject: string): string;
|
|
664
|
+
/**
|
|
665
|
+
* Take the first or last {$limit} characters of a string.
|
|
666
|
+
*
|
|
667
|
+
* @example
|
|
668
|
+
*
|
|
669
|
+
* take("hello world", 5); -> "hello"
|
|
670
|
+
* take("hello world", -5); -> "world"
|
|
671
|
+
*/
|
|
672
|
+
export declare function take(value: string, limit: number): string;
|
|
673
|
+
/**
|
|
674
|
+
* Make a string's first character lowercase.
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
*
|
|
678
|
+
* lcfirst('Hello World'); -> 'hello World'
|
|
679
|
+
*/
|
|
680
|
+
export declare function lcfirst(value: string): string;
|
|
681
|
+
/**
|
|
682
|
+
* Make a string's first character uppercase.
|
|
683
|
+
*
|
|
684
|
+
* @example
|
|
685
|
+
*
|
|
686
|
+
* ucfirst('hello world'); -> 'Hello world'
|
|
687
|
+
*/
|
|
688
|
+
export declare function ucfirst(value: string): string;
|
|
689
|
+
/**
|
|
690
|
+
* Split a string into pieces by uppercase characters.
|
|
691
|
+
*
|
|
692
|
+
* @example
|
|
693
|
+
*
|
|
694
|
+
* ucsplit('laravelPHPFramework'); -> ['laravel', 'P', 'H', 'P', 'Framework']
|
|
695
|
+
* ucsplit('Laravel-phP-framework'); -> ['Laravel-ph', 'P-framework']
|
|
696
|
+
* ucsplit('ÖffentlicheÜberraschungen'); -> ['Öffentliche', 'Überraschungen']
|
|
697
|
+
*/
|
|
698
|
+
export declare function ucsplit(value: string): string[];
|
|
699
|
+
/**
|
|
700
|
+
* Uppercase the first letter of each word in a string.
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
*
|
|
704
|
+
* ucwords('hello world'); -> 'Hello World'
|
|
705
|
+
* ucwords('laravel php framework'); -> 'Laravel Php Framework'
|
|
706
|
+
* ucwords('Öffentliche Überraschungen'); -> 'Öffentliche Überraschungen'
|
|
707
|
+
*/
|
|
708
|
+
export declare function ucwords(value: string, separators?: string | string[]): string;
|
|
709
|
+
/**
|
|
710
|
+
* Get the number of words a string contains.
|
|
711
|
+
*
|
|
712
|
+
* @example
|
|
713
|
+
*
|
|
714
|
+
* wordCount('Hello, world!'); -> 2
|
|
715
|
+
* wordCount('мама мыла раму'); -> 3
|
|
716
|
+
*/
|
|
717
|
+
export declare function wordCount(value: string, characters?: string | null): number;
|
|
718
|
+
/**
|
|
719
|
+
* Wrap a string to a given number of characters.
|
|
720
|
+
*
|
|
721
|
+
* @example
|
|
722
|
+
*
|
|
723
|
+
* wordWrap("Hello World", 3, "<br />"); -> "Hello<br />World"
|
|
724
|
+
* wordWrap("Hello World", 3, "<br />", true); -> "Hel<br />lo<br />Wor<br />ld"
|
|
725
|
+
* wordWrap("❤Multi Byte☆❤☆❤☆❤", 3, "<br />"); -> "❤Multi<br />Byte☆❤☆❤☆❤"
|
|
726
|
+
*/
|
|
727
|
+
export declare function wordWrap(value: string, characters?: number, breakStr?: string, cutLongWords?: boolean): string;
|
|
728
|
+
/**
|
|
729
|
+
* Generate a UUID (version 4).
|
|
730
|
+
*
|
|
731
|
+
* @example
|
|
732
|
+
*
|
|
733
|
+
* uuid(); -> "550e8400-e29b-41d4-a716-446655440000"
|
|
734
|
+
*/
|
|
735
|
+
export declare function uuid(): string;
|
|
736
|
+
/**
|
|
737
|
+
* Generate a UUID (version 7).
|
|
738
|
+
*
|
|
739
|
+
* @example
|
|
740
|
+
*
|
|
741
|
+
* uuid7(); -> "550e8400-e29b-41d4-a716-446655440000"
|
|
742
|
+
*/
|
|
743
|
+
export declare function uuid7(): string;
|
|
744
|
+
/**
|
|
745
|
+
* Set the callable that will be used to generate UUIDs.
|
|
746
|
+
*
|
|
747
|
+
* @example
|
|
748
|
+
*
|
|
749
|
+
* createUuidsUsing(() => "custom-uuid");
|
|
750
|
+
*/
|
|
751
|
+
export declare function createUuidsUsing(factory?: (() => string) | null): void;
|
|
752
|
+
/**
|
|
753
|
+
* Set the sequence that will be used to generate UUIDs.
|
|
754
|
+
*
|
|
755
|
+
* @example
|
|
756
|
+
*
|
|
757
|
+
* createUuidsUsingSequence(["uuid1", "uuid2"], () => "custom-uuid");
|
|
758
|
+
*/
|
|
759
|
+
export declare function createUuidsUsingSequence(sequence: string[], whenMissing?: (() => string) | null): void;
|
|
760
|
+
/**
|
|
761
|
+
* Always return the same UUID when generating new UUIDs.
|
|
762
|
+
*
|
|
763
|
+
* @example
|
|
764
|
+
*
|
|
765
|
+
* freezeUuids();
|
|
766
|
+
*/
|
|
767
|
+
export declare function freezeUuids(callback?: ((value: string) => string) | null): string;
|
|
768
|
+
/**
|
|
769
|
+
* Indicate that UUIDs should be created normally and not using a custom factory.
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
*
|
|
773
|
+
* createUuidsNormally();
|
|
774
|
+
*/
|
|
775
|
+
export declare function createUuidsNormally(): void;
|
|
776
|
+
/**
|
|
777
|
+
* Generate a ULID.
|
|
778
|
+
*
|
|
779
|
+
* @example
|
|
780
|
+
*
|
|
781
|
+
* ulid(); -> "01F8MECHZX2D7J8F8C8D4B8F8C"
|
|
782
|
+
*/
|
|
783
|
+
export declare function ulid(time?: Date | number | null): string;
|
|
784
|
+
/**
|
|
785
|
+
* Indicate that ULIDs should be created normally and not using a custom factory.
|
|
786
|
+
*
|
|
787
|
+
* @example
|
|
788
|
+
*
|
|
789
|
+
* createUlidsNormally();
|
|
790
|
+
*/
|
|
791
|
+
export declare function createUlidsNormally(): void;
|
|
792
|
+
/**
|
|
793
|
+
* Set the callable that will be used to generate ULIDs.
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
*
|
|
797
|
+
* createUlidsUsing(() => of("1234").toString());
|
|
798
|
+
*/
|
|
799
|
+
export declare function createUlidsUsing(factory?: (() => string) | null): void;
|
|
800
|
+
/**
|
|
801
|
+
* Set the sequence that will be used to generate ULIDs.
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
*
|
|
805
|
+
* createUlidsUsingSequence(["ulid1", "ulid2"], () => "custom-ulid");
|
|
806
|
+
*/
|
|
807
|
+
export declare function createUlidsUsingSequence(sequence: string[], whenMissing?: (() => string) | null): void;
|
|
808
|
+
/**
|
|
809
|
+
* Always return the same ULID when generating new ULIDs.
|
|
810
|
+
*
|
|
811
|
+
* @example
|
|
812
|
+
*
|
|
813
|
+
* freezeUlids(() => "custom-ulid");
|
|
814
|
+
*/
|
|
815
|
+
export declare function freezeUlids(callback?: ((value: string) => string) | null): string;
|
|
816
|
+
/**
|
|
817
|
+
* Get the size of the snake cache.
|
|
818
|
+
*
|
|
819
|
+
* @example
|
|
820
|
+
*
|
|
821
|
+
* snakeCacheSize();
|
|
822
|
+
*/
|
|
823
|
+
export declare function snakeCacheSize(): number;
|
|
824
|
+
/**
|
|
825
|
+
* Get the size of the camel cache.
|
|
826
|
+
*
|
|
827
|
+
* @example
|
|
828
|
+
*
|
|
829
|
+
* camelCacheSize();
|
|
830
|
+
*/
|
|
831
|
+
export declare function camelCacheSize(): number;
|
|
832
|
+
/**
|
|
833
|
+
* Get the size of the studly cache.
|
|
834
|
+
*
|
|
835
|
+
* @example
|
|
836
|
+
*
|
|
837
|
+
* studlyCacheSize();
|
|
838
|
+
*/
|
|
839
|
+
export declare function studlyCacheSize(): number;
|
|
840
|
+
/**
|
|
841
|
+
* Remove all strings from the casing caches.
|
|
842
|
+
*
|
|
843
|
+
* @return void
|
|
844
|
+
*/
|
|
845
|
+
export declare function flushCache(): void;
|
|
846
|
+
//# sourceMappingURL=str.d.ts.map
|