string-tuner 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +406 -0
- package/dist/index.d.mts +182 -3
- package/dist/index.d.ts +182 -3
- package/dist/index.js +293 -8
- package/dist/index.mjs +284 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,3 +3,409 @@
|
|
|
3
3
|
|
|
4
4
|
Fine-tune your strings the way you like it. A tool made by a dev for devs.
|
|
5
5
|
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install string-tuner
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## How to Use
|
|
14
|
+
|
|
15
|
+
### Importing
|
|
16
|
+
|
|
17
|
+
You can import the entire library or individual modules based on your needs:
|
|
18
|
+
|
|
19
|
+
#### Import Everything (Recommended)
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import st from 'string-tuner';
|
|
23
|
+
|
|
24
|
+
// Use all modules
|
|
25
|
+
st.transform.camel('hello world');
|
|
26
|
+
st.validate.email('test@example.com');
|
|
27
|
+
st.edit.trim('long string', 5);
|
|
28
|
+
st.clean.html('<p>text</p>');
|
|
29
|
+
st.format.mask('1234567890');
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### Import Individual Modules
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import { transform, validate, edit, clean, format } from 'string-tuner';
|
|
36
|
+
|
|
37
|
+
// Use individual modules directly
|
|
38
|
+
transform.camel('hello world');
|
|
39
|
+
validate.email('test@example.com');
|
|
40
|
+
edit.trim('long string', 5);
|
|
41
|
+
clean.html('<p>text</p>');
|
|
42
|
+
format.mask('1234567890');
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### Destructuring for Cleaner Code
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
import st from 'string-tuner';
|
|
49
|
+
|
|
50
|
+
// Extract only what you need
|
|
51
|
+
const { transform, validate } = st;
|
|
52
|
+
|
|
53
|
+
transform.pascal('my function name');
|
|
54
|
+
validate.url('https://example.com');
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## API Reference
|
|
60
|
+
|
|
61
|
+
### `transform` - String Transformation
|
|
62
|
+
|
|
63
|
+
String transformation utilities for converting strings to different formats and cases.
|
|
64
|
+
|
|
65
|
+
#### `transform.capitalize(str, fullSentence?)`
|
|
66
|
+
Capitalizes a string or sentence.
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
st.transform.capitalize('the guitar strings vibrate beautifully');
|
|
70
|
+
// Input: 'the guitar strings vibrate beautifully'
|
|
71
|
+
// Output: 'The Guitar Strings Vibrate Beautifully'
|
|
72
|
+
|
|
73
|
+
st.transform.capitalize('the guitar strings vibrate beautifully', false);
|
|
74
|
+
// Input: 'the guitar strings vibrate beautifully'
|
|
75
|
+
// Output: 'The guitar strings vibrate beautifully'
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### `transform.camel(str)`
|
|
79
|
+
Converts a string to camelCase.
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
st.transform.camel('acoustic guitar solo');
|
|
83
|
+
// Input: 'acoustic guitar solo'
|
|
84
|
+
// Output: 'acousticGuitarSolo'
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### `transform.snake(str)`
|
|
88
|
+
Converts a string to snake_case.
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
st.transform.snake('Electric Bass Guitar');
|
|
92
|
+
// Input: 'Electric Bass Guitar'
|
|
93
|
+
// Output: 'electric_bass_guitar'
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### `transform.snakeScream(str)`
|
|
97
|
+
Converts a string to SCREAMING_SNAKE_CASE.
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
st.transform.snakeScream('Electric Bass Guitar');
|
|
101
|
+
// Input: 'Electric Bass Guitar'
|
|
102
|
+
// Output: 'ELECTRIC_BASS_GUITAR'
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### `transform.kebab(str)`
|
|
106
|
+
Converts a string to kebab-case.
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
st.transform.kebab('Piano Chord Progression');
|
|
110
|
+
// Input: 'Piano Chord Progression'
|
|
111
|
+
// Output: 'piano-chord-progression'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### `transform.pascal(str)`
|
|
115
|
+
Converts a string to PascalCase.
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
st.transform.pascal('violin concerto in d major');
|
|
119
|
+
// Input: 'violin concerto in d major'
|
|
120
|
+
// Output: 'ViolinConcertoInDMajor'
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### `transform.reverse(str)`
|
|
124
|
+
Reverses a string.
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
st.transform.reverse('melody');
|
|
128
|
+
// Input: 'melody'
|
|
129
|
+
// Output: 'ydomel'
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### `transform.slugify(str)`
|
|
133
|
+
Creates a URL-friendly slug from a string.
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
st.transform.slugify('Jazz & Blues: A Musical Journey!');
|
|
137
|
+
// Input: 'Jazz & Blues: A Musical Journey!'
|
|
138
|
+
// Output: 'jazz-blues-a-musical-journey'
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
### `validate` - String Validation
|
|
144
|
+
|
|
145
|
+
Validation utilities for checking string formats.
|
|
146
|
+
|
|
147
|
+
#### `validate.email(str, customRegex?)`
|
|
148
|
+
Validates if a string is a valid email address.
|
|
149
|
+
|
|
150
|
+
```javascript
|
|
151
|
+
st.validate.email('musician@orchestra.com');
|
|
152
|
+
// Input: 'musician@orchestra.com'
|
|
153
|
+
// Output: true
|
|
154
|
+
|
|
155
|
+
st.validate.email('not-an-email');
|
|
156
|
+
// Input: 'not-an-email'
|
|
157
|
+
// Output: false
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### `validate.url(str, customRegex?)`
|
|
161
|
+
Validates if a string is a valid URL.
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
st.validate.url('https://guitar-lessons.com');
|
|
165
|
+
// Input: 'https://guitar-lessons.com'
|
|
166
|
+
// Output: true
|
|
167
|
+
|
|
168
|
+
st.validate.url('not a url');
|
|
169
|
+
// Input: 'not a url'
|
|
170
|
+
// Output: false
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### `validate.phone(str, customRegex?)`
|
|
174
|
+
Validates if a string is a valid phone number.
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
st.validate.phone('+1-555-MUSIC-01');
|
|
178
|
+
// Input: '+1-555-MUSIC-01'
|
|
179
|
+
// Output: true
|
|
180
|
+
|
|
181
|
+
st.validate.phone('call me maybe');
|
|
182
|
+
// Input: 'call me maybe'
|
|
183
|
+
// Output: false
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
### `edit` - String Manipulation
|
|
189
|
+
|
|
190
|
+
String editing utilities for modifying and manipulating strings.
|
|
191
|
+
|
|
192
|
+
#### `edit.trim(str, maxLength?, trimChar?)`
|
|
193
|
+
Trims a string to a maximum length and appends a trim character.
|
|
194
|
+
|
|
195
|
+
```javascript
|
|
196
|
+
st.edit.trim('The symphony orchestra performs tonight', 12);
|
|
197
|
+
// Input: 'The symphony orchestra performs tonight'
|
|
198
|
+
// Output: 'The symphony...'
|
|
199
|
+
|
|
200
|
+
st.edit.trim('The symphony orchestra performs tonight', 12, '♪');
|
|
201
|
+
// Input: 'The symphony orchestra performs tonight'
|
|
202
|
+
// Output: 'The symphony♪'
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### `edit.repeat(str, count)`
|
|
206
|
+
Repeats a string n times.
|
|
207
|
+
|
|
208
|
+
```javascript
|
|
209
|
+
st.edit.repeat('♪ ', 5);
|
|
210
|
+
// Input: '♪ '
|
|
211
|
+
// Output: '♪ ♪ ♪ ♪ ♪ '
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### `edit.pad(str, length, char?, position?)`
|
|
215
|
+
Pads a string to a specified length with a character.
|
|
216
|
+
|
|
217
|
+
```javascript
|
|
218
|
+
st.edit.pad('DRUMS', 15, '-', 'both');
|
|
219
|
+
// Input: 'DRUMS'
|
|
220
|
+
// Output: '-----DRUMS-----'
|
|
221
|
+
|
|
222
|
+
st.edit.pad('BASS', 10, '*', 'start');
|
|
223
|
+
// Input: 'BASS'
|
|
224
|
+
// Output: '******BASS'
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
#### `edit.wrap(str, wrapper)`
|
|
228
|
+
Wraps a string with specified characters.
|
|
229
|
+
|
|
230
|
+
```javascript
|
|
231
|
+
st.edit.wrap('piano forte', '"');
|
|
232
|
+
// Input: 'piano forte'
|
|
233
|
+
// Output: '"piano forte"'
|
|
234
|
+
|
|
235
|
+
st.edit.wrap('crescendo', { start: '[', end: ']' });
|
|
236
|
+
// Input: 'crescendo'
|
|
237
|
+
// Output: '[crescendo]'
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
#### `edit.unwrap(str, wrapper)`
|
|
241
|
+
Removes wrapping characters from a string.
|
|
242
|
+
|
|
243
|
+
```javascript
|
|
244
|
+
st.edit.unwrap('"allegro"', '"');
|
|
245
|
+
// Input: '"allegro"'
|
|
246
|
+
// Output: 'allegro'
|
|
247
|
+
|
|
248
|
+
st.edit.unwrap('[diminuendo]', { start: '[', end: ']' });
|
|
249
|
+
// Input: '[diminuendo]'
|
|
250
|
+
// Output: 'diminuendo'
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### `edit.prefix(pf)`
|
|
254
|
+
Creates prefix manipulation utilities for a given prefix string.
|
|
255
|
+
|
|
256
|
+
```javascript
|
|
257
|
+
const sharp = st.edit.prefix('#');
|
|
258
|
+
sharp.add('C');
|
|
259
|
+
// Input: 'C'
|
|
260
|
+
// Output: '#C'
|
|
261
|
+
|
|
262
|
+
sharp.remove('#F');
|
|
263
|
+
// Input: '#F'
|
|
264
|
+
// Output: 'F'
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
#### `edit.suffix(sf)`
|
|
268
|
+
Creates suffix manipulation utilities for a given suffix string.
|
|
269
|
+
|
|
270
|
+
```javascript
|
|
271
|
+
const major = st.edit.suffix(' major');
|
|
272
|
+
major.add('C');
|
|
273
|
+
// Input: 'C'
|
|
274
|
+
// Output: 'C major'
|
|
275
|
+
|
|
276
|
+
major.remove('D major');
|
|
277
|
+
// Input: 'D major'
|
|
278
|
+
// Output: 'D'
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
#### `edit.initials(str, maxInitials?)`
|
|
282
|
+
Extracts initials from a name or string.
|
|
283
|
+
|
|
284
|
+
```javascript
|
|
285
|
+
st.edit.initials('Ludwig van Beethoven');
|
|
286
|
+
// Input: 'Ludwig van Beethoven'
|
|
287
|
+
// Output: 'LVB'
|
|
288
|
+
|
|
289
|
+
st.edit.initials('Wolfgang Amadeus Mozart', 2);
|
|
290
|
+
// Input: 'Wolfgang Amadeus Mozart'
|
|
291
|
+
// Output: 'WA'
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
### `clean` - String Cleaning
|
|
297
|
+
|
|
298
|
+
String cleaning utilities for removing or normalizing content.
|
|
299
|
+
|
|
300
|
+
#### `clean.whitespace(str)`
|
|
301
|
+
Removes all whitespace from a string.
|
|
302
|
+
|
|
303
|
+
```javascript
|
|
304
|
+
st.clean.whitespace('C D E F G A B');
|
|
305
|
+
// Input: 'C D E F G A B'
|
|
306
|
+
// Output: 'CDEFGAB'
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
#### `clean.normalizeWhitespace(str)`
|
|
310
|
+
Normalizes whitespace by collapsing multiple spaces to single space and trimming.
|
|
311
|
+
|
|
312
|
+
```javascript
|
|
313
|
+
st.clean.normalizeWhitespace(' quarter note rest ');
|
|
314
|
+
// Input: ' quarter note rest '
|
|
315
|
+
// Output: 'quarter note rest'
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
#### `clean.html(str)`
|
|
319
|
+
Removes HTML tags from a string.
|
|
320
|
+
|
|
321
|
+
```javascript
|
|
322
|
+
st.clean.html('<h1>Jazz</h1> <p>is <strong>amazing</strong></p>');
|
|
323
|
+
// Input: '<h1>Jazz</h1> <p>is <strong>amazing</strong></p>'
|
|
324
|
+
// Output: 'Jazz is amazing'
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
#### `clean.escapeHtml(str)`
|
|
328
|
+
Escapes HTML special characters.
|
|
329
|
+
|
|
330
|
+
```javascript
|
|
331
|
+
st.clean.escapeHtml('<chord>C & G</chord>');
|
|
332
|
+
// Input: '<chord>C & G</chord>'
|
|
333
|
+
// Output: '<chord>C & G</chord>'
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
#### `clean.unescapeHtml(str)`
|
|
337
|
+
Unescapes HTML entities.
|
|
338
|
+
|
|
339
|
+
```javascript
|
|
340
|
+
st.clean.unescapeHtml('<note>A</note>');
|
|
341
|
+
// Input: '<note>A</note>'
|
|
342
|
+
// Output: '<note>A</note>'
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
### `format` - String Formatting
|
|
348
|
+
|
|
349
|
+
String formatting utilities for displaying and highlighting strings.
|
|
350
|
+
|
|
351
|
+
#### `format.mask(str, visibleChars?, maskChar?)`
|
|
352
|
+
Masks sensitive data in a string.
|
|
353
|
+
|
|
354
|
+
```javascript
|
|
355
|
+
st.format.mask('GUITAR-SERIAL-12345');
|
|
356
|
+
// Input: 'GUITAR-SERIAL-12345'
|
|
357
|
+
// Output: '***************2345'
|
|
358
|
+
|
|
359
|
+
st.format.mask('VIOLIN-ID-9876', 3, '#');
|
|
360
|
+
// Input: 'VIOLIN-ID-9876'
|
|
361
|
+
// Output: '###########876'
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
#### `format.highlight(str, search, wrapper?, caseSensitive?)`
|
|
365
|
+
Highlights search terms in a string by wrapping them.
|
|
366
|
+
|
|
367
|
+
```javascript
|
|
368
|
+
st.format.highlight('The violin plays a beautiful melody', 'violin');
|
|
369
|
+
// Input: 'The violin plays a beautiful melody'
|
|
370
|
+
// Output: 'The <mark>violin</mark> plays a beautiful melody'
|
|
371
|
+
|
|
372
|
+
st.format.highlight('Drums and bass create rhythm', 'bass', { start: '[', end: ']' });
|
|
373
|
+
// Input: 'Drums and bass create rhythm'
|
|
374
|
+
// Output: 'Drums and [bass] create rhythm'
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
#### `format.quote(type?)`
|
|
378
|
+
Creates quote manipulation utilities for wrapping/unwrapping strings with quotes.
|
|
379
|
+
|
|
380
|
+
```javascript
|
|
381
|
+
const dq = st.format.quote('double');
|
|
382
|
+
dq.add('staccato');
|
|
383
|
+
// Input: 'staccato'
|
|
384
|
+
// Output: '"staccato"'
|
|
385
|
+
|
|
386
|
+
const sq = st.format.quote('single');
|
|
387
|
+
sq.remove("'legato'");
|
|
388
|
+
// Input: "'legato'"
|
|
389
|
+
// Output: 'legato'
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
#### `format.bracket(type?)`
|
|
393
|
+
Creates bracket manipulation utilities for wrapping/unwrapping strings with brackets.
|
|
394
|
+
|
|
395
|
+
```javascript
|
|
396
|
+
const round = st.format.bracket('round');
|
|
397
|
+
round.add('forte');
|
|
398
|
+
// Input: 'forte'
|
|
399
|
+
// Output: '(forte)'
|
|
400
|
+
|
|
401
|
+
const square = st.format.bracket('square');
|
|
402
|
+
square.remove('[pianissimo]');
|
|
403
|
+
// Input: '[pianissimo]'
|
|
404
|
+
// Output: 'pianissimo'
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## License
|
|
410
|
+
|
|
411
|
+
MIT
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,193 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Capitalizes a string or sentence
|
|
3
|
+
* @param str - The string to capitalize
|
|
4
|
+
* @param fullSentence - If true, capitalizes each word in the sentence. If false, only capitalizes the first character
|
|
5
|
+
* @returns The capitalized string, or empty string if input is falsy
|
|
6
|
+
* @example
|
|
7
|
+
* transform.capitalize('hello world') // 'Hello World'
|
|
8
|
+
* transform.capitalize('hello world', false) // 'Hello world'
|
|
9
|
+
*/
|
|
10
|
+
declare const capitalize: (str: string, fullSentence?: boolean) => string;
|
|
11
|
+
/**
|
|
12
|
+
* String transformation utilities for converting strings to different formats and cases
|
|
13
|
+
* @property capitalize - Capitalizes a string or sentence
|
|
14
|
+
* @property camel - Converts to camelCase
|
|
15
|
+
* @property kebab - Converts to kebab-case
|
|
16
|
+
* @property pascal - Converts to PascalCase
|
|
17
|
+
* @property snake - Converts to snake_case
|
|
18
|
+
* @property snakeScream - Converts to SCREAMING_SNAKE_CASE
|
|
19
|
+
* @property reverse - Reverses a string
|
|
20
|
+
* @property slugify - Creates URL-friendly slugs
|
|
21
|
+
* @example
|
|
22
|
+
* transform.capitalize('hello world') // 'Hello World'
|
|
23
|
+
* transform.camel('hello world') // 'helloWorld'
|
|
24
|
+
* transform.kebab('helloWorld') // 'hello-world'
|
|
25
|
+
* transform.pascal('hello-world') // 'HelloWorld'
|
|
26
|
+
* transform.snake('helloWorld') // 'hello_world'
|
|
27
|
+
* transform.snakeScream('hello world') // 'HELLO_WORLD'
|
|
28
|
+
* transform.reverse('hello') // 'olleh'
|
|
29
|
+
* transform.slugify('Hello World!') // 'hello-world'
|
|
30
|
+
*/
|
|
31
|
+
declare const transform: {
|
|
32
|
+
capitalize: (str: string, fullSentence?: boolean) => string;
|
|
33
|
+
camel: (str: string) => string;
|
|
34
|
+
kebab: (str: string) => string;
|
|
35
|
+
pascal: (str: string) => string;
|
|
36
|
+
snake: (str: string) => string;
|
|
37
|
+
snakeScream: (str: string) => string;
|
|
38
|
+
reverse: (str: string) => string;
|
|
39
|
+
slugify: (str: string) => string;
|
|
40
|
+
};
|
|
41
|
+
declare const validate: {
|
|
42
|
+
email: (str: string, customRegex?: RegExp) => boolean;
|
|
43
|
+
url: (str: string, customRegex?: RegExp) => boolean;
|
|
44
|
+
phone: (str: string, customRegex?: RegExp) => boolean;
|
|
45
|
+
};
|
|
46
|
+
declare const edit: {
|
|
3
47
|
trim: (str: string, maxLength?: number, trimChar?: string) => string;
|
|
48
|
+
repeat: (str: string, count: number) => string;
|
|
49
|
+
pad: (str: string, length: number, char?: string, position?: "start" | "end" | "both") => string;
|
|
50
|
+
wrap: (str: string, wrapper: string | {
|
|
51
|
+
start: string;
|
|
52
|
+
end: string;
|
|
53
|
+
}) => string;
|
|
54
|
+
unwrap: (str: string, wrapper: string | {
|
|
55
|
+
start: string;
|
|
56
|
+
end: string;
|
|
57
|
+
}) => string;
|
|
4
58
|
prefix: (pf: string) => {
|
|
59
|
+
/**
|
|
60
|
+
* Adds the prefix to a string if it doesn't already start with it
|
|
61
|
+
* @param str - The string to add prefix to
|
|
62
|
+
* @returns The string with prefix, or empty string if input is falsy
|
|
63
|
+
*/
|
|
5
64
|
add: (str: string | undefined) => string;
|
|
65
|
+
/**
|
|
66
|
+
* Removes the prefix from a string if it starts with it
|
|
67
|
+
* @param str - The string to remove prefix from
|
|
68
|
+
* @returns The string without prefix, or empty string if input is falsy
|
|
69
|
+
*/
|
|
6
70
|
remove: (str: string | undefined) => string;
|
|
7
71
|
};
|
|
8
72
|
suffix: (sf: string) => {
|
|
73
|
+
/**
|
|
74
|
+
* Adds the suffix to a string if it doesn't already end with it
|
|
75
|
+
* @param str - The string to add suffix to
|
|
76
|
+
* @returns The string with suffix, or empty string if input is falsy
|
|
77
|
+
*/
|
|
9
78
|
add: (str: string | undefined) => string;
|
|
79
|
+
/**
|
|
80
|
+
* Removes the suffix from a string if it ends with it
|
|
81
|
+
* @param str - The string to remove suffix from
|
|
82
|
+
* @returns The string without suffix, or empty string if input is falsy
|
|
83
|
+
*/
|
|
10
84
|
remove: (str: string | undefined) => string;
|
|
11
85
|
};
|
|
86
|
+
initials: (str: string, maxInitials?: number) => string;
|
|
87
|
+
};
|
|
88
|
+
declare const clean: {
|
|
89
|
+
whitespace: (str: string) => string;
|
|
90
|
+
normalizeWhitespace: (str: string) => string;
|
|
91
|
+
html: (str: string) => string;
|
|
92
|
+
escapeHtml: (str: string) => string;
|
|
93
|
+
unescapeHtml: (str: string) => string;
|
|
94
|
+
};
|
|
95
|
+
declare const format: {
|
|
96
|
+
mask: (str: string, visibleChars?: number, maskChar?: string) => string;
|
|
97
|
+
highlight: (str: string, search: string, wrapper?: string | {
|
|
98
|
+
start: string;
|
|
99
|
+
end: string;
|
|
100
|
+
}, caseSensitive?: boolean) => string;
|
|
101
|
+
quote: (type?: "single" | "double" | "backtick") => {
|
|
102
|
+
/**
|
|
103
|
+
* Adds quotes to a string
|
|
104
|
+
* @param str - The string to quote
|
|
105
|
+
* @returns The quoted string
|
|
106
|
+
*/
|
|
107
|
+
add: (str: string) => string;
|
|
108
|
+
/**
|
|
109
|
+
* Removes quotes from a string
|
|
110
|
+
* @param str - The string to unquote
|
|
111
|
+
* @returns The unquoted string
|
|
112
|
+
*/
|
|
113
|
+
remove: (str: string) => string;
|
|
114
|
+
};
|
|
115
|
+
bracket: (type?: "round" | "square" | "curly" | "angle") => {
|
|
116
|
+
/**
|
|
117
|
+
* Adds brackets to a string
|
|
118
|
+
* @param str - The string to wrap
|
|
119
|
+
* @returns The bracketed string
|
|
120
|
+
*/
|
|
121
|
+
add: (str: string) => string;
|
|
122
|
+
/**
|
|
123
|
+
* Removes brackets from a string
|
|
124
|
+
* @param str - The string to unwrap
|
|
125
|
+
* @returns The unbracketted string
|
|
126
|
+
*/
|
|
127
|
+
remove: (str: string) => string;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
declare const st: {
|
|
132
|
+
transform: {
|
|
133
|
+
capitalize: (str: string, fullSentence?: boolean) => string;
|
|
134
|
+
camel: (str: string) => string;
|
|
135
|
+
kebab: (str: string) => string;
|
|
136
|
+
pascal: (str: string) => string;
|
|
137
|
+
snake: (str: string) => string;
|
|
138
|
+
snakeScream: (str: string) => string;
|
|
139
|
+
reverse: (str: string) => string;
|
|
140
|
+
slugify: (str: string) => string;
|
|
141
|
+
};
|
|
142
|
+
validate: {
|
|
143
|
+
email: (str: string, customRegex?: RegExp) => boolean;
|
|
144
|
+
url: (str: string, customRegex?: RegExp) => boolean;
|
|
145
|
+
phone: (str: string, customRegex?: RegExp) => boolean;
|
|
146
|
+
};
|
|
147
|
+
edit: {
|
|
148
|
+
trim: (str: string, maxLength?: number, trimChar?: string) => string;
|
|
149
|
+
repeat: (str: string, count: number) => string;
|
|
150
|
+
pad: (str: string, length: number, char?: string, position?: "start" | "end" | "both") => string;
|
|
151
|
+
wrap: (str: string, wrapper: string | {
|
|
152
|
+
start: string;
|
|
153
|
+
end: string;
|
|
154
|
+
}) => string;
|
|
155
|
+
unwrap: (str: string, wrapper: string | {
|
|
156
|
+
start: string;
|
|
157
|
+
end: string;
|
|
158
|
+
}) => string;
|
|
159
|
+
prefix: (pf: string) => {
|
|
160
|
+
add: (str: string | undefined) => string;
|
|
161
|
+
remove: (str: string | undefined) => string;
|
|
162
|
+
};
|
|
163
|
+
suffix: (sf: string) => {
|
|
164
|
+
add: (str: string | undefined) => string;
|
|
165
|
+
remove: (str: string | undefined) => string;
|
|
166
|
+
};
|
|
167
|
+
initials: (str: string, maxInitials?: number) => string;
|
|
168
|
+
};
|
|
169
|
+
clean: {
|
|
170
|
+
whitespace: (str: string) => string;
|
|
171
|
+
normalizeWhitespace: (str: string) => string;
|
|
172
|
+
html: (str: string) => string;
|
|
173
|
+
escapeHtml: (str: string) => string;
|
|
174
|
+
unescapeHtml: (str: string) => string;
|
|
175
|
+
};
|
|
176
|
+
format: {
|
|
177
|
+
mask: (str: string, visibleChars?: number, maskChar?: string) => string;
|
|
178
|
+
highlight: (str: string, search: string, wrapper?: string | {
|
|
179
|
+
start: string;
|
|
180
|
+
end: string;
|
|
181
|
+
}, caseSensitive?: boolean) => string;
|
|
182
|
+
quote: (type?: "single" | "double" | "backtick") => {
|
|
183
|
+
add: (str: string) => string;
|
|
184
|
+
remove: (str: string) => string;
|
|
185
|
+
};
|
|
186
|
+
bracket: (type?: "round" | "square" | "curly" | "angle") => {
|
|
187
|
+
add: (str: string) => string;
|
|
188
|
+
remove: (str: string) => string;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
12
191
|
};
|
|
13
192
|
|
|
14
|
-
export { st as default };
|
|
193
|
+
export { capitalize, clean, st as default, edit, format, transform, validate };
|