@zinaid/str 0.0.6 → 0.0.8
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 +16 -0
- package/dist/ascii/index.d.ts.map +1 -1
- package/dist/ascii/index.js +43 -4
- 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 +113 -112
- 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 → str/index.d.ts} +297 -66
- package/dist/str/index.d.ts.map +1 -0
- package/dist/str/index.js +939 -0
- 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 +5 -5
- package/dist/str.d.ts.map +0 -1
- package/dist/str.js +0 -993
|
@@ -13,6 +13,10 @@ export declare function after(subject: string, search: string | number): string;
|
|
|
13
13
|
/**
|
|
14
14
|
* Return the remainder of a string after the last occurrence of a given value.
|
|
15
15
|
*
|
|
16
|
+
* @param subject - The string to search in
|
|
17
|
+
* @param search - The value to search for
|
|
18
|
+
* @returns The portion of the string after the last occurrence of the search value
|
|
19
|
+
*
|
|
16
20
|
* @example
|
|
17
21
|
*
|
|
18
22
|
* afterLast('A house on a lake', 'a'); -> ' lake'
|
|
@@ -21,6 +25,10 @@ export declare function afterLast(subject: string, search: string | number): str
|
|
|
21
25
|
/**
|
|
22
26
|
* Get the portion of a string before the first occurrence of a given value.
|
|
23
27
|
*
|
|
28
|
+
* @param subject - The string to search in
|
|
29
|
+
* @param search - The value to search for
|
|
30
|
+
* @returns The portion of the string before the first occurrence of the search value
|
|
31
|
+
*
|
|
24
32
|
* @example
|
|
25
33
|
*
|
|
26
34
|
* before('hannah', 'nah'); -> 'han'
|
|
@@ -29,6 +37,10 @@ export declare function before(subject: string, search: string | number): string
|
|
|
29
37
|
/**
|
|
30
38
|
* Get the portion of a string before the last occurrence of a given value.
|
|
31
39
|
*
|
|
40
|
+
* @param subject - The string to search in
|
|
41
|
+
* @param search - The value to search for
|
|
42
|
+
* @returns The portion of the string before the last occurrence of the search value
|
|
43
|
+
*
|
|
32
44
|
* @example
|
|
33
45
|
*
|
|
34
46
|
* beforeLast('yvette', 'tte'); -> 'yve'
|
|
@@ -37,6 +49,11 @@ export declare function beforeLast(subject: string, search: string | number): st
|
|
|
37
49
|
/**
|
|
38
50
|
* Get the portion of a string between two given values.
|
|
39
51
|
*
|
|
52
|
+
* @param subject - The string to search in
|
|
53
|
+
* @param from - The starting value
|
|
54
|
+
* @param to - The ending value
|
|
55
|
+
* @returns The portion of the string between the two given values
|
|
56
|
+
*
|
|
40
57
|
* @example
|
|
41
58
|
*
|
|
42
59
|
* between('foofoobar', 'foo', 'bar'); -> 'foo'
|
|
@@ -45,6 +62,11 @@ export declare function between(subject: string, from: string | number, to: stri
|
|
|
45
62
|
/**
|
|
46
63
|
* Get the smallest possible portion of a string between two given values.
|
|
47
64
|
*
|
|
65
|
+
* @param subject - The string to search in
|
|
66
|
+
* @param from - The starting value
|
|
67
|
+
* @param to - The ending value
|
|
68
|
+
* @returns The smallest portion of the string between the two given values
|
|
69
|
+
*
|
|
48
70
|
* @example
|
|
49
71
|
*
|
|
50
72
|
* betweenFirst('foofoobar', 'foo', 'bar'); -> 'foo'
|
|
@@ -53,6 +75,9 @@ export declare function betweenFirst(subject: string, from: string | number, to:
|
|
|
53
75
|
/**
|
|
54
76
|
* Convert a value to camel case.
|
|
55
77
|
*
|
|
78
|
+
* @param value - The string to convert
|
|
79
|
+
* @returns The camel-cased string
|
|
80
|
+
*
|
|
56
81
|
* @example
|
|
57
82
|
*
|
|
58
83
|
* camel('foo_bar'); -> 'fooBar'
|
|
@@ -61,6 +86,10 @@ export declare function camel(value: string): string;
|
|
|
61
86
|
/**
|
|
62
87
|
* Get the character at the specified index.
|
|
63
88
|
*
|
|
89
|
+
* @param subject - The string to get the character from
|
|
90
|
+
* @param index - The index of the character to get
|
|
91
|
+
* @returns The character at the specified index, or false if the index is out of bounds
|
|
92
|
+
*
|
|
64
93
|
* @example
|
|
65
94
|
*
|
|
66
95
|
* charAt('hello', 1); -> 'e'
|
|
@@ -69,6 +98,10 @@ export declare function charAt(subject: string, index: number): string | false;
|
|
|
69
98
|
/**
|
|
70
99
|
* Remove the given string(s) if it exists at the start of the haystack.
|
|
71
100
|
*
|
|
101
|
+
* @param subject - The string to chop from
|
|
102
|
+
* @param needle - The string or strings to remove
|
|
103
|
+
* @returns The string with the given string(s) removed from the start
|
|
104
|
+
*
|
|
72
105
|
* @example
|
|
73
106
|
*
|
|
74
107
|
* chopStart('foobar', 'foo'); -> 'bar'
|
|
@@ -77,6 +110,10 @@ export declare function chopStart(subject: string, needle: string | string[]): s
|
|
|
77
110
|
/**
|
|
78
111
|
* Remove the given string(s) if it exists at the end of the haystack.
|
|
79
112
|
*
|
|
113
|
+
* @param subject - The string to chop from
|
|
114
|
+
* @param needle - The string or strings to remove
|
|
115
|
+
* @returns The string with the given string(s) removed from the end
|
|
116
|
+
*
|
|
80
117
|
* @example
|
|
81
118
|
*
|
|
82
119
|
* chopEnd('foobar', 'bar'); -> 'foo'
|
|
@@ -99,6 +136,11 @@ export declare function contains(haystack: string, needles: string | Iterable<st
|
|
|
99
136
|
/**
|
|
100
137
|
* Extracts an excerpt from text that matches the first instance of a phrase.
|
|
101
138
|
*
|
|
139
|
+
* @param text - The text to extract the excerpt from
|
|
140
|
+
* @param phrase - The phrase to search for
|
|
141
|
+
* @param options - Additional options for excerpt extraction
|
|
142
|
+
* @returns The extracted excerpt, or null if the phrase is not found
|
|
143
|
+
*
|
|
102
144
|
* @example
|
|
103
145
|
* excerpt('The quick brown fox', 'brown', { radius: 5 });
|
|
104
146
|
*/
|
|
@@ -109,6 +151,11 @@ export declare function excerpt(text: string | null, phrase?: string | null, opt
|
|
|
109
151
|
/**
|
|
110
152
|
* Determine if a given string contains all array values.
|
|
111
153
|
*
|
|
154
|
+
* @param haystack - The string to search in
|
|
155
|
+
* @param needles - The substrings to search for
|
|
156
|
+
* @param ignoreCase - Whether to ignore case when searching
|
|
157
|
+
* @returns True if all substrings are found, false otherwise
|
|
158
|
+
*
|
|
112
159
|
* @example
|
|
113
160
|
*
|
|
114
161
|
* containsAll('Taylor Otwell', ['taylor', 'otwell'], false); -> true
|
|
@@ -118,6 +165,11 @@ export declare function containsAll(haystack: string, needles: Iterable<string>,
|
|
|
118
165
|
/**
|
|
119
166
|
* Determine if a given string doesn't contain a given substring.
|
|
120
167
|
*
|
|
168
|
+
* @param haystack - The string to search in
|
|
169
|
+
* @param needles - The substring or substrings to search for
|
|
170
|
+
* @param ignoreCase - Whether to ignore case when searching
|
|
171
|
+
* @returns True if the substring is not found, false otherwise
|
|
172
|
+
*
|
|
121
173
|
* @example
|
|
122
174
|
*
|
|
123
175
|
* doesntContain('Minion', 'ni'); -> false
|
|
@@ -128,6 +180,10 @@ export declare function doesntContain(haystack: string, needles: string | Iterab
|
|
|
128
180
|
/**
|
|
129
181
|
* Replace consecutive instances of a given character with a single character in the given string.
|
|
130
182
|
*
|
|
183
|
+
* @param value - The string to process
|
|
184
|
+
* @param character - The character or characters to deduplicate
|
|
185
|
+
* @returns The string with consecutive instances of the character(s) replaced by a single instance
|
|
186
|
+
*
|
|
131
187
|
* @example
|
|
132
188
|
*
|
|
133
189
|
* deduplicate('hello world'); -> 'hello world'
|
|
@@ -139,6 +195,10 @@ export declare function deduplicate(value: string, character?: string | string[]
|
|
|
139
195
|
/**
|
|
140
196
|
* Determine if a given string ends with a given substring.
|
|
141
197
|
*
|
|
198
|
+
* @param haystack - The string to search in
|
|
199
|
+
* @param needles - The substring or substrings to search for
|
|
200
|
+
* @returns True if the string ends with any of the substrings, false otherwise
|
|
201
|
+
*
|
|
142
202
|
* @example
|
|
143
203
|
*
|
|
144
204
|
* endsWith("Jason", "on"); -> true
|
|
@@ -148,6 +208,10 @@ export declare function endsWith(haystack: string | number | null, needles: stri
|
|
|
148
208
|
/**
|
|
149
209
|
* Determine if a given string doesn't end with a given substring.
|
|
150
210
|
*
|
|
211
|
+
* @param haystack - The string to search in
|
|
212
|
+
* @param needles - The substring or substrings to search for
|
|
213
|
+
* @returns True if the string does not end with any of the substrings, false otherwise
|
|
214
|
+
*
|
|
151
215
|
* @example
|
|
152
216
|
*
|
|
153
217
|
* doesntEndWith("Jason", "on"); -> false
|
|
@@ -157,6 +221,10 @@ export declare function doesntEndWith(haystack: string | number | null, needles:
|
|
|
157
221
|
/**
|
|
158
222
|
* Cap a string with a single instance of a given value.
|
|
159
223
|
*
|
|
224
|
+
* @param value - The string to cap
|
|
225
|
+
* @param cap - The string to cap with
|
|
226
|
+
* @returns The capped string
|
|
227
|
+
*
|
|
160
228
|
* @example
|
|
161
229
|
*
|
|
162
230
|
* finish('hello', '!'); -> 'hello!'
|
|
@@ -165,6 +233,11 @@ export declare function finish(value: string, cap: string): string;
|
|
|
165
233
|
/**
|
|
166
234
|
* Wrap the string with the given strings.
|
|
167
235
|
*
|
|
236
|
+
* @param value - The string to wrap
|
|
237
|
+
* @param before - The string to prepend
|
|
238
|
+
* @param after - The string to append (if null, use the 'before' string)
|
|
239
|
+
* @returns The wrapped string
|
|
240
|
+
*
|
|
168
241
|
* @example
|
|
169
242
|
*
|
|
170
243
|
* wrap('hello', '[', ']'); -> '[hello]'
|
|
@@ -173,6 +246,11 @@ export declare function wrap(value: string, before: string, after?: string | nul
|
|
|
173
246
|
/**
|
|
174
247
|
* Unwrap the string with the given strings.
|
|
175
248
|
*
|
|
249
|
+
* @param value - The string to unwrap
|
|
250
|
+
* @param before - The string to remove from the start
|
|
251
|
+
* @param after - The string to remove from the end (if null, use the 'before' string)
|
|
252
|
+
* @returns The unwrapped string
|
|
253
|
+
*
|
|
176
254
|
* @example
|
|
177
255
|
*
|
|
178
256
|
* unwrap('[hello]', '[', ']'); -> 'hello'
|
|
@@ -181,6 +259,11 @@ export declare function unwrap(value: string, before: string, after?: string | n
|
|
|
181
259
|
/**
|
|
182
260
|
* Determine if a given string matches a given pattern.
|
|
183
261
|
*
|
|
262
|
+
* @param pattern - The pattern or patterns to match against
|
|
263
|
+
* @param value - The string or number to check
|
|
264
|
+
* @param ignoreCase - Whether to ignore case when matching
|
|
265
|
+
* @return True if the string matches the pattern, false otherwise
|
|
266
|
+
*
|
|
184
267
|
* @example
|
|
185
268
|
*
|
|
186
269
|
* is('hello', 'hello'); -> true
|
|
@@ -191,6 +274,9 @@ export declare function is(pattern: string | Iterable<string>, value: string | n
|
|
|
191
274
|
/**
|
|
192
275
|
* Determine if a given string is 7 bit ASCII.
|
|
193
276
|
*
|
|
277
|
+
* @param value - The string to check
|
|
278
|
+
* @returns True if the string is ASCII, false otherwise
|
|
279
|
+
*
|
|
194
280
|
* @example
|
|
195
281
|
*
|
|
196
282
|
* isAscii("Hello World"); -> true
|
|
@@ -203,6 +289,9 @@ export declare function isAscii(value: string): boolean;
|
|
|
203
289
|
/**
|
|
204
290
|
* Determine if a given value is valid JSON.
|
|
205
291
|
*
|
|
292
|
+
* @param value - The value to check if it's JSON
|
|
293
|
+
* @returns True if the value is valid JSON, false otherwise
|
|
294
|
+
*
|
|
206
295
|
* @example
|
|
207
296
|
*
|
|
208
297
|
* isJson('{"name": "John", "age": 30}'); -> true
|
|
@@ -215,6 +304,7 @@ export declare function isJson(value: unknown): boolean;
|
|
|
215
304
|
*
|
|
216
305
|
* @param value - The value to check if it's URL
|
|
217
306
|
* @param protocols - An optional array of allowed protocols (e.g., ['http', 'https'])
|
|
307
|
+
* @return True if the value is a valid URL, false otherwise
|
|
218
308
|
*
|
|
219
309
|
* @example
|
|
220
310
|
*
|
|
@@ -223,17 +313,12 @@ export declare function isJson(value: unknown): boolean;
|
|
|
223
313
|
* isUrl('invalid url'); -> false
|
|
224
314
|
*/
|
|
225
315
|
export declare function isUrl(value: string | unknown, protocols?: string[]): boolean;
|
|
226
|
-
/**
|
|
227
|
-
* Determine if a given value is a valid ULID.
|
|
228
|
-
*
|
|
229
|
-
* @example
|
|
230
|
-
*
|
|
231
|
-
* isUlid("01F8MECHZX2D7J8F8C8D4B8F8C"); -> true
|
|
232
|
-
*/
|
|
233
|
-
export declare function isUlid(value: unknown): boolean;
|
|
234
316
|
/**
|
|
235
317
|
* Convert a string to kebab case.
|
|
236
318
|
*
|
|
319
|
+
* @param value - The string to convert
|
|
320
|
+
* @returns The kebab-cased string
|
|
321
|
+
*
|
|
237
322
|
* @example
|
|
238
323
|
*
|
|
239
324
|
* kebab("Laravel PHP Framework"); -> "laravel-php-framework"
|
|
@@ -242,6 +327,9 @@ export declare function kebab(value: string): string;
|
|
|
242
327
|
/**
|
|
243
328
|
* Return the length of the given string.
|
|
244
329
|
*
|
|
330
|
+
* @param value - The string to measure
|
|
331
|
+
* @returns The length of the string
|
|
332
|
+
*
|
|
245
333
|
* @example
|
|
246
334
|
*
|
|
247
335
|
* length("Hello World"); -> 11
|
|
@@ -250,16 +338,19 @@ export declare function length(value: string): number;
|
|
|
250
338
|
/**
|
|
251
339
|
* Limit the number of characters in a string.
|
|
252
340
|
*
|
|
253
|
-
* @param
|
|
254
|
-
* @param
|
|
255
|
-
* @param
|
|
256
|
-
* @param
|
|
257
|
-
* @
|
|
341
|
+
* @param value - The string to limit
|
|
342
|
+
* @param limit - The maximum number of characters
|
|
343
|
+
* @param end - The string to append if the value is truncated
|
|
344
|
+
* @param preserveWords - Whether to preserve whole words when truncating
|
|
345
|
+
* @returns The limited string
|
|
258
346
|
*/
|
|
259
347
|
export declare function limit(value: string, limit?: number, end?: string, preserveWords?: boolean): string;
|
|
260
348
|
/**
|
|
261
349
|
* Convert the given string to lower-case.
|
|
262
350
|
*
|
|
351
|
+
* @param value - The string to convert
|
|
352
|
+
* @returns The lower-cased string
|
|
353
|
+
*
|
|
263
354
|
* @example
|
|
264
355
|
*
|
|
265
356
|
* lower("Hello World"); -> "hello world"
|
|
@@ -268,6 +359,11 @@ export declare function lower(value: string): string;
|
|
|
268
359
|
/**
|
|
269
360
|
* Limit the number of words in a string.
|
|
270
361
|
*
|
|
362
|
+
* @param value - The string to limit
|
|
363
|
+
* @param words - The maximum number of words
|
|
364
|
+
* @param end - The string to append if the value is truncated
|
|
365
|
+
* @returns The limited string
|
|
366
|
+
*
|
|
271
367
|
* @example
|
|
272
368
|
*
|
|
273
369
|
* words("Laravel PHP Framework", 2); -> "Laravel PHP Framework"
|
|
@@ -277,6 +373,12 @@ export declare function words(value: string, words?: number, end?: string): stri
|
|
|
277
373
|
/**
|
|
278
374
|
* Masks a portion of a string with a repeated character.
|
|
279
375
|
*
|
|
376
|
+
* @param value - The string to mask
|
|
377
|
+
* @param character - The character to use for masking
|
|
378
|
+
* @param index - The starting index to begin masking (can be negative)
|
|
379
|
+
* @param length - The number of characters to mask (if null, mask to the end of the string)
|
|
380
|
+
* @returns The masked string
|
|
381
|
+
*
|
|
280
382
|
* @example
|
|
281
383
|
*
|
|
282
384
|
* mask("taylor@email.com", "*", 3); -> "tay*************"
|
|
@@ -288,14 +390,18 @@ export declare function mask(value: string, character: string, index: number, le
|
|
|
288
390
|
/**
|
|
289
391
|
* Get the string matching the given pattern.
|
|
290
392
|
*
|
|
291
|
-
* @param
|
|
292
|
-
* @param
|
|
293
|
-
* @
|
|
393
|
+
* @param pattern - The regex pattern to match
|
|
394
|
+
* @param subject - The string to search within
|
|
395
|
+
* @returns The matched string or an empty string if no match
|
|
294
396
|
*/
|
|
295
397
|
export declare function match(pattern: string, subject: string): string;
|
|
296
398
|
/**
|
|
297
399
|
* Determine if a given string matches a given pattern.
|
|
298
400
|
*
|
|
401
|
+
* @param pattern - The pattern or patterns to match against
|
|
402
|
+
* @param value - The string to check
|
|
403
|
+
* @return True if the string matches the pattern, false otherwise
|
|
404
|
+
*
|
|
299
405
|
* @example
|
|
300
406
|
*
|
|
301
407
|
* Str::isMatch('/foo/', 'foo bar'); // true
|
|
@@ -305,6 +411,10 @@ export declare function isMatch(pattern: string | Iterable<string>, value: strin
|
|
|
305
411
|
/**
|
|
306
412
|
* Get the string matching the given pattern.
|
|
307
413
|
*
|
|
414
|
+
* @param pattern - The regex pattern to match
|
|
415
|
+
* @param subject - The string to search within
|
|
416
|
+
* @returns An array of all matched strings
|
|
417
|
+
*
|
|
308
418
|
* @example
|
|
309
419
|
*
|
|
310
420
|
* matchAll("/foo (.*)/", "foo bar baz"); -> ["foo bar baz"]
|
|
@@ -313,6 +423,9 @@ export declare function matchAll(pattern: string, subject: string): string[];
|
|
|
313
423
|
/**
|
|
314
424
|
* Remove all non-numeric characters from a string.
|
|
315
425
|
*
|
|
426
|
+
* @param value - The string or array of strings to process
|
|
427
|
+
* @returns The numeric-only string or array of strings
|
|
428
|
+
*
|
|
316
429
|
* @example
|
|
317
430
|
*
|
|
318
431
|
* numbers("foo123bar"); -> "123"
|
|
@@ -322,15 +435,20 @@ export declare function numbers(value: string | string[]): string | string[];
|
|
|
322
435
|
/**
|
|
323
436
|
* Pad both sides of a string with another.
|
|
324
437
|
*
|
|
325
|
-
* @param
|
|
326
|
-
* @param
|
|
327
|
-
* @param
|
|
328
|
-
* @
|
|
438
|
+
* @param value - The string to pad
|
|
439
|
+
* @param length - The desired total length after padding
|
|
440
|
+
* @param pad - The string to use for padding
|
|
441
|
+
* @returns The padded string
|
|
329
442
|
*/
|
|
330
443
|
export declare function padBoth(value: string, length: number, pad?: string): string;
|
|
331
444
|
/**
|
|
332
445
|
* Pad the left side of a string with another.
|
|
333
446
|
*
|
|
447
|
+
* @param value - The string to pad
|
|
448
|
+
* @param length - The desired total length after padding
|
|
449
|
+
* @param pad - The string to use for padding
|
|
450
|
+
* @returns The padded string
|
|
451
|
+
*
|
|
334
452
|
* @example
|
|
335
453
|
*
|
|
336
454
|
* padLeft("Alien", 10, "-="); -> "-=-=-Alien"
|
|
@@ -342,6 +460,11 @@ export declare function padLeft(value: string, length: number, pad?: string): st
|
|
|
342
460
|
/**
|
|
343
461
|
* Pad the right side of a string with another.
|
|
344
462
|
*
|
|
463
|
+
* @param value - The string to pad
|
|
464
|
+
* @param length - The desired total length after padding
|
|
465
|
+
* @param pad - The string to use for padding
|
|
466
|
+
* @returns The padded string
|
|
467
|
+
*
|
|
345
468
|
* @example
|
|
346
469
|
*
|
|
347
470
|
* padRight("Alien", 10, "-="); -> "Alien-=-="
|
|
@@ -353,6 +476,10 @@ export declare function padRight(value: string, length: number, pad?: string): s
|
|
|
353
476
|
/**
|
|
354
477
|
* Create a padding string.
|
|
355
478
|
*
|
|
479
|
+
* @param padStr - The string to use for padding
|
|
480
|
+
* @param needed - The total length of padding needed
|
|
481
|
+
* @returns The generated padding string
|
|
482
|
+
*
|
|
356
483
|
* @example
|
|
357
484
|
*
|
|
358
485
|
* makePad(" ", 5); -> " "
|
|
@@ -360,22 +487,6 @@ export declare function padRight(value: string, length: number, pad?: string): s
|
|
|
360
487
|
* makePad("❤", 5); -> "❤❤❤❤❤"
|
|
361
488
|
*/
|
|
362
489
|
export declare function makePad(padStr: string, needed: number): string;
|
|
363
|
-
/**
|
|
364
|
-
* Pluralize the last word of an English, studly caps case string.
|
|
365
|
-
*
|
|
366
|
-
* @example
|
|
367
|
-
*
|
|
368
|
-
* pluralStudly("These are the school", 4); -> "These are the schools"
|
|
369
|
-
*/
|
|
370
|
-
export declare function pluralStudly(value: string, count?: number): string;
|
|
371
|
-
/**
|
|
372
|
-
* Pluralize the last word of an English, Pascal caps case string.
|
|
373
|
-
*
|
|
374
|
-
* @example
|
|
375
|
-
*
|
|
376
|
-
* pluralPascal("These are the school", 4); -> "These are the schools"
|
|
377
|
-
*/
|
|
378
|
-
export declare function pluralPascal(value: string, count?: number): string;
|
|
379
490
|
/**
|
|
380
491
|
* Generate a random, secure password.
|
|
381
492
|
*
|
|
@@ -395,6 +506,11 @@ export declare function password(length?: number, letters?: boolean, numbers?: b
|
|
|
395
506
|
/**
|
|
396
507
|
* Find the multi-byte safe position of the first occurrence of a given substring in a string.
|
|
397
508
|
*
|
|
509
|
+
* @param haystack - The string to search within
|
|
510
|
+
* @param needle - The substring to search for
|
|
511
|
+
* @param offset - The position to start searching from (can be negative)
|
|
512
|
+
* @returns The position of the first occurrence or false if not found
|
|
513
|
+
*
|
|
398
514
|
* @example
|
|
399
515
|
*
|
|
400
516
|
* position('Hello, World!', 'World!'); -> 7
|
|
@@ -404,6 +520,9 @@ export declare function position(haystack: string, needle: string, offset?: numb
|
|
|
404
520
|
/**
|
|
405
521
|
* Generate a more truly "random" alpha-numeric string.
|
|
406
522
|
*
|
|
523
|
+
* @param length - The desired length of the random string (default: 16)
|
|
524
|
+
* @returns The generated random string
|
|
525
|
+
*
|
|
407
526
|
* @example
|
|
408
527
|
*
|
|
409
528
|
* random(); -> "a1b2c3d4e5f6g7h8"
|
|
@@ -412,6 +531,9 @@ export declare function random(length?: number): string;
|
|
|
412
531
|
/**
|
|
413
532
|
* Set the callable that will be used to generate random strings.
|
|
414
533
|
*
|
|
534
|
+
* @param factory - The factory function to generate random strings
|
|
535
|
+
* @returns void
|
|
536
|
+
*
|
|
415
537
|
* @example
|
|
416
538
|
*
|
|
417
539
|
* createRandomStringsUsing((length) => "x".repeat(length));
|
|
@@ -420,6 +542,10 @@ export declare function createRandomStringsUsing(factory: ((length: number) => s
|
|
|
420
542
|
/**
|
|
421
543
|
* Set the sequence that will be used to generate random strings.
|
|
422
544
|
*
|
|
545
|
+
* @param sequence - An array of strings to use in sequence
|
|
546
|
+
* @param whenMissing - An optional callable to generate strings when the sequence is exhausted
|
|
547
|
+
* @returns void
|
|
548
|
+
*
|
|
423
549
|
* @example
|
|
424
550
|
*
|
|
425
551
|
* createRandomStringsUsingSequence(['a', 'b', 'c']);
|
|
@@ -429,6 +555,8 @@ export declare function createRandomStringsUsingSequence(sequence: string[], whe
|
|
|
429
555
|
/**
|
|
430
556
|
* Indicate that random strings should be created normally and not using a custom factory.
|
|
431
557
|
*
|
|
558
|
+
* @returns void
|
|
559
|
+
*
|
|
432
560
|
* @example
|
|
433
561
|
*
|
|
434
562
|
* createRandomStringsNormally();
|
|
@@ -437,6 +565,10 @@ export declare function createRandomStringsNormally(): void;
|
|
|
437
565
|
/**
|
|
438
566
|
* Repeat the given string.
|
|
439
567
|
*
|
|
568
|
+
* @param string - The string to repeat
|
|
569
|
+
* @param times - The number of times to repeat the string
|
|
570
|
+
* @returns The repeated string
|
|
571
|
+
*
|
|
440
572
|
* @example
|
|
441
573
|
*
|
|
442
574
|
* repeat("foo", 3); -> "foofoofoo"
|
|
@@ -445,6 +577,11 @@ export declare function repeat(string: string, times: number): string;
|
|
|
445
577
|
/**
|
|
446
578
|
* Replace a given value in the string sequentially with an array.
|
|
447
579
|
*
|
|
580
|
+
* @param search - The value to search for
|
|
581
|
+
* @param replace - The array or record of replacements
|
|
582
|
+
* @param subject - The string to perform replacements on
|
|
583
|
+
* @returns The resulting string after replacements
|
|
584
|
+
*
|
|
448
585
|
* @example
|
|
449
586
|
*
|
|
450
587
|
* replaceArray('?', ['foo', 'bar', 'baz'], '?/?/?'); -> 'foo/bar/baz'
|
|
@@ -455,6 +592,10 @@ export declare function replaceArray(search: string, replace: Record<string, str
|
|
|
455
592
|
/**
|
|
456
593
|
* Convert the given value to a string or return the given fallback on failure.
|
|
457
594
|
*
|
|
595
|
+
* @param value - The value to convert
|
|
596
|
+
* @param fallback - The fallback string to return on failure
|
|
597
|
+
* @returns The converted string or the fallback
|
|
598
|
+
*
|
|
458
599
|
* @example
|
|
459
600
|
*
|
|
460
601
|
* toStringOr(123);
|
|
@@ -463,6 +604,12 @@ export declare function toStringOr(value: unknown, fallback: string): string;
|
|
|
463
604
|
/**
|
|
464
605
|
* Replace the given value in the given string.
|
|
465
606
|
*
|
|
607
|
+
* @param search - The value or values to search for
|
|
608
|
+
* @param replacement - The value or values to replace with
|
|
609
|
+
* @param subject - The string or array of strings to perform replacements on
|
|
610
|
+
* @param caseSensitive - Whether the search should be case-sensitive (default: true)
|
|
611
|
+
* @returns The resulting string or array of strings after replacements
|
|
612
|
+
*
|
|
466
613
|
* @example
|
|
467
614
|
*
|
|
468
615
|
* replace("foo", "bar", "foo baz"); -> "bar baz"
|
|
@@ -471,6 +618,11 @@ export declare function replace<T extends string | Iterable<string>>(search: str
|
|
|
471
618
|
/**
|
|
472
619
|
* Replace the first occurrence of a given value in the string.
|
|
473
620
|
*
|
|
621
|
+
* @param search - The value to search for
|
|
622
|
+
* @param replace - The value to replace with
|
|
623
|
+
* @param subject - The string to perform the replacement on
|
|
624
|
+
* @returns The resulting string after replacement
|
|
625
|
+
*
|
|
474
626
|
* @example
|
|
475
627
|
*
|
|
476
628
|
* replaceFirst('bar', 'qux', 'foobar foobar'); -> 'fooqux foobar'
|
|
@@ -479,15 +631,20 @@ export declare function replaceFirst(search: string | number, replace: string, s
|
|
|
479
631
|
/**
|
|
480
632
|
* Replace the first occurrence of the given value if it appears at the start of the string.
|
|
481
633
|
*
|
|
482
|
-
* @param
|
|
483
|
-
* @param
|
|
484
|
-
* @param
|
|
485
|
-
* @
|
|
634
|
+
* @param search - The value to search for
|
|
635
|
+
* @param replace - The value to replace with
|
|
636
|
+
* @param subject - The string to perform the replacement on
|
|
637
|
+
* @returns The resulting string after replacement
|
|
486
638
|
*/
|
|
487
639
|
export declare function replaceStart(search: string | number, replace: string, subject: string): string;
|
|
488
640
|
/**
|
|
489
641
|
* Replace the last occurrence of a given value in the string.
|
|
490
642
|
*
|
|
643
|
+
* @param search - The value to search for
|
|
644
|
+
* @param replace - The value to replace with
|
|
645
|
+
* @param subject - The string to perform the replacement on
|
|
646
|
+
* @returns The resulting string after replacement
|
|
647
|
+
*
|
|
491
648
|
* @example
|
|
492
649
|
*
|
|
493
650
|
* replaceLast('bar', 'qux', 'foobar foobar'); -> 'foobar foobarqux'
|
|
@@ -496,6 +653,11 @@ export declare function replaceLast(search: string | number, replace: string, su
|
|
|
496
653
|
/**
|
|
497
654
|
* Replace the last occurrence of a given value if it appears at the end of the string.
|
|
498
655
|
*
|
|
656
|
+
* @param search - The value to search for
|
|
657
|
+
* @param replace - The value to replace with
|
|
658
|
+
* @param subject - The string to perform the replacement on
|
|
659
|
+
* @returns The resulting string after replacement
|
|
660
|
+
*
|
|
499
661
|
* @example
|
|
500
662
|
*
|
|
501
663
|
* replaceEnd('bar', 'qux', 'foobar foobar'); -> 'foobar fooqux'
|
|
@@ -504,6 +666,12 @@ export declare function replaceEnd(search: string | number, replace: string, sub
|
|
|
504
666
|
/**
|
|
505
667
|
* Replace the patterns matching the given regular expression.
|
|
506
668
|
*
|
|
669
|
+
* @param pattern - The regex pattern or patterns to search for
|
|
670
|
+
* @param replace - The replacement string, array of strings, or function
|
|
671
|
+
* @param subject - The string or array of strings to perform replacements on
|
|
672
|
+
* @param limit - The maximum number of replacements per pattern (-1 for no limit)
|
|
673
|
+
* @returns The resulting string, array of strings, or null on error
|
|
674
|
+
*
|
|
507
675
|
* @example
|
|
508
676
|
*
|
|
509
677
|
* replaceMatches(/foo/, 'bar', 'foobar'); -> 'barbar'
|
|
@@ -514,6 +682,9 @@ export declare function replaceMatches(pattern: string | string[] | RegExp | Reg
|
|
|
514
682
|
/**
|
|
515
683
|
* Strip HTML tags from a string.
|
|
516
684
|
*
|
|
685
|
+
* @param value - The string to process
|
|
686
|
+
* @returns The string with HTML tags removed
|
|
687
|
+
*
|
|
517
688
|
* @example
|
|
518
689
|
*
|
|
519
690
|
* stripTags("<p>Hello World</p>"); -> "Hello World"
|
|
@@ -522,6 +693,11 @@ export declare function stripTags(value: string): string;
|
|
|
522
693
|
/**
|
|
523
694
|
* Remove any occurrence of the given string in the subject.
|
|
524
695
|
*
|
|
696
|
+
* @param search - The string or strings to remove
|
|
697
|
+
* @param subject - The string or strings to process
|
|
698
|
+
* @param caseSensitive - Whether the search should be case-sensitive (default: true)
|
|
699
|
+
* @returns The resulting string or array of strings after removal
|
|
700
|
+
*
|
|
525
701
|
* @example
|
|
526
702
|
*
|
|
527
703
|
* remove("foo", "foobar"); -> "bar"
|
|
@@ -531,6 +707,9 @@ export declare function remove(search: string | Iterable<string>, subject: strin
|
|
|
531
707
|
/**
|
|
532
708
|
* Reverse the given string.
|
|
533
709
|
*
|
|
710
|
+
* @param value - The string to reverse
|
|
711
|
+
* @returns The reversed string
|
|
712
|
+
*
|
|
534
713
|
* @example
|
|
535
714
|
*
|
|
536
715
|
* reverse("hello"); -> "olleh"
|
|
@@ -541,6 +720,10 @@ export declare function reverse(value: string): string;
|
|
|
541
720
|
/**
|
|
542
721
|
* Begin a string with a single instance of a given value.
|
|
543
722
|
*
|
|
723
|
+
* @param value - The string to process
|
|
724
|
+
* @param prefix - The prefix to ensure at the start
|
|
725
|
+
* @returns The resulting string starting with the prefix
|
|
726
|
+
*
|
|
544
727
|
* @example
|
|
545
728
|
*
|
|
546
729
|
* start("test/string", "/"); -> "/test/string"
|
|
@@ -551,6 +734,9 @@ export declare function start(value: string, prefix: string): string;
|
|
|
551
734
|
/**
|
|
552
735
|
* Convert the given string to proper case for each word.
|
|
553
736
|
*
|
|
737
|
+
* @param value - The string to convert
|
|
738
|
+
* @returns The converted string in headline case
|
|
739
|
+
*
|
|
554
740
|
* @example
|
|
555
741
|
*
|
|
556
742
|
* headline("foo bar baz"); -> "Foo Bar Baz"
|
|
@@ -560,7 +746,10 @@ export declare function headline(value: string): string;
|
|
|
560
746
|
/**
|
|
561
747
|
* Convert the given string to APA-style title case.
|
|
562
748
|
*
|
|
563
|
-
*
|
|
749
|
+
* @param value - The string to convert
|
|
750
|
+
* @returns The converted string in APA title case
|
|
751
|
+
*
|
|
752
|
+
* @see https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case
|
|
564
753
|
*
|
|
565
754
|
* @example
|
|
566
755
|
*
|
|
@@ -568,37 +757,35 @@ export declare function headline(value: string): string;
|
|
|
568
757
|
* apa("foO bAr BaZ"); -> "Foo Bar Baz"
|
|
569
758
|
*/
|
|
570
759
|
export declare function apa(value: string): string;
|
|
571
|
-
/**
|
|
572
|
-
* Generate a URL friendly "slug" from a given string.
|
|
573
|
-
*
|
|
574
|
-
* @param string $title
|
|
575
|
-
* @param string $separator
|
|
576
|
-
* @param array<string, string> $dictionary
|
|
577
|
-
* @return string
|
|
578
|
-
*/
|
|
579
|
-
export declare function slug(title: string, separator?: string, dictionary?: Record<string, string>): string;
|
|
580
760
|
/**
|
|
581
761
|
* Convert a string to snake case.
|
|
582
762
|
*
|
|
583
|
-
* @param
|
|
584
|
-
* @param
|
|
585
|
-
* @
|
|
763
|
+
* @param value - The string to convert
|
|
764
|
+
* @param delimiter - The word delimiter to use (default: "_")
|
|
765
|
+
* @returns The converted string in snake case
|
|
586
766
|
*/
|
|
587
767
|
export declare function snake(value: string, delimiter?: string): string;
|
|
588
768
|
/**
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
769
|
+
* Remove all "extra" blank space from the given string.
|
|
770
|
+
*
|
|
771
|
+
* @param value - The string to process
|
|
772
|
+
* @returns The resulting string with extra spaces removed
|
|
773
|
+
*
|
|
774
|
+
* @example
|
|
775
|
+
*
|
|
776
|
+
* squish(`
|
|
777
|
+
foo
|
|
778
|
+
bar
|
|
779
|
+
`); -> "foo bar"
|
|
780
|
+
*/
|
|
598
781
|
export declare function squish(value: string): string;
|
|
599
782
|
/**
|
|
600
783
|
* Determine if a given string starts with a given substring.
|
|
601
784
|
*
|
|
785
|
+
* @param haystack - The string to search in
|
|
786
|
+
* @param needles - The substring or substrings to search for
|
|
787
|
+
* @returns True if the haystack starts with any of the needles, false otherwise
|
|
788
|
+
*
|
|
602
789
|
* @example
|
|
603
790
|
*
|
|
604
791
|
* startsWith("hello world", "hello"); -> true
|
|
@@ -608,6 +795,10 @@ export declare function startsWith(haystack: string | number | null, needles: st
|
|
|
608
795
|
/**
|
|
609
796
|
* Determine if a given string doesn't start with a given substring.
|
|
610
797
|
*
|
|
798
|
+
* @param haystack - The string to search in
|
|
799
|
+
* @param needles - The substring or substrings to search for
|
|
800
|
+
* @returns True if the haystack doesn't start with any of the needles, false otherwise
|
|
801
|
+
*
|
|
611
802
|
* @example
|
|
612
803
|
*
|
|
613
804
|
* expect(doesntStartWith("jason", ["day"])).toBe(true);
|
|
@@ -616,6 +807,9 @@ export declare function doesntStartWith(haystack: string | number | null, needle
|
|
|
616
807
|
/**
|
|
617
808
|
* Convert a value to studly caps case.
|
|
618
809
|
*
|
|
810
|
+
* @param value - The string to convert
|
|
811
|
+
* @returns The converted string in studly caps case
|
|
812
|
+
*
|
|
619
813
|
* @example
|
|
620
814
|
*
|
|
621
815
|
* studly("fooBar"); -> "FooBar"
|
|
@@ -626,13 +820,17 @@ export declare function studly(value: string): string;
|
|
|
626
820
|
/**
|
|
627
821
|
* Convert a value to Pascal case.
|
|
628
822
|
*
|
|
629
|
-
* @param
|
|
630
|
-
* @
|
|
823
|
+
* @param value - The string to convert
|
|
824
|
+
* @returns The converted string in Pascal case
|
|
631
825
|
*/
|
|
632
826
|
export declare function pascal(value: string): string;
|
|
633
827
|
/**
|
|
634
828
|
* Swap multiple keywords in a string with other keywords.
|
|
635
829
|
*
|
|
830
|
+
* @param map - The record of replacements
|
|
831
|
+
* @param subject - The string to perform replacements on
|
|
832
|
+
* @returns The resulting string after replacements
|
|
833
|
+
*
|
|
636
834
|
* @example
|
|
637
835
|
*
|
|
638
836
|
* swap(
|
|
@@ -647,6 +845,10 @@ export declare function swap(map: Record<string, string>, subject: string): stri
|
|
|
647
845
|
/**
|
|
648
846
|
* Take the first or last {$limit} characters of a string.
|
|
649
847
|
*
|
|
848
|
+
* @param value - The string to process
|
|
849
|
+
* @param limit - The number of characters to take (negative for from end)
|
|
850
|
+
* @returns The resulting substring
|
|
851
|
+
*
|
|
650
852
|
* @example
|
|
651
853
|
*
|
|
652
854
|
* take("hello world", 5); -> "hello"
|
|
@@ -656,6 +858,9 @@ export declare function take(value: string, limit: number): string;
|
|
|
656
858
|
/**
|
|
657
859
|
* Make a string's first character lowercase.
|
|
658
860
|
*
|
|
861
|
+
* @param value - The string to process
|
|
862
|
+
* @returns The resulting string with the first character in lowercase
|
|
863
|
+
*
|
|
659
864
|
* @example
|
|
660
865
|
*
|
|
661
866
|
* lcfirst('Hello World'); -> 'hello World'
|
|
@@ -664,6 +869,9 @@ export declare function lcfirst(value: string): string;
|
|
|
664
869
|
/**
|
|
665
870
|
* Make a string's first character uppercase.
|
|
666
871
|
*
|
|
872
|
+
* @param value - The string to process
|
|
873
|
+
* @returns The resulting string with the first character in uppercase
|
|
874
|
+
*
|
|
667
875
|
* @example
|
|
668
876
|
*
|
|
669
877
|
* ucfirst('hello world'); -> 'Hello world'
|
|
@@ -672,6 +880,9 @@ export declare function ucfirst(value: string): string;
|
|
|
672
880
|
/**
|
|
673
881
|
* Split a string into pieces by uppercase characters.
|
|
674
882
|
*
|
|
883
|
+
* @param value - The string to split
|
|
884
|
+
* @returns An array of string segments split at uppercase characters
|
|
885
|
+
*
|
|
675
886
|
* @example
|
|
676
887
|
*
|
|
677
888
|
* ucsplit('laravelPHPFramework'); -> ['laravel', 'P', 'H', 'P', 'Framework']
|
|
@@ -682,6 +893,10 @@ export declare function ucsplit(value: string): string[];
|
|
|
682
893
|
/**
|
|
683
894
|
* Uppercase the first letter of each word in a string.
|
|
684
895
|
*
|
|
896
|
+
* @param value - The string to process
|
|
897
|
+
* @param separators - The word separators to use (default: whitespace characters)
|
|
898
|
+
* @returns The resulting string with each word capitalized
|
|
899
|
+
*
|
|
685
900
|
* @example
|
|
686
901
|
*
|
|
687
902
|
* ucwords('hello world'); -> 'Hello World'
|
|
@@ -692,6 +907,10 @@ export declare function ucwords(value: string, separators?: string | string[]):
|
|
|
692
907
|
/**
|
|
693
908
|
* Get the number of words a string contains.
|
|
694
909
|
*
|
|
910
|
+
* @param value - The string to analyze
|
|
911
|
+
* @param characters - Additional characters to consider as part of words
|
|
912
|
+
* @returns The word count in the string
|
|
913
|
+
*
|
|
695
914
|
* @example
|
|
696
915
|
*
|
|
697
916
|
* wordCount('Hello, world!'); -> 2
|
|
@@ -701,6 +920,12 @@ export declare function wordCount(value: string, characters?: string | null): nu
|
|
|
701
920
|
/**
|
|
702
921
|
* Wrap a string to a given number of characters.
|
|
703
922
|
*
|
|
923
|
+
* @param value - The string to wrap
|
|
924
|
+
* @param characters - The maximum number of characters per line (default: 75)
|
|
925
|
+
* @param breakStr - The string to insert as a line break (default: "\n")
|
|
926
|
+
* @param cutLongWords - Whether to cut words longer than the limit (default: false)
|
|
927
|
+
* @returns The resulting wrapped string
|
|
928
|
+
*
|
|
704
929
|
* @example
|
|
705
930
|
*
|
|
706
931
|
* wordWrap("Hello World", 3, "<br />"); -> "Hello<br />World"
|
|
@@ -711,6 +936,8 @@ export declare function wordWrap(value: string, characters?: number, breakStr?:
|
|
|
711
936
|
/**
|
|
712
937
|
* Get the size of the snake cache.
|
|
713
938
|
*
|
|
939
|
+
* @returns The size of the snake cache
|
|
940
|
+
*
|
|
714
941
|
* @example
|
|
715
942
|
*
|
|
716
943
|
* snakeCacheSize();
|
|
@@ -719,6 +946,8 @@ export declare function snakeCacheSize(): number;
|
|
|
719
946
|
/**
|
|
720
947
|
* Get the size of the camel cache.
|
|
721
948
|
*
|
|
949
|
+
* @returns The size of the camel cache
|
|
950
|
+
*
|
|
722
951
|
* @example
|
|
723
952
|
*
|
|
724
953
|
* camelCacheSize();
|
|
@@ -727,6 +956,8 @@ export declare function camelCacheSize(): number;
|
|
|
727
956
|
/**
|
|
728
957
|
* Get the size of the studly cache.
|
|
729
958
|
*
|
|
959
|
+
* @returns The size of the studly cache
|
|
960
|
+
*
|
|
730
961
|
* @example
|
|
731
962
|
*
|
|
732
963
|
* studlyCacheSize();
|
|
@@ -735,7 +966,7 @@ export declare function studlyCacheSize(): number;
|
|
|
735
966
|
/**
|
|
736
967
|
* Remove all strings from the casing caches.
|
|
737
968
|
*
|
|
738
|
-
* @
|
|
969
|
+
* @returns void
|
|
739
970
|
*/
|
|
740
971
|
export declare function flushCache(): void;
|
|
741
|
-
//# sourceMappingURL=
|
|
972
|
+
//# sourceMappingURL=index.d.ts.map
|