@hichchi/utils 0.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,1382 @@
1
+ **@hichchi/utils**
2
+
3
+ ---
4
+
5
+ # utils
6
+
7
+ This library was generated with [Nx](https://nx.dev).
8
+
9
+ ## Building
10
+
11
+ Run `nx build utils` to build the library.
12
+
13
+ ## Running unit tests
14
+
15
+ Run `nx test utils` to execute the unit tests via [Jest](https://jestjs.io).
16
+
17
+ ## Interfaces
18
+
19
+ ### InfiniteObject
20
+
21
+ #### Indexable
22
+
23
+ \[`key`: `string`\]: [`InfiniteObject`](README.md#infiniteobject)
24
+
25
+ ---
26
+
27
+ ### PathValueSet
28
+
29
+ #### Indexable
30
+
31
+ \[`path`: `string`\]: `string` \| `number` \| `boolean`
32
+
33
+ ## Type Aliases
34
+
35
+ ### LiteralObject\<T\>
36
+
37
+ ```ts
38
+ type LiteralObject<T>: {};
39
+ ```
40
+
41
+ #### Type Parameters
42
+
43
+ | Type Parameter | Default type |
44
+ |----------------|--------------|
45
+ | `T` | `any` |
46
+
47
+ #### Index Signature
48
+
49
+ \[`key`: `string`\]: `T`
50
+
51
+ #### Defined in
52
+
53
+ types.ts:3
54
+
55
+ ## Variables
56
+
57
+ ### mimeTypes
58
+
59
+ ```ts
60
+ const mimeTypes: Map<string, string>;
61
+ ```
62
+
63
+ Map of mime types to all file extensions.
64
+
65
+ #### Defined in
66
+
67
+ file.utils.ts:8
68
+
69
+ ## Functions
70
+
71
+ ### applyTemplate()
72
+
73
+ ```ts
74
+ function applyTemplate(str: string, prefix: string): string;
75
+ ```
76
+
77
+ Apply error message prefix to a valid template string
78
+
79
+ Acceptable template tags:
80
+
81
+ - `#{upperCase}`
82
+ - `#{snakeCase}`
83
+ - `#{upperSnakeCase}`
84
+ - `#{lowerCase}`
85
+ - `#{sentenceCase}`
86
+ - `#{firstCase}`
87
+
88
+ #### Parameters
89
+
90
+ | Parameter | Type | Description |
91
+ |-----------|----------|---------------------------------|
92
+ | `str` | `string` | Template string to apply prefix |
93
+ | `prefix` | `string` | Prefix to apply |
94
+
95
+ #### Returns
96
+
97
+ `string`
98
+
99
+ Prefix applied string
100
+
101
+ #### Example
102
+
103
+ ```TypeScript
104
+ applyTemplate(
105
+ "Cannot create a #{lowerCase} with this email. #{sentenceCase} already exists.",
106
+ "User",
107
+ );
108
+ // Output: Cannot create a user with this email. User exists.
109
+ ```
110
+
111
+ #### Defined in
112
+
113
+ string-template.utils.ts:29
114
+
115
+ ---
116
+
117
+ ### breakToWords()
118
+
119
+ #### Call Signature
120
+
121
+ ```ts
122
+ function breakToWords(str: string): string[];
123
+ ```
124
+
125
+ Break a string into words array.<br>
126
+
127
+ This function will break any of below to words in examples into `['hello', 'world']`<br>
128
+
129
+ ##### Parameters
130
+
131
+ | Parameter | Type | Description |
132
+ |-----------|----------|-----------------------------|
133
+ | `str` | `string` | String to break into words. |
134
+
135
+ ##### Returns
136
+
137
+ `string`[]
138
+
139
+ Array of words.
140
+
141
+ ##### Examples
142
+
143
+ ```TypeScript
144
+ breakToWords("helloWorld"); // ['hello', 'world']
145
+ ```
146
+
147
+ ```TypeScript
148
+ breakToWords("hello_world"); // ['hello', 'world']
149
+ ```
150
+
151
+ ```TypeScript
152
+ breakToWords("hello-world"); // ['hello', 'world']
153
+ ```
154
+
155
+ ```TypeScript
156
+ breakToWords("hello world"); // ['hello', 'world']
157
+ ```
158
+
159
+ ##### Defined in
160
+
161
+ string.utils.ts:31
162
+
163
+ #### Call Signature
164
+
165
+ ```ts
166
+ function breakToWords(str: string, format: (str: string) => string): string;
167
+ ```
168
+
169
+ Break a string into words array and format the string.<br>
170
+
171
+ This function will break a string into words and format the string using the provided function.<br>
172
+
173
+ ##### Parameters
174
+
175
+ | Parameter | Type | Description |
176
+ |-----------|-------------------------------|-----------------------------|
177
+ | `str` | `string` | String to break into words. |
178
+ | `format` | (`str`: `string`) => `string` | Formatting function. |
179
+
180
+ ##### Returns
181
+
182
+ `string`
183
+
184
+ Formatted string.
185
+
186
+ ##### Example
187
+
188
+ ```TypeScript
189
+ breakToWords("helloWorld", toFirstCase); // Hello world
190
+ ```
191
+
192
+ ##### Defined in
193
+
194
+ string.utils.ts:47
195
+
196
+ ---
197
+
198
+ ### deepCopy()
199
+
200
+ ```ts
201
+ function deepCopy<T>(obj: T): T;
202
+ ```
203
+
204
+ Deep copy an object.
205
+
206
+ #### Type Parameters
207
+
208
+ | Type Parameter | Description |
209
+ |----------------|---------------------|
210
+ | `T` | Type of the object. |
211
+
212
+ #### Parameters
213
+
214
+ | Parameter | Type | Description |
215
+ |-----------|------|-----------------|
216
+ | `obj` | `T` | Object to copy. |
217
+
218
+ #### Returns
219
+
220
+ `T`
221
+
222
+ Copied object.
223
+
224
+ #### Example
225
+
226
+ ```TypeScript
227
+ // Example usage
228
+ const object = {
229
+ name: "John Doe",
230
+ };
231
+
232
+ const copiedObject = deepCopy(object);
233
+ ```
234
+
235
+ #### Defined in
236
+
237
+ object.utils.ts:23
238
+
239
+ ---
240
+
241
+ ### getFileExt()
242
+
243
+ ```ts
244
+ function getFileExt(
245
+ mimeType: string,
246
+ allowedMimeTypes?: Map<string, string>,
247
+ ): string;
248
+ ```
249
+
250
+ Get the file extension of the given mime type.
251
+
252
+ #### Parameters
253
+
254
+ | Parameter | Type | Description |
255
+ |---------------------|-----------------------------|---------------------|
256
+ | `mimeType` | `string` | Mime type. |
257
+ | `allowedMimeTypes`? | `Map`\<`string`, `string`\> | Allowed mime types. |
258
+
259
+ #### Returns
260
+
261
+ `string`
262
+
263
+ File extension.
264
+
265
+ #### Defined in
266
+
267
+ file.utils.ts:1217
268
+
269
+ ---
270
+
271
+ ### getFileSize()
272
+
273
+ ```ts
274
+ function getFileSize(size: number, round?: boolean): string;
275
+ ```
276
+
277
+ Get file size in human-readable format.
278
+
279
+ #### Parameters
280
+
281
+ | Parameter | Type | Description |
282
+ |-----------|-----------|----------------------------|
283
+ | `size` | `number` | File size in bytes. |
284
+ | `round`? | `boolean` | Whether to round the size. |
285
+
286
+ #### Returns
287
+
288
+ `string`
289
+
290
+ File size in human-readable format.
291
+
292
+ #### Defined in
293
+
294
+ file.utils.ts:1227
295
+
296
+ ---
297
+
298
+ ### getMapKey()
299
+
300
+ ```ts
301
+ function getMapKey(
302
+ map: Map<string, unknown>,
303
+ value: unknown,
304
+ ): string | undefined;
305
+ ```
306
+
307
+ Get the key of a map by value.
308
+
309
+ #### Parameters
310
+
311
+ | Parameter | Type | Description |
312
+ |-----------|------------------------------|-----------------------|
313
+ | `map` | `Map`\<`string`, `unknown`\> | Map to get key from. |
314
+ | `value` | `unknown` | Value to get key for. |
315
+
316
+ #### Returns
317
+
318
+ `string` \| `undefined`
319
+
320
+ Key of the map.
321
+
322
+ #### Example
323
+
324
+ ```TypeScript
325
+ // Example usage
326
+ const user = new Map<string, string>([
327
+ ["firstName", "John"],
328
+ ["lastName", "Doe"],
329
+ ["preferredName", "John"],
330
+ ["age", 30],
331
+ ]);
332
+
333
+ const key = getMapKey(user, "value2");
334
+
335
+ // Example output: "firstName"
336
+ ```
337
+
338
+ #### Defined in
339
+
340
+ object.utils.ts:53
341
+
342
+ ---
343
+
344
+ ### getMapKeys()
345
+
346
+ ```ts
347
+ function getMapKeys(map: Map<string, string>, partialValue: string): string[];
348
+ ```
349
+
350
+ Get the keys of a map by partial value.
351
+
352
+ #### Parameters
353
+
354
+ | Parameter | Type | Description |
355
+ |----------------|-----------------------------|--------------------------------|
356
+ | `map` | `Map`\<`string`, `string`\> | Map to get keys from. |
357
+ | `partialValue` | `string` | Partial value to get keys for. |
358
+
359
+ #### Returns
360
+
361
+ `string`[]
362
+
363
+ - Keys of the map.
364
+
365
+ #### Example
366
+
367
+ ```TypeScript
368
+ // Example usage
369
+ const user = new Map<string, string>([
370
+ ["firstName", "John"],
371
+ ["lastName", "Doe"],
372
+ ["preferredName", "John"],
373
+ ["age", 30],
374
+ ]);
375
+
376
+ const keys = getMapKeys(user, "Jo");
377
+
378
+ // Example output
379
+ ["firstName", "preferredName"];
380
+ ```
381
+
382
+ #### Defined in
383
+
384
+ object.utils.ts:79
385
+
386
+ ---
387
+
388
+ ### getValueByPath()
389
+
390
+ ```ts
391
+ function getValueByPath<T>(obj: InfiniteObject, path: string): T;
392
+ ```
393
+
394
+ Get value from an object by path.
395
+
396
+ #### Type Parameters
397
+
398
+ | Type Parameter | Description |
399
+ |----------------|--------------------|
400
+ | `T` | Type of the value. |
401
+
402
+ #### Parameters
403
+
404
+ | Parameter | Type | Description |
405
+ |-----------|----------------------------------------------|---------------------------|
406
+ | `obj` | [`InfiniteObject`](README.md#infiniteobject) | Object to get value from. |
407
+ | `path` | `string` | Path to get value from. |
408
+
409
+ #### Returns
410
+
411
+ `T`
412
+
413
+ Value from the object.
414
+
415
+ #### Example
416
+
417
+ ```TypeScript
418
+ // Example usage
419
+ const object = {
420
+ role: "user",
421
+ profile: {
422
+ name: "John Doe",
423
+ age: 30,
424
+ address: {
425
+ city: "New York",
426
+ },
427
+ },
428
+ };
429
+
430
+ const value = getValueByPath<string>(object, "profile.address.city");
431
+
432
+ // Example output: "New York"
433
+ ```
434
+
435
+ #### Defined in
436
+
437
+ object.utils.ts:196
438
+
439
+ ---
440
+
441
+ ### groupBy()
442
+
443
+ ```ts
444
+ function groupBy<K, V>(list: V[], keyGetter: (input: V) => K): Map<K, V[]>;
445
+ ```
446
+
447
+ Groups an array of objects by a key.
448
+
449
+ #### Type Parameters
450
+
451
+ | Type Parameter | Description |
452
+ |----------------|---------------------|
453
+ | `K` | Type of the key. |
454
+ | `V` | Type of the object. |
455
+
456
+ #### Parameters
457
+
458
+ | Parameter | Type | Description |
459
+ |-------------|-----------------------|------------------------------------------|
460
+ | `list` | `V`[] | Array of objects to group. |
461
+ | `keyGetter` | (`input`: `V`) => `K` | Function to get the key from the object. |
462
+
463
+ #### Returns
464
+
465
+ `Map`\<`K`, `V`[]\>
466
+
467
+ Grouped objects.
468
+
469
+ #### Example
470
+
471
+ ```TypeScript
472
+ // Example usage
473
+ // group by age, all have unique names
474
+ const users = [
475
+ { name: "John", age: 30 },
476
+ { name: "Jane", age: 25 },
477
+ { name: "Doe", age: 30 },
478
+ { name: "Smith", age: 25 },
479
+ { name: "Denis", age: 30 },
480
+ ];
481
+
482
+ const groupedUsers = groupBy(users, user => user.age);
483
+
484
+ // Example output
485
+ Map {
486
+ 30 => [
487
+ { name: "John", age: 30 },
488
+ { name: "Doe", age: 30 },
489
+ { name: "Denis", age: 30 },
490
+ ],
491
+ 25 => [
492
+ { name: "Jane", age: 25 },
493
+ { name: "Smith", age: 25 },
494
+ ],
495
+ }
496
+ ```
497
+
498
+ #### Defined in
499
+
500
+ object.utils.ts:125
501
+
502
+ ---
503
+
504
+ ### htmlToText()
505
+
506
+ ```ts
507
+ function htmlToText(str: string): string;
508
+ ```
509
+
510
+ Remove HTML tags from a string and return plain text.
511
+
512
+ #### Parameters
513
+
514
+ | Parameter | Type | Description |
515
+ |-----------|----------|----------------------------------|
516
+ | `str` | `string` | String to remove HTML tags from. |
517
+
518
+ #### Returns
519
+
520
+ `string`
521
+
522
+ Plain text.
523
+
524
+ #### Example
525
+
526
+ ```TypeScript
527
+ htmlToText("<h1>Hello World</h1>"); // "Hello World"
528
+ ```
529
+
530
+ #### Defined in
531
+
532
+ string.utils.ts:305
533
+
534
+ ---
535
+
536
+ ### isArray()
537
+
538
+ ```ts
539
+ function isArray<T>(value: T | T[]): value is T[];
540
+ ```
541
+
542
+ Check if the value is an array while asserting it's an array of generic type T
543
+
544
+ #### Type Parameters
545
+
546
+ | Type Parameter | Description |
547
+ |----------------|-----------------------|
548
+ | `T` | The type of the array |
549
+
550
+ #### Parameters
551
+
552
+ | Parameter | Type | Description |
553
+ |-----------|--------------|--------------------|
554
+ | `value` | `T` \| `T`[] | The value to check |
555
+
556
+ #### Returns
557
+
558
+ `value is T[]`
559
+
560
+ True if the value is an array, false otherwise
561
+
562
+ #### Example
563
+
564
+ ```TypeScript
565
+ async function createUser(userOrUsers: UserDto | UserDto[] | undefined): User {
566
+ if (isArray<UserDto>(userOrUsers)) {
567
+ return userOrUsers.map(async (user) => await userService.createUser(user));
568
+ } else {
569
+ return await userService.createUser(userOrUsers);
570
+ }
571
+ }
572
+ ```
573
+
574
+ #### Defined in
575
+
576
+ assertions.utils.ts:21
577
+
578
+ ---
579
+
580
+ ### isObject()
581
+
582
+ ```ts
583
+ function isObject<T>(value?: T | T[]): value is T;
584
+ ```
585
+
586
+ Check if the value is an object while asserting it's an object of generic type T
587
+
588
+ #### Type Parameters
589
+
590
+ | Type Parameter | Description |
591
+ |----------------|------------------------|
592
+ | `T` | The type of the object |
593
+
594
+ #### Parameters
595
+
596
+ | Parameter | Type | Description |
597
+ |-----------|--------------|--------------------|
598
+ | `value`? | `T` \| `T`[] | The value to check |
599
+
600
+ #### Returns
601
+
602
+ `value is T`
603
+
604
+ True if the value is an object, false otherwise
605
+
606
+ #### Example
607
+
608
+ ```TypeScript
609
+ async function getUserInfo(userIdOrUser: string | User | undefined): UserInfo {
610
+ if (isObject<User>(userIdOrUser)) {
611
+ return await userService.getUserInfo(userIdOrUser.id);
612
+ } else {
613
+ return await userService.getUserInfo(userIdOrUser);
614
+ }
615
+ }
616
+ ```
617
+
618
+ #### Defined in
619
+
620
+ assertions.utils.ts:42
621
+
622
+ ---
623
+
624
+ ### isObjectWith()
625
+
626
+ ```ts
627
+ function isObjectWith<T>(value: any, propertyName: keyof T): value is T;
628
+ ```
629
+
630
+ Check if the value is an object with a given property name and asset it's an object of generic type T
631
+
632
+ #### Type Parameters
633
+
634
+ | Type Parameter | Description |
635
+ |------------------------|------------------------|
636
+ | `T` _extends_ `object` | The type of the object |
637
+
638
+ #### Parameters
639
+
640
+ | Parameter | Type | Description |
641
+ |----------------|-----------|----------------------------|
642
+ | `value` | `any` | The value to check |
643
+ | `propertyName` | keyof `T` | The property name to check |
644
+
645
+ #### Returns
646
+
647
+ `value is T`
648
+
649
+ True if the value is an object with the given property name, false otherwise
650
+
651
+ #### Example
652
+
653
+ ```TypeScript
654
+ async function getUserInfo(userIdOrUser: string | User | undefined): UserInfo {
655
+ if (isObjectWith<User>(userIdOrUser, "id")) {
656
+ return await userService.getUserInfo(userIdOrUser.id);
657
+ } else {
658
+ return await userService.getUserInfo(userIdOrUser);
659
+ }
660
+ }
661
+ ```
662
+
663
+ #### Defined in
664
+
665
+ assertions.utils.ts:64
666
+
667
+ ---
668
+
669
+ ### objectToPathValueSet()
670
+
671
+ ```ts
672
+ function objectToPathValueSet(obj: LiteralObject): PathValueSet;
673
+ ```
674
+
675
+ Convert an object to a path value set
676
+
677
+ #### Parameters
678
+
679
+ | Parameter | Type | Description |
680
+ |-----------|---------------------------------------------|-------------|
681
+ | `obj` | [`LiteralObject`](README.md#literalobjectt) | The object |
682
+
683
+ #### Returns
684
+
685
+ [`PathValueSet`](README.md#pathvalueset)
686
+
687
+ The path value set
688
+
689
+ #### Example
690
+
691
+ ```TypeScript
692
+ // Example usage
693
+ const object = {
694
+ role: "user",
695
+ profile: {
696
+ name: "John Doe",
697
+ age: 30,
698
+ address: {
699
+ city: "New York",
700
+ },
701
+ },
702
+ };
703
+
704
+ const pathValueSet = objectToPathValueSet(object);
705
+
706
+ // Example output
707
+ {
708
+ "role": "user",
709
+ "profile.name": "John Doe",
710
+ "profile.age": 30,
711
+ "profile.address.city": "New York",
712
+ }
713
+ ```
714
+
715
+ #### Defined in
716
+
717
+ object.utils.ts:255
718
+
719
+ ---
720
+
721
+ ### omit()
722
+
723
+ ```ts
724
+ function omit<T>(obj: Partial<T>, keys?: keyof T[]): void;
725
+ ```
726
+
727
+ Omits undefined properties and properties in the keys array from an object.
728
+
729
+ #### Type Parameters
730
+
731
+ | Type Parameter |
732
+ |--------------------|
733
+ | `T` _extends_ \{\} |
734
+
735
+ #### Parameters
736
+
737
+ | Parameter | Type | Description |
738
+ |-----------|------------------|---------------------------------|
739
+ | `obj` | `Partial`\<`T`\> | Object to omit properties from. |
740
+ | `keys`? | keyof `T`[] | Array of keys to omit. |
741
+
742
+ #### Returns
743
+
744
+ `void`
745
+
746
+ - Object with omitted properties.
747
+
748
+ #### Example
749
+
750
+ ```TypeScript
751
+ // Example usage
752
+ const object = {
753
+ role: "user",
754
+ name: "John Doe",
755
+ age: 30,
756
+ address: undefined,
757
+ };
758
+
759
+ omit(object, ["role"]);
760
+
761
+ // Example output
762
+ {
763
+ name: "John Doe",
764
+ age: 30,
765
+ }
766
+ ```
767
+
768
+ #### Defined in
769
+
770
+ object.utils.ts:370
771
+
772
+ ---
773
+
774
+ ### pathValueSetToObject()
775
+
776
+ ```ts
777
+ function pathValueSetToObject<R>(pathValueSet: Record<string, any>): R;
778
+ ```
779
+
780
+ Convert the path value set to an object
781
+
782
+ #### Type Parameters
783
+
784
+ | Type Parameter | Default type | Description |
785
+ |----------------|--------------|-----------------|
786
+ | `R` | `object` | The return type |
787
+
788
+ #### Parameters
789
+
790
+ | Parameter | Type | Description |
791
+ |----------------|-----------------------------|--------------------|
792
+ | `pathValueSet` | `Record`\<`string`, `any`\> | The path value set |
793
+
794
+ #### Returns
795
+
796
+ `R`
797
+
798
+ The object with the path value set converted
799
+
800
+ #### Example
801
+
802
+ ```TypeScript
803
+ // Example usage
804
+ const pathValueSet = {
805
+ "role": "user",
806
+ "profile.name": "John Doe",
807
+ "profile.age": 30,
808
+ "profile.address.city": "New York",
809
+ }
810
+
811
+ const object = pathValueSetToObject(pathValueSet);
812
+
813
+ // Example output
814
+ {
815
+ role: "user",
816
+ profile: {
817
+ name: "John Doe",
818
+ age: 30,
819
+ address: {
820
+ city: "New York",
821
+ },
822
+ },
823
+ }
824
+ ```
825
+
826
+ #### Defined in
827
+
828
+ object.utils.ts:308
829
+
830
+ ---
831
+
832
+ ### prune()
833
+
834
+ ```ts
835
+ function prune<T>(obj: any, omitPrototype?: boolean): T;
836
+ ```
837
+
838
+ Prune an object by removing all empty, null, undefined, and prototype properties.
839
+
840
+ #### Type Parameters
841
+
842
+ | Type Parameter | Description |
843
+ |----------------|---------------------|
844
+ | `T` | Type of the object. |
845
+
846
+ #### Parameters
847
+
848
+ | Parameter | Type | Description |
849
+ |------------------|-----------|----------------------------|
850
+ | `obj` | `any` | Object to prune. |
851
+ | `omitPrototype`? | `boolean` | Omit prototype properties. |
852
+
853
+ #### Returns
854
+
855
+ `T`
856
+
857
+ Pruned object.
858
+
859
+ #### Example
860
+
861
+ ````TypeScript
862
+ // Example usage
863
+ const object = {
864
+ role: "user",
865
+ profile: {
866
+ name: "John Doe",
867
+ age: 30,
868
+ address: undefined,
869
+ city: "New York",
870
+ },
871
+ };
872
+
873
+ #### Defined in
874
+
875
+ object.utils.ts:398
876
+
877
+ ***
878
+
879
+ ### saveAsFile()
880
+
881
+ ```ts
882
+ function saveAsFile(blob: Blob, filename: string): void
883
+ ````
884
+
885
+ Save a StreamableBlob as a file.
886
+
887
+ #### Parameters
888
+
889
+ | Parameter | Type | Description |
890
+ |------------|----------|---------------|
891
+ | `blob` | `Blob` | Blob to save. |
892
+ | `filename` | `string` | File name. |
893
+
894
+ #### Returns
895
+
896
+ `void`
897
+
898
+ #### Throws
899
+
900
+ - Throws an error if used in a Node.js environment.
901
+
902
+ #### Defined in
903
+
904
+ file.utils.ts:1246
905
+
906
+ ---
907
+
908
+ ### searchMapValues()
909
+
910
+ ```ts
911
+ function searchMapValues(
912
+ map: Map<string, string>,
913
+ partialValue: string,
914
+ ): string[];
915
+ ```
916
+
917
+ Get the values of a map by partial value.
918
+
919
+ #### Parameters
920
+
921
+ | Parameter | Type | Description |
922
+ |----------------|-----------------------------|----------------------------------|
923
+ | `map` | `Map`\<`string`, `string`\> | Map to get values from. |
924
+ | `partialValue` | `string` | Partial value to get values for. |
925
+
926
+ #### Returns
927
+
928
+ `string`[]
929
+
930
+ Values of the map.
931
+
932
+ #### Example
933
+
934
+ ```TypeScript
935
+ // Example usage
936
+ const user = new Map<string, string>([
937
+ ["name", "John Doe"],
938
+ ["preferredName", "John"],
939
+ ["age", 30],
940
+ ]);
941
+
942
+ const values = getMapValues(user, "Jo");
943
+
944
+ // Example output
945
+ ["John Doe", "John"];
946
+ ```
947
+
948
+ #### Defined in
949
+
950
+ object.utils.ts:160
951
+
952
+ ---
953
+
954
+ ### singular()
955
+
956
+ ```ts
957
+ function singular(str: string): string;
958
+ ```
959
+
960
+ Handles converting plural words to their singular form.
961
+
962
+ #### Parameters
963
+
964
+ | Parameter | Type | Description |
965
+ |-----------|----------|--------------------------------|
966
+ | `str` | `string` | String to convert to singular. |
967
+
968
+ #### Returns
969
+
970
+ `string`
971
+
972
+ Singular form of the string.
973
+
974
+ #### Example
975
+
976
+ ```TypeScript
977
+ singular("children"); // "child"
978
+ ```
979
+
980
+ #### Defined in
981
+
982
+ string.utils.ts:319
983
+
984
+ ---
985
+
986
+ ### toCamelCase()
987
+
988
+ ```ts
989
+ function toCamelCase(str?: string): string;
990
+ ```
991
+
992
+ Convert a string to camel case.
993
+
994
+ #### Parameters
995
+
996
+ | Parameter | Type | Description |
997
+ |-----------|----------|----------------------------------|
998
+ | `str`? | `string` | String to convert to camel case. |
999
+
1000
+ #### Returns
1001
+
1002
+ `string`
1003
+
1004
+ String in camel case.
1005
+
1006
+ #### Example
1007
+
1008
+ ```TypeScript
1009
+ toCamelCase("hello world"); // "helloWorld"
1010
+ ```
1011
+
1012
+ #### Defined in
1013
+
1014
+ string.utils.ts:188
1015
+
1016
+ ---
1017
+
1018
+ ### toFirstCase()
1019
+
1020
+ ```ts
1021
+ function toFirstCase(str?: string): string;
1022
+ ```
1023
+
1024
+ Convert a string to first case (Capitalize first letter of the string).
1025
+
1026
+ #### Parameters
1027
+
1028
+ | Parameter | Type | Description |
1029
+ |-----------|----------|-----------------------------------------|
1030
+ | `str`? | `string` | Optional string to join the words with. |
1031
+
1032
+ #### Returns
1033
+
1034
+ `string`
1035
+
1036
+ String in first case.
1037
+
1038
+ #### Example
1039
+
1040
+ ```TypeScript
1041
+ toFirstCase("hello world"); // "Hello world"
1042
+ ```
1043
+
1044
+ #### Defined in
1045
+
1046
+ string.utils.ts:152
1047
+
1048
+ ---
1049
+
1050
+ ### toKebabCase()
1051
+
1052
+ ```ts
1053
+ function toKebabCase(str?: string, caps?: boolean): string;
1054
+ ```
1055
+
1056
+ Convert a string to kebab case.
1057
+
1058
+ #### Parameters
1059
+
1060
+ | Parameter | Type | Description |
1061
+ |-----------|-----------|-----------------------------------|
1062
+ | `str`? | `string` | String to convert to kebab case. |
1063
+ | `caps`? | `boolean` | Whether to convert to upper case. |
1064
+
1065
+ #### Returns
1066
+
1067
+ `string`
1068
+
1069
+ String in kebab case.
1070
+
1071
+ #### Examples
1072
+
1073
+ ```TypeScript
1074
+ toKebabCase("hello world"); // "hello-world"
1075
+ ```
1076
+
1077
+ ```TypeScript
1078
+ toKebabCase("hello world", true); // "HELLO-WORLD"
1079
+ ```
1080
+
1081
+ #### Defined in
1082
+
1083
+ string.utils.ts:273
1084
+
1085
+ ---
1086
+
1087
+ ### toLowerCase()
1088
+
1089
+ ```ts
1090
+ function toLowerCase(str?: string): string;
1091
+ ```
1092
+
1093
+ Convert a string to lower case.
1094
+
1095
+ #### Parameters
1096
+
1097
+ | Parameter | Type | Description |
1098
+ |-----------|----------|----------------------------------|
1099
+ | `str`? | `string` | String to convert to lower case. |
1100
+
1101
+ #### Returns
1102
+
1103
+ `string`
1104
+
1105
+ String in lower case.
1106
+
1107
+ #### Example
1108
+
1109
+ ```TypeScript
1110
+ toLowerCase("Hello World"); // "hello world"
1111
+ ```
1112
+
1113
+ #### Defined in
1114
+
1115
+ string.utils.ts:74
1116
+
1117
+ ---
1118
+
1119
+ ### toLowerCaseBreak()
1120
+
1121
+ ```ts
1122
+ function toLowerCaseBreak(str?: string, join?: string): string;
1123
+ ```
1124
+
1125
+ Convert a string to lower cases and break into words with optional join or space.
1126
+
1127
+ #### Parameters
1128
+
1129
+ | Parameter | Type | Description |
1130
+ |-----------|----------|--------------------------------------------------------|
1131
+ | `str`? | `string` | String to convert to lower cases and break into words. |
1132
+ | `join`? | `string` | Optional string to join the words with. |
1133
+
1134
+ #### Returns
1135
+
1136
+ `string`
1137
+
1138
+ String in lower cases and broken into words.
1139
+
1140
+ #### Example
1141
+
1142
+ ```TypeScript
1143
+ toLowerCaseBreak("HelloWorld"); // "hello world"
1144
+ ```
1145
+
1146
+ #### Defined in
1147
+
1148
+ string.utils.ts:92
1149
+
1150
+ ---
1151
+
1152
+ ### toNumber()
1153
+
1154
+ ```ts
1155
+ function toNumber(str: string | number): number | undefined;
1156
+ ```
1157
+
1158
+ Converts a string to a number.
1159
+
1160
+ #### Parameters
1161
+
1162
+ | Parameter | Type | Description |
1163
+ |-----------|----------------------|--------------------------------|
1164
+ | `str` | `string` \| `number` | String to convert to a number. |
1165
+
1166
+ #### Returns
1167
+
1168
+ `number` \| `undefined`
1169
+
1170
+ Number or undefined.
1171
+
1172
+ #### Example
1173
+
1174
+ ```TypeScript
1175
+ toNumber("123"); // 123
1176
+ ```
1177
+
1178
+ #### Defined in
1179
+
1180
+ string.utils.ts:291
1181
+
1182
+ ---
1183
+
1184
+ ### toPascalCase()
1185
+
1186
+ ```ts
1187
+ function toPascalCase(str?: string): string;
1188
+ ```
1189
+
1190
+ Convert a string to pascal case.
1191
+
1192
+ #### Parameters
1193
+
1194
+ | Parameter | Type | Description |
1195
+ |-----------|----------|-----------------------------------|
1196
+ | `str`? | `string` | String to convert to pascal case. |
1197
+
1198
+ #### Returns
1199
+
1200
+ `string`
1201
+
1202
+ String in pascal case.
1203
+
1204
+ #### Example
1205
+
1206
+ ```TypeScript
1207
+ toPascalCase("hello world"); // "HelloWorld"
1208
+ ```
1209
+
1210
+ #### Defined in
1211
+
1212
+ string.utils.ts:207
1213
+
1214
+ ---
1215
+
1216
+ ### toSentenceCase()
1217
+
1218
+ ```ts
1219
+ function toSentenceCase(str?: string): string;
1220
+ ```
1221
+
1222
+ Convert a string to sentence case. (Capitalize first letter of every sentence).
1223
+
1224
+ #### Parameters
1225
+
1226
+ | Parameter | Type | Description |
1227
+ |-----------|----------|-------------------------------------|
1228
+ | `str`? | `string` | String to convert to sentence case. |
1229
+
1230
+ #### Returns
1231
+
1232
+ `string`
1233
+
1234
+ String in sentence case.
1235
+
1236
+ #### Example
1237
+
1238
+ ```TypeScript
1239
+ toSentenceCase("hello world. how are you?"); // "Hello world. How are you?"
1240
+ ```
1241
+
1242
+ #### Defined in
1243
+
1244
+ string.utils.ts:226
1245
+
1246
+ ---
1247
+
1248
+ ### toSnakeCase()
1249
+
1250
+ ```ts
1251
+ function toSnakeCase(str?: string, caps?: boolean): string;
1252
+ ```
1253
+
1254
+ Convert a string to snake case.
1255
+
1256
+ #### Parameters
1257
+
1258
+ | Parameter | Type | Description |
1259
+ |-----------|-----------|-----------------------------------|
1260
+ | `str`? | `string` | String to convert to snake case. |
1261
+ | `caps`? | `boolean` | Whether to convert to upper case. |
1262
+
1263
+ #### Returns
1264
+
1265
+ `string`
1266
+
1267
+ String in snake case.
1268
+
1269
+ #### Examples
1270
+
1271
+ ```TypeScript
1272
+ toSnakeCase("hello world"); // "hello_world"
1273
+ ```
1274
+
1275
+ ```TypeScript
1276
+ toSnakeCase("hello world", true); // "HELLO_WORLD"
1277
+ ```
1278
+
1279
+ #### Defined in
1280
+
1281
+ string.utils.ts:249
1282
+
1283
+ ---
1284
+
1285
+ ### toTitleCase()
1286
+
1287
+ ```ts
1288
+ function toTitleCase(str?: string): string;
1289
+ ```
1290
+
1291
+ Convert a string to title case (Capitalize first letter of each word).
1292
+
1293
+ #### Parameters
1294
+
1295
+ | Parameter | Type | Description |
1296
+ |-----------|----------|----------------------------------|
1297
+ | `str`? | `string` | String to convert to title case. |
1298
+
1299
+ #### Returns
1300
+
1301
+ `string`
1302
+
1303
+ String in title case.
1304
+
1305
+ #### Example
1306
+
1307
+ ```TypeScript
1308
+ toTitleCase("hello world"); // "Hello World"
1309
+ ```
1310
+
1311
+ #### Defined in
1312
+
1313
+ string.utils.ts:169
1314
+
1315
+ ---
1316
+
1317
+ ### toUpperCase()
1318
+
1319
+ ```ts
1320
+ function toUpperCase(str?: string): string;
1321
+ ```
1322
+
1323
+ Convert a string to upper case.
1324
+
1325
+ #### Parameters
1326
+
1327
+ | Parameter | Type | Description |
1328
+ |-----------|----------|----------------------------------|
1329
+ | `str`? | `string` | String to convert to upper case. |
1330
+
1331
+ #### Returns
1332
+
1333
+ `string`
1334
+
1335
+ String in upper case.
1336
+
1337
+ #### Example
1338
+
1339
+ ```TypeScript
1340
+ toUpperCase("HelloWorld"); // "HELLO WORLD"
1341
+ ```
1342
+
1343
+ #### Defined in
1344
+
1345
+ string.utils.ts:111
1346
+
1347
+ ---
1348
+
1349
+ ### toUpperCaseBreak()
1350
+
1351
+ ```ts
1352
+ function toUpperCaseBreak(str?: string, join?: string): string;
1353
+ ```
1354
+
1355
+ Convert a string to upper cases and break into words with optional join or space.
1356
+
1357
+ #### Parameters
1358
+
1359
+ | Parameter | Type | Description |
1360
+ |-----------|----------|--------------------------------------------------------|
1361
+ | `str`? | `string` | String to convert to upper cases and break into words. |
1362
+ | `join`? | `string` | Optional string to join the words with. |
1363
+
1364
+ #### Returns
1365
+
1366
+ `string`
1367
+
1368
+ String in upper cases and broken into words.
1369
+
1370
+ #### Examples
1371
+
1372
+ ```TypeScript
1373
+ toUpperCaseBreak("HelloWorld"); // "HELLO WORLD"
1374
+ ```
1375
+
1376
+ ```TypeScript
1377
+ toUpperCaseBreak("HelloWorld", "! "); // "HELLO! WORLD"
1378
+
1379
+ #### Defined in
1380
+
1381
+ string.utils.ts:133
1382
+ ```