@bigbinary/neeto-commons-frontend 2.1.6 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -94
- package/configs/scripts/jsdoc-builder/constants.mjs +1 -1
- package/configs/scripts/jsdoc-builder/utils.mjs +4 -3
- package/cypress-utils.d.ts +2 -2
- package/initializers.d.ts +7 -5
- package/package.json +1 -1
- package/pure.d.ts +325 -324
- package/react-utils.d.ts +674 -153
- package/utils.cjs.js +8 -2
- package/utils.cjs.js.map +1 -1
- package/utils.d.ts +145 -44
- package/utils.js +8 -2
- package/utils.js.map +1 -1
package/pure.d.ts
CHANGED
|
@@ -11,11 +11,7 @@ type MatchPattern<Obj = any, Parent = Obj> = Obj extends any[] ? Matchable<Obj,
|
|
|
11
11
|
});
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* Failsafe status: alternative available
|
|
17
|
-
*
|
|
18
|
-
* Converts camelCase string to snake_case.
|
|
14
|
+
* The camelToSnakeCase function converts a camelCase string to snake_case.
|
|
19
15
|
*
|
|
20
16
|
* @example
|
|
21
17
|
*
|
|
@@ -26,11 +22,7 @@ export function camelToSnakeCase(string: string): string;
|
|
|
26
22
|
export function _camelToSnakeCase(string: NilOr<string>): NilOr<string>;
|
|
27
23
|
/**
|
|
28
24
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* Failsafe status: alternative available
|
|
32
|
-
*
|
|
33
|
-
* Convert the first character of string to upper case.
|
|
25
|
+
* The capitalize function converts the first character of a string to uppercase.
|
|
34
26
|
*
|
|
35
27
|
* @example
|
|
36
28
|
*
|
|
@@ -43,13 +35,13 @@ export function capitalize(string: string): string;
|
|
|
43
35
|
export function _capitalize(string: NilOr<string>): NilOr<string>;
|
|
44
36
|
/**
|
|
45
37
|
*
|
|
46
|
-
*
|
|
38
|
+
* The copyKeys function is similar to the renameKeys function
|
|
47
39
|
*
|
|
48
|
-
*
|
|
40
|
+
* but retains both the source and destination keys in the resulting array. For
|
|
49
41
|
*
|
|
50
|
-
*
|
|
42
|
+
* deep copying of nested objects refer to copyKeysDeep
|
|
51
43
|
*
|
|
52
|
-
*
|
|
44
|
+
* function.
|
|
53
45
|
*
|
|
54
46
|
* @example
|
|
55
47
|
*
|
|
@@ -74,13 +66,13 @@ export function copyKeys<T>(keyMap: { [key in keyof Partial<T>]: string }, objec
|
|
|
74
66
|
})[];
|
|
75
67
|
/**
|
|
76
68
|
*
|
|
77
|
-
*
|
|
69
|
+
* The copyKeys function is similar to the renameKeys function
|
|
78
70
|
*
|
|
79
|
-
*
|
|
71
|
+
* but retains both the source and destination keys in the resulting array. For
|
|
80
72
|
*
|
|
81
|
-
*
|
|
73
|
+
* deep copying of nested objects refer to copyKeysDeep
|
|
82
74
|
*
|
|
83
|
-
*
|
|
75
|
+
* function.
|
|
84
76
|
*
|
|
85
77
|
* @example
|
|
86
78
|
*
|
|
@@ -115,13 +107,11 @@ export function _copyKeys(keyMap: {
|
|
|
115
107
|
})[]>;
|
|
116
108
|
/**
|
|
117
109
|
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* Failsafe status: alternative available
|
|
110
|
+
* The copyKeysDeep function is an advanced version of the
|
|
121
111
|
*
|
|
122
|
-
*
|
|
112
|
+
* copyKeys function. It supports deep copying with nested objects
|
|
123
113
|
*
|
|
124
|
-
*
|
|
114
|
+
* and offers flexibility in specifying key mappings for the copy operation.
|
|
125
115
|
*
|
|
126
116
|
* @example
|
|
127
117
|
*
|
|
@@ -142,7 +132,7 @@ export function _copyKeys(keyMap: {
|
|
|
142
132
|
* },
|
|
143
133
|
* ];
|
|
144
134
|
*
|
|
145
|
-
* //
|
|
135
|
+
* // Create a new array to hold the transformed objects
|
|
146
136
|
* copyKeysDeep(
|
|
147
137
|
* {
|
|
148
138
|
* name: "label",
|
|
@@ -177,13 +167,11 @@ export function _copyKeys(keyMap: {
|
|
|
177
167
|
export function copyKeysDeep(keyMap: object, objectArray: object[]): object[];
|
|
178
168
|
/**
|
|
179
169
|
*
|
|
180
|
-
*
|
|
170
|
+
* The copyKeysDeep function is an advanced version of the
|
|
181
171
|
*
|
|
182
|
-
*
|
|
172
|
+
* copyKeys function. It supports deep copying with nested objects
|
|
183
173
|
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* has a different structure for the key mapping to support nesting.
|
|
174
|
+
* and offers flexibility in specifying key mappings for the copy operation.
|
|
187
175
|
*
|
|
188
176
|
* @example
|
|
189
177
|
*
|
|
@@ -204,7 +192,7 @@ export function copyKeysDeep(keyMap: object, objectArray: object[]): object[];
|
|
|
204
192
|
* },
|
|
205
193
|
* ];
|
|
206
194
|
*
|
|
207
|
-
* //
|
|
195
|
+
* // Create a new array to hold the transformed objects
|
|
208
196
|
* copyKeysDeep(
|
|
209
197
|
* {
|
|
210
198
|
* name: "label",
|
|
@@ -241,11 +229,9 @@ export function _copyKeysDeep(keyMap: object, objectArray: NilOr<object[]>): Nil
|
|
|
241
229
|
export function _copyKeysDeep(keyMap: object): (objectArray: NilOr<object[]>) => NilOr<object[]>;
|
|
242
230
|
/**
|
|
243
231
|
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
* Failsafe status: alternative available
|
|
232
|
+
* The countBy function counts the number of items in an array that match the
|
|
247
233
|
*
|
|
248
|
-
*
|
|
234
|
+
* provided pattern.
|
|
249
235
|
*
|
|
250
236
|
* @example
|
|
251
237
|
*
|
|
@@ -264,11 +250,9 @@ export function _copyKeysDeep(keyMap: object): (objectArray: NilOr<object[]>) =>
|
|
|
264
250
|
export function countBy<T>(pattern: MatchPattern<T>, entityArray: T[]): number;
|
|
265
251
|
/**
|
|
266
252
|
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
* Failsafe status: alternative available
|
|
253
|
+
* The countBy function counts the number of items in an array that match the
|
|
270
254
|
*
|
|
271
|
-
*
|
|
255
|
+
* provided pattern.
|
|
272
256
|
*
|
|
273
257
|
* @example
|
|
274
258
|
*
|
|
@@ -289,11 +273,11 @@ export function _countBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>):
|
|
|
289
273
|
export function _countBy(pattern: MatchPattern): (entityArray: NilOr<object[]>) => NilOr<number>;
|
|
290
274
|
/**
|
|
291
275
|
*
|
|
292
|
-
*
|
|
276
|
+
* The deepFreezeObject function is used to make an object immutable by
|
|
293
277
|
*
|
|
294
|
-
*
|
|
278
|
+
* recursively freezing each property that is of type object. Freezing an object
|
|
295
279
|
*
|
|
296
|
-
*
|
|
280
|
+
* prevents any changes to its properties, making it effectively immutable.
|
|
297
281
|
*
|
|
298
282
|
* @example
|
|
299
283
|
*
|
|
@@ -315,7 +299,9 @@ export function _countBy(pattern: MatchPattern): (entityArray: NilOr<object[]>)
|
|
|
315
299
|
* };
|
|
316
300
|
*
|
|
317
301
|
* @endexample
|
|
318
|
-
* The assignment operation will throw the error only when we execute it in strict
|
|
302
|
+
* The assignment operation will throw the error only when we execute it in strict
|
|
303
|
+
*
|
|
304
|
+
* mode, in non-strict mode it will fail silently.
|
|
319
305
|
*
|
|
320
306
|
* @example
|
|
321
307
|
*
|
|
@@ -333,15 +319,15 @@ export function _countBy(pattern: MatchPattern): (entityArray: NilOr<object[]>)
|
|
|
333
319
|
export function deepFreezeObject<T>(object: T): Readonly<T>;
|
|
334
320
|
/**
|
|
335
321
|
*
|
|
336
|
-
*
|
|
322
|
+
* The dynamicArray function constructs an array of a specified length using a
|
|
337
323
|
*
|
|
338
|
-
*
|
|
324
|
+
* provided function to generate each element. The function takes the index as a
|
|
339
325
|
*
|
|
340
|
-
*
|
|
326
|
+
* parameter and is expected to return the element corresponding to that index.
|
|
341
327
|
*
|
|
342
|
-
*
|
|
328
|
+
* This function does not include a failsafe mechanism, so it is important to
|
|
343
329
|
*
|
|
344
|
-
*
|
|
330
|
+
* ensure that the provided function and length are valid to prevent errors.
|
|
345
331
|
*
|
|
346
332
|
* @example
|
|
347
333
|
*
|
|
@@ -353,13 +339,9 @@ export function deepFreezeObject<T>(object: T): Readonly<T>;
|
|
|
353
339
|
export function dynamicArray<T>(count: number, elementGenerator: (index: number) => T): T[];
|
|
354
340
|
/**
|
|
355
341
|
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
* Failsafe status: alternative available
|
|
342
|
+
* The existsBy function searches for an item in the array that matches the
|
|
359
343
|
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
* found, false otherwise.
|
|
344
|
+
* provided pattern and returns true if found, or false otherwise.
|
|
363
345
|
*
|
|
364
346
|
* @example
|
|
365
347
|
*
|
|
@@ -375,13 +357,9 @@ export function dynamicArray<T>(count: number, elementGenerator: (index: number)
|
|
|
375
357
|
export function existsBy<T>(pattern: MatchPattern<T>, entityArray: T[]): boolean;
|
|
376
358
|
/**
|
|
377
359
|
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
* Failsafe status: alternative available
|
|
381
|
-
*
|
|
382
|
-
* Search for an item that matches the given pattern in an array. Returns true if
|
|
360
|
+
* The existsBy function searches for an item in the array that matches the
|
|
383
361
|
*
|
|
384
|
-
* found, false otherwise.
|
|
362
|
+
* provided pattern and returns true if found, or false otherwise.
|
|
385
363
|
*
|
|
386
364
|
* @example
|
|
387
365
|
*
|
|
@@ -399,11 +377,9 @@ export function _existsBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>):
|
|
|
399
377
|
export function _existsBy(pattern: MatchPattern): (entityArray: NilOr<object[]>) => NilOr<boolean>;
|
|
400
378
|
/**
|
|
401
379
|
*
|
|
402
|
-
*
|
|
380
|
+
* The existsById function searches for an item in the provided array using the
|
|
403
381
|
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
* Search for an item in the given array using the given id.
|
|
382
|
+
* given id.
|
|
407
383
|
*
|
|
408
384
|
* @example
|
|
409
385
|
*
|
|
@@ -419,11 +395,9 @@ export function _existsBy(pattern: MatchPattern): (entityArray: NilOr<object[]>)
|
|
|
419
395
|
export function existsById(id: any, entityArray: object[]): boolean;
|
|
420
396
|
/**
|
|
421
397
|
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
* Failsafe status: alternative available
|
|
398
|
+
* The existsById function searches for an item in the provided array using the
|
|
425
399
|
*
|
|
426
|
-
*
|
|
400
|
+
* given id.
|
|
427
401
|
*
|
|
428
402
|
* @example
|
|
429
403
|
*
|
|
@@ -441,11 +415,7 @@ export function _existsById(id: any, entityArray: NilOr<object[]>): NilOr<boolea
|
|
|
441
415
|
export function _existsById(id: any): (entityArray: NilOr<object[]>) => NilOr<boolean>;
|
|
442
416
|
/**
|
|
443
417
|
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
* Failsafe status: alternative available
|
|
447
|
-
*
|
|
448
|
-
* Filter an array of items based on pattern matching.
|
|
418
|
+
* The filterBy function filters an array of items based on pattern matching.
|
|
449
419
|
*
|
|
450
420
|
* @example
|
|
451
421
|
*
|
|
@@ -464,11 +434,7 @@ export function _existsById(id: any): (entityArray: NilOr<object[]>) => NilOr<bo
|
|
|
464
434
|
export function filterBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T[];
|
|
465
435
|
/**
|
|
466
436
|
*
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
* Failsafe status: alternative available
|
|
470
|
-
*
|
|
471
|
-
* Filter an array of items based on pattern matching.
|
|
437
|
+
* The filterBy function filters an array of items based on pattern matching.
|
|
472
438
|
*
|
|
473
439
|
* @example
|
|
474
440
|
*
|
|
@@ -489,13 +455,13 @@ export function _filterBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>):
|
|
|
489
455
|
export function _filterBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
490
456
|
/**
|
|
491
457
|
*
|
|
492
|
-
*
|
|
458
|
+
* The filterNonNull function accepts an object and returns a new object with
|
|
493
459
|
*
|
|
494
|
-
*
|
|
460
|
+
* only the properties that are not null or undefined. It filters out
|
|
495
461
|
*
|
|
496
|
-
*
|
|
462
|
+
* properties with these values, creating a new object with only the non-null and
|
|
497
463
|
*
|
|
498
|
-
*
|
|
464
|
+
* non-undefined properties.
|
|
499
465
|
*
|
|
500
466
|
* @example
|
|
501
467
|
*
|
|
@@ -517,11 +483,9 @@ export function filterNonNull(object: object): object;
|
|
|
517
483
|
export function _filterNonNull(object: NilOr<object>): NilOr<object>;
|
|
518
484
|
/**
|
|
519
485
|
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
* Failsafe status: alternative available
|
|
486
|
+
* The findBy function locates the first item in the array that matches the
|
|
523
487
|
*
|
|
524
|
-
*
|
|
488
|
+
* provided pattern.
|
|
525
489
|
*
|
|
526
490
|
* @example
|
|
527
491
|
*
|
|
@@ -538,11 +502,9 @@ export function _filterNonNull(object: NilOr<object>): NilOr<object>;
|
|
|
538
502
|
export function findBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T;
|
|
539
503
|
/**
|
|
540
504
|
*
|
|
541
|
-
*
|
|
505
|
+
* The findBy function locates the first item in the array that matches the
|
|
542
506
|
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
* Find the first item that matches the given pattern from an array.
|
|
507
|
+
* provided pattern.
|
|
546
508
|
*
|
|
547
509
|
* @example
|
|
548
510
|
*
|
|
@@ -561,11 +523,9 @@ export function _findBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>): N
|
|
|
561
523
|
export function _findBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) => NilOr<T>;
|
|
562
524
|
/**
|
|
563
525
|
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
* Failsafe status: alternative available
|
|
526
|
+
* The findById function is used to locate an object within an array based on the
|
|
567
527
|
*
|
|
568
|
-
*
|
|
528
|
+
* provided Id.
|
|
569
529
|
*
|
|
570
530
|
* @example
|
|
571
531
|
*
|
|
@@ -582,11 +542,9 @@ export function _findBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) =>
|
|
|
582
542
|
export function findById<T>(id: any, entityArray: T[]): T;
|
|
583
543
|
/**
|
|
584
544
|
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
* Failsafe status: alternative available
|
|
545
|
+
* The findById function is used to locate an object within an array based on the
|
|
588
546
|
*
|
|
589
|
-
*
|
|
547
|
+
* provided Id.
|
|
590
548
|
*
|
|
591
549
|
* @example
|
|
592
550
|
*
|
|
@@ -605,11 +563,9 @@ export function _findById<T>(id: any, entityArray: NilOr<T[]>): NilOr<T>;
|
|
|
605
563
|
export function _findById(id: any): <T>(entityArray: NilOr<T[]>) => NilOr<T>;
|
|
606
564
|
/**
|
|
607
565
|
*
|
|
608
|
-
*
|
|
566
|
+
* The findIndexBy function finds the index of the item in the array that matches
|
|
609
567
|
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
* Find the index of an item that matches the pattern from the given array.
|
|
568
|
+
* the provided pattern.
|
|
613
569
|
*
|
|
614
570
|
* @example
|
|
615
571
|
*
|
|
@@ -626,11 +582,9 @@ export function _findById(id: any): <T>(entityArray: NilOr<T[]>) => NilOr<T>;
|
|
|
626
582
|
export function findIndexBy<T>(pattern: MatchPattern<T>, entityArray: T[]): number;
|
|
627
583
|
/**
|
|
628
584
|
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
* Failsafe status: alternative available
|
|
585
|
+
* The findIndexBy function finds the index of the item in the array that matches
|
|
632
586
|
*
|
|
633
|
-
*
|
|
587
|
+
* the provided pattern.
|
|
634
588
|
*
|
|
635
589
|
* @example
|
|
636
590
|
*
|
|
@@ -649,13 +603,9 @@ export function _findIndexBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]
|
|
|
649
603
|
export function _findIndexBy(pattern: MatchPattern): (entityArray: NilOr<object[]>) => NilOr<number>;
|
|
650
604
|
/**
|
|
651
605
|
*
|
|
652
|
-
*
|
|
606
|
+
* The findIndexById function is used to find the index of an item within an
|
|
653
607
|
*
|
|
654
|
-
*
|
|
655
|
-
*
|
|
656
|
-
* Find an index of an item from an array of items based on the id property of
|
|
657
|
-
*
|
|
658
|
-
* entities inside it.
|
|
608
|
+
* array of items based on the id property of the entities within it.
|
|
659
609
|
*
|
|
660
610
|
* @example
|
|
661
611
|
*
|
|
@@ -672,13 +622,9 @@ export function _findIndexBy(pattern: MatchPattern): (entityArray: NilOr<object[
|
|
|
672
622
|
export function findIndexById(id: any, entityArray: object[]): number;
|
|
673
623
|
/**
|
|
674
624
|
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
* Failsafe status: alternative available
|
|
625
|
+
* The findIndexById function is used to find the index of an item within an
|
|
678
626
|
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
* entities inside it.
|
|
627
|
+
* array of items based on the id property of the entities within it.
|
|
682
628
|
*
|
|
683
629
|
* @example
|
|
684
630
|
*
|
|
@@ -697,11 +643,9 @@ export function _findIndexById(id: any, entityArray: NilOr<object[]>): NilOr<num
|
|
|
697
643
|
export function _findIndexById(id: any): (entityArray: NilOr<object[]>) => NilOr<number>;
|
|
698
644
|
/**
|
|
699
645
|
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
* Failsafe status: alternative available
|
|
646
|
+
* The findLastBy function finds the last item in the array that matches the
|
|
703
647
|
*
|
|
704
|
-
*
|
|
648
|
+
* provided pattern.
|
|
705
649
|
*
|
|
706
650
|
* @example
|
|
707
651
|
*
|
|
@@ -719,11 +663,9 @@ export function _findIndexById(id: any): (entityArray: NilOr<object[]>) => NilOr
|
|
|
719
663
|
export function findLastBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T;
|
|
720
664
|
/**
|
|
721
665
|
*
|
|
722
|
-
*
|
|
666
|
+
* The findLastBy function finds the last item in the array that matches the
|
|
723
667
|
*
|
|
724
|
-
*
|
|
725
|
-
*
|
|
726
|
-
* Find the last item that matches the given pattern.
|
|
668
|
+
* provided pattern.
|
|
727
669
|
*
|
|
728
670
|
* @example
|
|
729
671
|
*
|
|
@@ -743,11 +685,9 @@ export function _findLastBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>
|
|
|
743
685
|
export function _findLastBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) => NilOr<T>;
|
|
744
686
|
/**
|
|
745
687
|
*
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
* Failsafe status: alternative available
|
|
688
|
+
* The findLastIndexBy function finds the last index of an item in the array that
|
|
749
689
|
*
|
|
750
|
-
*
|
|
690
|
+
* matches the provided pattern.
|
|
751
691
|
*
|
|
752
692
|
* @example
|
|
753
693
|
*
|
|
@@ -765,11 +705,9 @@ export function _findLastBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>)
|
|
|
765
705
|
export function findLastIndexBy(id: any, entityArray: object[]): number;
|
|
766
706
|
/**
|
|
767
707
|
*
|
|
768
|
-
*
|
|
769
|
-
*
|
|
770
|
-
* Failsafe status: alternative available
|
|
708
|
+
* The findLastIndexBy function finds the last index of an item in the array that
|
|
771
709
|
*
|
|
772
|
-
*
|
|
710
|
+
* matches the provided pattern.
|
|
773
711
|
*
|
|
774
712
|
* @example
|
|
775
713
|
*
|
|
@@ -789,11 +727,11 @@ export function _findLastIndexBy(id: any, entityArray: NilOr<object[]>): NilOr<n
|
|
|
789
727
|
export function _findLastIndexBy(id: any): (entityArray: NilOr<object[]>) => NilOr<number>;
|
|
790
728
|
/**
|
|
791
729
|
*
|
|
792
|
-
*
|
|
730
|
+
* The getRandomInt function generates a random integer within a specified range.
|
|
793
731
|
*
|
|
794
|
-
*
|
|
732
|
+
* If only one argument is provided, it is considered as the upper bound, and the
|
|
795
733
|
*
|
|
796
|
-
*
|
|
734
|
+
* lower bound is assumed to be 0.
|
|
797
735
|
*
|
|
798
736
|
* @example
|
|
799
737
|
*
|
|
@@ -805,13 +743,9 @@ export function _findLastIndexBy(id: any): (entityArray: NilOr<object[]>) => Nil
|
|
|
805
743
|
export function getRandomInt(a?: number, b?: number): number;
|
|
806
744
|
/**
|
|
807
745
|
*
|
|
808
|
-
*
|
|
809
|
-
*
|
|
810
|
-
* Failsafe status: alternative available
|
|
811
|
-
*
|
|
812
|
-
* Converts common developer friendly string formats (camelCase, snake_case,
|
|
746
|
+
* The humanize function converts common developer-friendly string formats such
|
|
813
747
|
*
|
|
814
|
-
* dash-case etc
|
|
748
|
+
* as camelCase, snake_case, dash-case, etc., into human-readable strings.
|
|
815
749
|
*
|
|
816
750
|
* @example
|
|
817
751
|
*
|
|
@@ -823,35 +757,137 @@ export function getRandomInt(a?: number, b?: number): number;
|
|
|
823
757
|
*/
|
|
824
758
|
export function humanize(string: string): string;
|
|
825
759
|
export function _humanize(string: NilOr<string>): NilOr<string>;
|
|
760
|
+
/**
|
|
761
|
+
*
|
|
762
|
+
* The isNot function returns true if the given values (or references) are not
|
|
763
|
+
*
|
|
764
|
+
* equal and false otherwise. It provides the opposite behavior of the
|
|
765
|
+
*
|
|
766
|
+
* Object.is() method.
|
|
767
|
+
*
|
|
768
|
+
* The primary difference between isNot() and !== is that isNot() is a
|
|
769
|
+
*
|
|
770
|
+
* curried function, which means you can partially apply it to create a new
|
|
771
|
+
*
|
|
772
|
+
* function that's pre-configured to compare one value against another value
|
|
773
|
+
*
|
|
774
|
+
* repeatedly.
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
*
|
|
778
|
+
* const value1 = 10;
|
|
779
|
+
* const isNotValue1 = isNot(value1);
|
|
780
|
+
* const value2 = 20;
|
|
781
|
+
* isNotValue1(value2); // true
|
|
782
|
+
*
|
|
783
|
+
* // Filter out fruits that are not Apple
|
|
784
|
+
* const fruits = ["Apple", "Orange", "Lemon"];
|
|
785
|
+
* fruits.filter(notEquals("Apple")); // ["Orange", "Lemon"];
|
|
786
|
+
* @endexample
|
|
787
|
+
*/
|
|
826
788
|
export function isNot(a: any, b: any): boolean;
|
|
789
|
+
/**
|
|
790
|
+
*
|
|
791
|
+
* The isNot function returns true if the given values (or references) are not
|
|
792
|
+
*
|
|
793
|
+
* equal and false otherwise. It provides the opposite behavior of the
|
|
794
|
+
*
|
|
795
|
+
* Object.is() method.
|
|
796
|
+
*
|
|
797
|
+
* The primary difference between isNot() and !== is that isNot() is a
|
|
798
|
+
*
|
|
799
|
+
* curried function, which means you can partially apply it to create a new
|
|
800
|
+
*
|
|
801
|
+
* function that's pre-configured to compare one value against another value
|
|
802
|
+
*
|
|
803
|
+
* repeatedly.
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
*
|
|
807
|
+
* const value1 = 10;
|
|
808
|
+
* const isNotValue1 = isNot(value1);
|
|
809
|
+
* const value2 = 20;
|
|
810
|
+
* isNotValue1(value2); // true
|
|
811
|
+
*
|
|
812
|
+
* // Filter out fruits that are not Apple
|
|
813
|
+
* const fruits = ["Apple", "Orange", "Lemon"];
|
|
814
|
+
* fruits.filter(notEquals("Apple")); // ["Orange", "Lemon"];
|
|
815
|
+
* @endexample
|
|
816
|
+
*/
|
|
827
817
|
export function isNot(a: any): (b: any) => boolean;
|
|
828
818
|
/**
|
|
829
819
|
*
|
|
830
|
-
*
|
|
820
|
+
* The isNotEmpty returns true if the given value is not empty (includes
|
|
831
821
|
*
|
|
832
|
-
*
|
|
822
|
+
* strings, arrays, objects) and false otherwise. It provides the opposite
|
|
833
823
|
*
|
|
834
|
-
*
|
|
824
|
+
* behavior of checking if a value is empty, similar to the isEmpty function in
|
|
835
825
|
*
|
|
836
|
-
*
|
|
826
|
+
* Ramda.
|
|
837
827
|
*
|
|
838
828
|
* @example
|
|
839
829
|
*
|
|
840
830
|
* isNotEmpty(""); // returns false
|
|
841
831
|
* isNotEmpty(["a"]); // returns true
|
|
842
|
-
*
|
|
832
|
+
* isNotEmpty({ name: "Oliver" }); //return true
|
|
843
833
|
* @endexample
|
|
844
834
|
*/
|
|
845
835
|
export const isNotEmpty: (a: any) => boolean;
|
|
836
|
+
/**
|
|
837
|
+
*
|
|
838
|
+
* The isNotEqualDeep function returns true if the given values are not equal,
|
|
839
|
+
*
|
|
840
|
+
* considering deep equality. It checks for deep inequality between objects or
|
|
841
|
+
*
|
|
842
|
+
* arrays.
|
|
843
|
+
*
|
|
844
|
+
* @example
|
|
845
|
+
*
|
|
846
|
+
* const object1 = {
|
|
847
|
+
* a: 1,
|
|
848
|
+
* b: { c: 3 },
|
|
849
|
+
* };
|
|
850
|
+
*
|
|
851
|
+
* const object2 = {
|
|
852
|
+
* a: 1,
|
|
853
|
+
* b: { c: 2 },
|
|
854
|
+
* };
|
|
855
|
+
*
|
|
856
|
+
* isNotEqualsDeep(object1, object2); //returns true
|
|
857
|
+
* notEqualsDeep(object1, object2); //returns true
|
|
858
|
+
* @endexample
|
|
859
|
+
*/
|
|
846
860
|
export function isNotEqualDeep(a: any, b: any): boolean;
|
|
847
|
-
export function isNotEqualDeep(a: any): (b: any) => boolean;
|
|
848
861
|
/**
|
|
849
862
|
*
|
|
850
|
-
*
|
|
863
|
+
* The isNotEqualDeep function returns true if the given values are not equal,
|
|
851
864
|
*
|
|
852
|
-
*
|
|
865
|
+
* considering deep equality. It checks for deep inequality between objects or
|
|
853
866
|
*
|
|
854
|
-
*
|
|
867
|
+
* arrays.
|
|
868
|
+
*
|
|
869
|
+
* @example
|
|
870
|
+
*
|
|
871
|
+
* const object1 = {
|
|
872
|
+
* a: 1,
|
|
873
|
+
* b: { c: 3 },
|
|
874
|
+
* };
|
|
875
|
+
*
|
|
876
|
+
* const object2 = {
|
|
877
|
+
* a: 1,
|
|
878
|
+
* b: { c: 2 },
|
|
879
|
+
* };
|
|
880
|
+
*
|
|
881
|
+
* isNotEqualsDeep(object1, object2); //returns true
|
|
882
|
+
* notEqualsDeep(object1, object2); //returns true
|
|
883
|
+
* @endexample
|
|
884
|
+
*/
|
|
885
|
+
export function isNotEqualDeep(a: any): (b: any) => boolean;
|
|
886
|
+
/**
|
|
887
|
+
*
|
|
888
|
+
* The keysToCamelCase function recursively converts the snake-cased object keys
|
|
889
|
+
*
|
|
890
|
+
* to camel case.
|
|
855
891
|
*
|
|
856
892
|
* @example
|
|
857
893
|
*
|
|
@@ -872,11 +908,9 @@ export function isNotEqualDeep(a: any): (b: any) => boolean;
|
|
|
872
908
|
export function keysToCamelCase(object: any): any;
|
|
873
909
|
/**
|
|
874
910
|
*
|
|
875
|
-
*
|
|
911
|
+
* The keysToSnakeCase function recursively converts the camel-cased object keys
|
|
876
912
|
*
|
|
877
|
-
*
|
|
878
|
-
*
|
|
879
|
-
* Recursively converts the camel cased object keys to snake case.
|
|
913
|
+
* to snake case.
|
|
880
914
|
*
|
|
881
915
|
* @example
|
|
882
916
|
*
|
|
@@ -897,11 +931,13 @@ export function keysToCamelCase(object: any): any;
|
|
|
897
931
|
export function keysToSnakeCase(object: any): any;
|
|
898
932
|
/**
|
|
899
933
|
*
|
|
900
|
-
*
|
|
934
|
+
* The matches function checks whether the given object matches the given
|
|
935
|
+
*
|
|
936
|
+
* pattern. It compares the primitive value (int, boolean, string, etc.) in the
|
|
901
937
|
*
|
|
902
|
-
*
|
|
938
|
+
* object with the corresponding values in the pattern (deeply) and checks if all
|
|
903
939
|
*
|
|
904
|
-
*
|
|
940
|
+
* conditions (functions) are satisfied for a match.
|
|
905
941
|
*
|
|
906
942
|
* @example
|
|
907
943
|
*
|
|
@@ -928,11 +964,13 @@ export function keysToSnakeCase(object: any): any;
|
|
|
928
964
|
export function matches<T>(pattern: MatchPattern<T>, data: T): boolean;
|
|
929
965
|
/**
|
|
930
966
|
*
|
|
931
|
-
*
|
|
967
|
+
* The matches function checks whether the given object matches the given
|
|
932
968
|
*
|
|
933
|
-
*
|
|
969
|
+
* pattern. It compares the primitive value (int, boolean, string, etc.) in the
|
|
934
970
|
*
|
|
935
|
-
*
|
|
971
|
+
* object with the corresponding values in the pattern (deeply) and checks if all
|
|
972
|
+
*
|
|
973
|
+
* conditions (functions) are satisfied for a match.
|
|
936
974
|
*
|
|
937
975
|
* @example
|
|
938
976
|
*
|
|
@@ -959,13 +997,9 @@ export function matches<T>(pattern: MatchPattern<T>, data: T): boolean;
|
|
|
959
997
|
export function matches(pattern: MatchPattern): (data: any) => boolean;
|
|
960
998
|
/**
|
|
961
999
|
*
|
|
962
|
-
*
|
|
963
|
-
*
|
|
964
|
-
* Failsafe status: alternative available
|
|
965
|
-
*
|
|
966
|
-
* Modify all items using modifier function based on a pattern passed as an
|
|
1000
|
+
* The modifyBy function modifies all items in the array that match the provided
|
|
967
1001
|
*
|
|
968
|
-
*
|
|
1002
|
+
* pattern using the given modifier function.
|
|
969
1003
|
*
|
|
970
1004
|
* @example
|
|
971
1005
|
*
|
|
@@ -984,13 +1018,9 @@ export function matches(pattern: MatchPattern): (data: any) => boolean;
|
|
|
984
1018
|
export function modifyBy<T>(pattern: MatchPattern<T>, modifier: (previous: T) => T, entityArray: T[]): T[];
|
|
985
1019
|
/**
|
|
986
1020
|
*
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
* Failsafe status: alternative available
|
|
990
|
-
*
|
|
991
|
-
* Modify all items using modifier function based on a pattern passed as an
|
|
1021
|
+
* The modifyBy function modifies all items in the array that match the provided
|
|
992
1022
|
*
|
|
993
|
-
*
|
|
1023
|
+
* pattern using the given modifier function.
|
|
994
1024
|
*
|
|
995
1025
|
* @example
|
|
996
1026
|
*
|
|
@@ -1009,13 +1039,9 @@ export function modifyBy<T>(pattern: MatchPattern<T>, modifier: (previous: T) =>
|
|
|
1009
1039
|
export function modifyBy<T>(pattern: MatchPattern<T>, modifier: (previous: T) => T): (entityArray: T[]) => T[];
|
|
1010
1040
|
/**
|
|
1011
1041
|
*
|
|
1012
|
-
*
|
|
1042
|
+
* The modifyBy function modifies all items in the array that match the provided
|
|
1013
1043
|
*
|
|
1014
|
-
*
|
|
1015
|
-
*
|
|
1016
|
-
* Modify all items using modifier function based on a pattern passed as an
|
|
1017
|
-
*
|
|
1018
|
-
* argument to the function.
|
|
1044
|
+
* pattern using the given modifier function.
|
|
1019
1045
|
*
|
|
1020
1046
|
* @example
|
|
1021
1047
|
*
|
|
@@ -1034,13 +1060,9 @@ export function modifyBy<T>(pattern: MatchPattern<T>, modifier: (previous: T) =>
|
|
|
1034
1060
|
export function modifyBy(pattern: MatchPattern): <T>(modifier: (previous: T) => T, entityArray: T[]) => T[];
|
|
1035
1061
|
/**
|
|
1036
1062
|
*
|
|
1037
|
-
*
|
|
1038
|
-
*
|
|
1039
|
-
* Failsafe status: alternative available
|
|
1063
|
+
* The modifyBy function modifies all items in the array that match the provided
|
|
1040
1064
|
*
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
1043
|
-
* argument to the function.
|
|
1065
|
+
* pattern using the given modifier function.
|
|
1044
1066
|
*
|
|
1045
1067
|
* @example
|
|
1046
1068
|
*
|
|
@@ -1063,15 +1085,11 @@ export function _modifyBy(pattern: MatchPattern): <T>(modifier: (previous: T) =>
|
|
|
1063
1085
|
export function _modifyBy(pattern: MatchPattern): <T>(modifier: (previous: T) => T) => (entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1064
1086
|
/**
|
|
1065
1087
|
*
|
|
1066
|
-
*
|
|
1067
|
-
*
|
|
1068
|
-
* Failsafe status: alternative available
|
|
1088
|
+
* The modifyById function applies a modifier function to the item with the
|
|
1069
1089
|
*
|
|
1070
|
-
*
|
|
1090
|
+
* specified id in an array and returns a new array with the modified item in the
|
|
1071
1091
|
*
|
|
1072
|
-
*
|
|
1073
|
-
*
|
|
1074
|
-
* of the match.
|
|
1092
|
+
* same index.
|
|
1075
1093
|
*
|
|
1076
1094
|
* @example
|
|
1077
1095
|
*
|
|
@@ -1091,15 +1109,11 @@ export function _modifyBy(pattern: MatchPattern): <T>(modifier: (previous: T) =>
|
|
|
1091
1109
|
export function modifyById<T>(id: any, modifier: (previous: T) => T, entityArray: T[]): T[];
|
|
1092
1110
|
/**
|
|
1093
1111
|
*
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1096
|
-
* Failsafe status: alternative available
|
|
1097
|
-
*
|
|
1098
|
-
* Applies the modifier function on the item having the given id in an array and
|
|
1112
|
+
* The modifyById function applies a modifier function to the item with the
|
|
1099
1113
|
*
|
|
1100
|
-
* returns a new array with the
|
|
1114
|
+
* specified id in an array and returns a new array with the modified item in the
|
|
1101
1115
|
*
|
|
1102
|
-
*
|
|
1116
|
+
* same index.
|
|
1103
1117
|
*
|
|
1104
1118
|
* @example
|
|
1105
1119
|
*
|
|
@@ -1119,15 +1133,11 @@ export function modifyById<T>(id: any, modifier: (previous: T) => T, entityArray
|
|
|
1119
1133
|
export function modifyById<T>(id: any, modifier: (previous: T) => T): (entityArray: T[]) => T[];
|
|
1120
1134
|
/**
|
|
1121
1135
|
*
|
|
1122
|
-
*
|
|
1123
|
-
*
|
|
1124
|
-
* Failsafe status: alternative available
|
|
1125
|
-
*
|
|
1126
|
-
* Applies the modifier function on the item having the given id in an array and
|
|
1136
|
+
* The modifyById function applies a modifier function to the item with the
|
|
1127
1137
|
*
|
|
1128
|
-
* returns a new array with the
|
|
1138
|
+
* specified id in an array and returns a new array with the modified item in the
|
|
1129
1139
|
*
|
|
1130
|
-
*
|
|
1140
|
+
* same index.
|
|
1131
1141
|
*
|
|
1132
1142
|
* @example
|
|
1133
1143
|
*
|
|
@@ -1147,15 +1157,11 @@ export function modifyById<T>(id: any, modifier: (previous: T) => T): (entityArr
|
|
|
1147
1157
|
export function modifyById(id: any): <T>(modifier: (previous: T) => T, entityArray: T[]) => T[];
|
|
1148
1158
|
/**
|
|
1149
1159
|
*
|
|
1150
|
-
*
|
|
1160
|
+
* The modifyById function applies a modifier function to the item with the
|
|
1151
1161
|
*
|
|
1152
|
-
*
|
|
1162
|
+
* specified id in an array and returns a new array with the modified item in the
|
|
1153
1163
|
*
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1156
|
-
* returns a new array with the return value of the modifier function in the index
|
|
1157
|
-
*
|
|
1158
|
-
* of the match.
|
|
1164
|
+
* same index.
|
|
1159
1165
|
*
|
|
1160
1166
|
* @example
|
|
1161
1167
|
*
|
|
@@ -1179,11 +1185,11 @@ export function _modifyById(id: any): <T>(modifier: (previous: T) => T, entityAr
|
|
|
1179
1185
|
export function _modifyById(id: any): <T>(modifier: (previous: T) => T) => (entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1180
1186
|
/**
|
|
1181
1187
|
*
|
|
1182
|
-
*
|
|
1188
|
+
* The noop function is a "no-operation" function that does nothing when called and
|
|
1183
1189
|
*
|
|
1184
|
-
*
|
|
1190
|
+
* returns undefined. It is often used as a placeholder or a default function
|
|
1185
1191
|
*
|
|
1186
|
-
*
|
|
1192
|
+
* when a function is expected but no action is required.
|
|
1187
1193
|
*
|
|
1188
1194
|
*/
|
|
1189
1195
|
export function noop(...args: any[]): void;
|
|
@@ -1193,13 +1199,11 @@ export function notEqualsDeep(a: any, b: any): boolean;
|
|
|
1193
1199
|
export function notEqualsDeep(a: any): (b: any) => boolean;
|
|
1194
1200
|
/**
|
|
1195
1201
|
*
|
|
1196
|
-
*
|
|
1197
|
-
*
|
|
1198
|
-
* Failsafe status: not failsafe
|
|
1202
|
+
* The randomPick function accepts a variable number of arguments and returns a
|
|
1199
1203
|
*
|
|
1200
|
-
*
|
|
1204
|
+
* random element from the list of arguments. It randomly selects one of the
|
|
1201
1205
|
*
|
|
1202
|
-
*
|
|
1206
|
+
* provided values and returns it.
|
|
1203
1207
|
*
|
|
1204
1208
|
* @example
|
|
1205
1209
|
*
|
|
@@ -1211,11 +1215,9 @@ export function notEqualsDeep(a: any): (b: any) => boolean;
|
|
|
1211
1215
|
export function randomPick<T>(...args: T[]): T;
|
|
1212
1216
|
/**
|
|
1213
1217
|
*
|
|
1214
|
-
*
|
|
1218
|
+
* The removeBy function removes all items in the array that match the provided
|
|
1215
1219
|
*
|
|
1216
|
-
*
|
|
1217
|
-
*
|
|
1218
|
-
* Remove all items that matches the given pattern from an array of items.
|
|
1220
|
+
* pattern.
|
|
1219
1221
|
*
|
|
1220
1222
|
* @example
|
|
1221
1223
|
*
|
|
@@ -1232,11 +1234,9 @@ export function randomPick<T>(...args: T[]): T;
|
|
|
1232
1234
|
export function removeBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T[];
|
|
1233
1235
|
/**
|
|
1234
1236
|
*
|
|
1235
|
-
*
|
|
1236
|
-
*
|
|
1237
|
-
* Failsafe status: alternative available
|
|
1237
|
+
* The removeBy function removes all items in the array that match the provided
|
|
1238
1238
|
*
|
|
1239
|
-
*
|
|
1239
|
+
* pattern.
|
|
1240
1240
|
*
|
|
1241
1241
|
* @example
|
|
1242
1242
|
*
|
|
@@ -1255,11 +1255,9 @@ export function _removeBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>):
|
|
|
1255
1255
|
export function _removeBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1256
1256
|
/**
|
|
1257
1257
|
*
|
|
1258
|
-
*
|
|
1258
|
+
* The removeById function generates a new array with the item possessing the
|
|
1259
1259
|
*
|
|
1260
|
-
*
|
|
1261
|
-
*
|
|
1262
|
-
* Return a new array with the item with the given id removed.
|
|
1260
|
+
* specified id removed.
|
|
1263
1261
|
*
|
|
1264
1262
|
* @example
|
|
1265
1263
|
*
|
|
@@ -1276,11 +1274,9 @@ export function _removeBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) =
|
|
|
1276
1274
|
export function removeById<T>(id: any, entityArray: T[]): T[];
|
|
1277
1275
|
/**
|
|
1278
1276
|
*
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
1281
|
-
* Failsafe status: alternative available
|
|
1277
|
+
* The removeById function generates a new array with the item possessing the
|
|
1282
1278
|
*
|
|
1283
|
-
*
|
|
1279
|
+
* specified id removed.
|
|
1284
1280
|
*
|
|
1285
1281
|
* @example
|
|
1286
1282
|
*
|
|
@@ -1299,13 +1295,11 @@ export function _removeById<T>(id: any, entityArray: NilOr<T[]>): NilOr<T[]>;
|
|
|
1299
1295
|
export function _removeById(id: any): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1300
1296
|
/**
|
|
1301
1297
|
*
|
|
1302
|
-
*
|
|
1298
|
+
* The renameKeys function renames specified keys in each object of an array
|
|
1303
1299
|
*
|
|
1304
|
-
*
|
|
1300
|
+
* while keeping their values the same. It creates a new instance and does not
|
|
1305
1301
|
*
|
|
1306
|
-
*
|
|
1307
|
-
*
|
|
1308
|
-
* array. This creates a new instance and doesn't mutate the array.
|
|
1302
|
+
* mutate the original array.
|
|
1309
1303
|
*
|
|
1310
1304
|
* @example
|
|
1311
1305
|
*
|
|
@@ -1330,13 +1324,11 @@ export function renameKeys<T, M extends { [key in keyof Partial<T>]: string }>(k
|
|
|
1330
1324
|
})[];
|
|
1331
1325
|
/**
|
|
1332
1326
|
*
|
|
1333
|
-
*
|
|
1334
|
-
*
|
|
1335
|
-
* Failsafe status: alternative available
|
|
1327
|
+
* The renameKeys function renames specified keys in each object of an array
|
|
1336
1328
|
*
|
|
1337
|
-
*
|
|
1329
|
+
* while keeping their values the same. It creates a new instance and does not
|
|
1338
1330
|
*
|
|
1339
|
-
*
|
|
1331
|
+
* mutate the original array.
|
|
1340
1332
|
*
|
|
1341
1333
|
* @example
|
|
1342
1334
|
*
|
|
@@ -1371,11 +1363,9 @@ export function _renameKeys<M extends {
|
|
|
1371
1363
|
})[]>;
|
|
1372
1364
|
/**
|
|
1373
1365
|
*
|
|
1374
|
-
*
|
|
1366
|
+
* The replaceBy function replaces all items in the array that match the provided
|
|
1375
1367
|
*
|
|
1376
|
-
*
|
|
1377
|
-
*
|
|
1378
|
-
* Replace all items that matches the given pattern with the given item.
|
|
1368
|
+
* pattern with the given item.
|
|
1379
1369
|
*
|
|
1380
1370
|
* @example
|
|
1381
1371
|
*
|
|
@@ -1394,11 +1384,9 @@ export function _renameKeys<M extends {
|
|
|
1394
1384
|
export function replaceBy<T>(pattern: MatchPattern<T>, entity: T, entityArray: T[]): T[];
|
|
1395
1385
|
/**
|
|
1396
1386
|
*
|
|
1397
|
-
*
|
|
1398
|
-
*
|
|
1399
|
-
* Failsafe status: alternative available
|
|
1387
|
+
* The replaceBy function replaces all items in the array that match the provided
|
|
1400
1388
|
*
|
|
1401
|
-
*
|
|
1389
|
+
* pattern with the given item.
|
|
1402
1390
|
*
|
|
1403
1391
|
* @example
|
|
1404
1392
|
*
|
|
@@ -1417,11 +1405,9 @@ export function replaceBy<T>(pattern: MatchPattern<T>, entity: T, entityArray: T
|
|
|
1417
1405
|
export function replaceBy<T>(pattern: MatchPattern<T>, entity: T): <T>(entityArray: T[]) => T[];
|
|
1418
1406
|
/**
|
|
1419
1407
|
*
|
|
1420
|
-
*
|
|
1421
|
-
*
|
|
1422
|
-
* Failsafe status: alternative available
|
|
1408
|
+
* The replaceBy function replaces all items in the array that match the provided
|
|
1423
1409
|
*
|
|
1424
|
-
*
|
|
1410
|
+
* pattern with the given item.
|
|
1425
1411
|
*
|
|
1426
1412
|
* @example
|
|
1427
1413
|
*
|
|
@@ -1443,13 +1429,9 @@ export function _replaceBy<T>(pattern: MatchPattern<T>, entity: NilOr<T>): <T>(e
|
|
|
1443
1429
|
export function _replaceBy(pattern: MatchPattern): <T>(entity: NilOr<T>) => <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1444
1430
|
/**
|
|
1445
1431
|
*
|
|
1446
|
-
*
|
|
1447
|
-
*
|
|
1448
|
-
* Failsafe status: alternative available
|
|
1449
|
-
*
|
|
1450
|
-
* Returns a new array with the item having the given id is replaced with the given
|
|
1432
|
+
* The replaceById function returns a new array with the item having the
|
|
1451
1433
|
*
|
|
1452
|
-
* object.
|
|
1434
|
+
* specified id replaced by the provided object.
|
|
1453
1435
|
*
|
|
1454
1436
|
* @example
|
|
1455
1437
|
*
|
|
@@ -1469,13 +1451,9 @@ export function _replaceBy(pattern: MatchPattern): <T>(entity: NilOr<T>) => <T>(
|
|
|
1469
1451
|
export function replaceById<T>(id: any, entity: T, entityArray: T[]): T[];
|
|
1470
1452
|
/**
|
|
1471
1453
|
*
|
|
1472
|
-
*
|
|
1454
|
+
* The replaceById function returns a new array with the item having the
|
|
1473
1455
|
*
|
|
1474
|
-
*
|
|
1475
|
-
*
|
|
1476
|
-
* Returns a new array with the item having the given id is replaced with the given
|
|
1477
|
-
*
|
|
1478
|
-
* object.
|
|
1456
|
+
* specified id replaced by the provided object.
|
|
1479
1457
|
*
|
|
1480
1458
|
* @example
|
|
1481
1459
|
*
|
|
@@ -1495,13 +1473,9 @@ export function replaceById<T>(id: any, entity: T, entityArray: T[]): T[];
|
|
|
1495
1473
|
export function replaceById<T>(id: any, entity: T): <T>(entityArray: T[]) => T[];
|
|
1496
1474
|
/**
|
|
1497
1475
|
*
|
|
1498
|
-
*
|
|
1499
|
-
*
|
|
1500
|
-
* Failsafe status: alternative available
|
|
1476
|
+
* The replaceById function returns a new array with the item having the
|
|
1501
1477
|
*
|
|
1502
|
-
*
|
|
1503
|
-
*
|
|
1504
|
-
* object.
|
|
1478
|
+
* specified id replaced by the provided object.
|
|
1505
1479
|
*
|
|
1506
1480
|
* @example
|
|
1507
1481
|
*
|
|
@@ -1524,13 +1498,17 @@ export function _replaceById<T>(id: any, entity: NilOr<T>): <T>(entityArray: Nil
|
|
|
1524
1498
|
export function _replaceById(id: any): <T>(entity: NilOr<T>) => <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1525
1499
|
/**
|
|
1526
1500
|
*
|
|
1527
|
-
*
|
|
1501
|
+
* The serializeKeysToSnakeCase function recursively converts the camel-cased
|
|
1502
|
+
*
|
|
1503
|
+
* object keys to snake case. It gracefully handles special objects like Date and
|
|
1528
1504
|
*
|
|
1529
|
-
*
|
|
1505
|
+
* dayjs instances. Additionally, while converting, this function checks if the
|
|
1530
1506
|
*
|
|
1531
|
-
*
|
|
1507
|
+
* value being processed is an object and if it has a toJSON function. If the
|
|
1532
1508
|
*
|
|
1533
|
-
*
|
|
1509
|
+
* toJSON function is present, it calls the function and uses the return value
|
|
1510
|
+
*
|
|
1511
|
+
* for further processing.
|
|
1534
1512
|
*
|
|
1535
1513
|
* Example 1:
|
|
1536
1514
|
*
|
|
@@ -1568,23 +1546,27 @@ export function _replaceById(id: any): <T>(entity: NilOr<T>) => <T>(entityArray:
|
|
|
1568
1546
|
* }
|
|
1569
1547
|
*
|
|
1570
1548
|
* @endexample
|
|
1571
|
-
* In the above example, the value of dob is an date object and has toJSON
|
|
1549
|
+
* In the above example, the value of dob is an date object and has toJSON
|
|
1550
|
+
*
|
|
1551
|
+
* method present in it. The toJSON method returns the date in ISO format which
|
|
1552
|
+
*
|
|
1553
|
+
* will be used for further processing instead of recursively converting the
|
|
1554
|
+
*
|
|
1555
|
+
* original date object.
|
|
1572
1556
|
*
|
|
1573
1557
|
*/
|
|
1574
1558
|
export function serializeKeysToSnakeCase(object: object): object;
|
|
1575
1559
|
/**
|
|
1576
1560
|
*
|
|
1577
|
-
*
|
|
1578
|
-
*
|
|
1579
|
-
* Failsafe status: failsafe by default
|
|
1561
|
+
* The preprocessForSerialization function creates a ready-to-be-serialized
|
|
1580
1562
|
*
|
|
1581
|
-
*
|
|
1563
|
+
* version of the given object by recursively traversing all the object properties
|
|
1582
1564
|
*
|
|
1583
|
-
*
|
|
1565
|
+
* and replacing them with their JSON serializable versions. This is particularly
|
|
1584
1566
|
*
|
|
1585
|
-
*
|
|
1567
|
+
* helpful when serializing objects that include non-serializable data types, such
|
|
1586
1568
|
*
|
|
1587
|
-
*
|
|
1569
|
+
* as Date objects, dayjs objects or custom classes.
|
|
1588
1570
|
*
|
|
1589
1571
|
* @example
|
|
1590
1572
|
*
|
|
@@ -1597,11 +1579,15 @@ export function serializeKeysToSnakeCase(object: object): object;
|
|
|
1597
1579
|
export function preprocessForSerialization(object: object): object;
|
|
1598
1580
|
/**
|
|
1599
1581
|
*
|
|
1600
|
-
*
|
|
1582
|
+
* The slugify function converts a given string into a slug. A slug is a
|
|
1601
1583
|
*
|
|
1602
|
-
*
|
|
1584
|
+
* URL-friendly representation of a string, typically used for creating
|
|
1603
1585
|
*
|
|
1604
|
-
*
|
|
1586
|
+
* human-readable and SEO-friendly URLs. This function transforms a string by
|
|
1587
|
+
*
|
|
1588
|
+
* removing spaces, special characters, and converting it to lowercase to create a
|
|
1589
|
+
*
|
|
1590
|
+
* valid slug.
|
|
1605
1591
|
*
|
|
1606
1592
|
* @example
|
|
1607
1593
|
*
|
|
@@ -1616,11 +1602,7 @@ export function slugify(string: string): string;
|
|
|
1616
1602
|
export function _slugify(string: NilOr<string>): NilOr<string>;
|
|
1617
1603
|
/**
|
|
1618
1604
|
*
|
|
1619
|
-
*
|
|
1620
|
-
*
|
|
1621
|
-
* Failsafe status: alternative available
|
|
1622
|
-
*
|
|
1623
|
-
* Converts snake_case string to camelCase.
|
|
1605
|
+
* The snakeToCamelCase function converts a snake_case string to camelCase.
|
|
1624
1606
|
*
|
|
1625
1607
|
* @example
|
|
1626
1608
|
*
|
|
@@ -1631,13 +1613,11 @@ export function snakeToCamelCase(string: string): string;
|
|
|
1631
1613
|
export function _snakeToCamelCase(string: NilOr<string>): NilOr<string>;
|
|
1632
1614
|
/**
|
|
1633
1615
|
*
|
|
1634
|
-
*
|
|
1616
|
+
* The toLabelAndValue function takes a string as an argument and returns an
|
|
1635
1617
|
*
|
|
1636
|
-
*
|
|
1618
|
+
* object with keys "label" and "value." It is often used to transform a string
|
|
1637
1619
|
*
|
|
1638
|
-
*
|
|
1639
|
-
*
|
|
1640
|
-
* "label" and "value".
|
|
1620
|
+
* into an object with specific key-value pairs.
|
|
1641
1621
|
*
|
|
1642
1622
|
* @example
|
|
1643
1623
|
*
|
|
@@ -1652,15 +1632,13 @@ export function toLabelAndValue(string: string): {
|
|
|
1652
1632
|
};
|
|
1653
1633
|
/**
|
|
1654
1634
|
*
|
|
1655
|
-
*
|
|
1656
|
-
*
|
|
1657
|
-
* Failsafe status: failsafe by default
|
|
1635
|
+
* The transformObjectDeep function passes each key and value of the given object
|
|
1658
1636
|
*
|
|
1659
|
-
*
|
|
1637
|
+
* (recursively) to the provided transformer function. It reconstructs an object of
|
|
1660
1638
|
*
|
|
1661
|
-
*
|
|
1639
|
+
* the same hierarchy with the key-value pairs that the transformer function
|
|
1662
1640
|
*
|
|
1663
|
-
*
|
|
1641
|
+
* returns.
|
|
1664
1642
|
*
|
|
1665
1643
|
* Usage:
|
|
1666
1644
|
*
|
|
@@ -1699,11 +1677,9 @@ export function toLabelAndValue(string: string): {
|
|
|
1699
1677
|
export function transformObjectDeep(object: object, keyValueTransformer: (key: string | number | symbol, object: any) => any[], objectPreProcessor?: (object: any) => any): object;
|
|
1700
1678
|
/**
|
|
1701
1679
|
*
|
|
1702
|
-
*
|
|
1703
|
-
*
|
|
1704
|
-
* Failsafe status: alternative available
|
|
1680
|
+
* The truncate function truncates a string by adding "..." if it exceeds a
|
|
1705
1681
|
*
|
|
1706
|
-
*
|
|
1682
|
+
* specified maximum length.
|
|
1707
1683
|
*
|
|
1708
1684
|
* @example
|
|
1709
1685
|
*
|
|
@@ -1714,11 +1690,9 @@ export function transformObjectDeep(object: object, keyValueTransformer: (key: s
|
|
|
1714
1690
|
export function truncate(string: string, length: number): string;
|
|
1715
1691
|
/**
|
|
1716
1692
|
*
|
|
1717
|
-
*
|
|
1693
|
+
* The truncate function truncates a string by adding "..." if it exceeds a
|
|
1718
1694
|
*
|
|
1719
|
-
*
|
|
1720
|
-
*
|
|
1721
|
-
* Truncate the string with ... if it is longer than specified string length.
|
|
1695
|
+
* specified maximum length.
|
|
1722
1696
|
*
|
|
1723
1697
|
* @example
|
|
1724
1698
|
*
|
|
@@ -1728,21 +1702,40 @@ export function truncate(string: string, length: number): string;
|
|
|
1728
1702
|
*/
|
|
1729
1703
|
export function truncate(string: NilOr<string>, length: number): NilOr<string>;
|
|
1730
1704
|
export function nullSafe<T extends Function>(func: T): (...args: any) => ReturnType<T>;
|
|
1705
|
+
/**
|
|
1706
|
+
*
|
|
1707
|
+
* The isNotPresent function is a utility that checks if a value is not present.
|
|
1708
|
+
*
|
|
1709
|
+
* It combines checks for null and empty values. It is worth noting that we also
|
|
1710
|
+
*
|
|
1711
|
+
* have a isPresent utility function that returns the complement of
|
|
1712
|
+
*
|
|
1713
|
+
* isNotPresent.
|
|
1714
|
+
*
|
|
1715
|
+
*/
|
|
1731
1716
|
export function isNotPresent(object: any): boolean;
|
|
1732
1717
|
export function isPresent(object: any): boolean;
|
|
1733
1718
|
/**
|
|
1734
1719
|
*
|
|
1735
|
-
*
|
|
1720
|
+
* The modifyWithImmer function is designed for immutable modification of values
|
|
1721
|
+
*
|
|
1722
|
+
* and is an abstraction over Immer's produce method. Immer is a library that
|
|
1723
|
+
*
|
|
1724
|
+
* simplifies working with complex data structures and state updates in a more
|
|
1725
|
+
*
|
|
1726
|
+
* immutable manner.
|
|
1727
|
+
*
|
|
1728
|
+
* This function does not include a failsafe mechanism, so it is important to use
|
|
1736
1729
|
*
|
|
1737
|
-
*
|
|
1730
|
+
* it with care, especially when working with complex data structures.
|
|
1738
1731
|
*
|
|
1739
|
-
*
|
|
1732
|
+
* You can read more about Immer here.
|
|
1740
1733
|
*
|
|
1741
1734
|
* Returns the new modified value.
|
|
1742
1735
|
*
|
|
1743
1736
|
* @example
|
|
1744
1737
|
*
|
|
1745
|
-
* const data = { name: "Oliver" }
|
|
1738
|
+
* const data = { name: "Oliver" };
|
|
1746
1739
|
* modifyWithImmer(draft => {
|
|
1747
1740
|
* draft.name = "Oliver smith";
|
|
1748
1741
|
* })(data);
|
|
@@ -1766,17 +1759,25 @@ export function isPresent(object: any): boolean;
|
|
|
1766
1759
|
export function modifyWithImmer<T>(modifier: (draft: Draft<T>) => void, data: T): T;
|
|
1767
1760
|
/**
|
|
1768
1761
|
*
|
|
1769
|
-
*
|
|
1762
|
+
* The modifyWithImmer function is designed for immutable modification of values
|
|
1763
|
+
*
|
|
1764
|
+
* and is an abstraction over Immer's produce method. Immer is a library that
|
|
1765
|
+
*
|
|
1766
|
+
* simplifies working with complex data structures and state updates in a more
|
|
1767
|
+
*
|
|
1768
|
+
* immutable manner.
|
|
1769
|
+
*
|
|
1770
|
+
* This function does not include a failsafe mechanism, so it is important to use
|
|
1770
1771
|
*
|
|
1771
|
-
*
|
|
1772
|
+
* it with care, especially when working with complex data structures.
|
|
1772
1773
|
*
|
|
1773
|
-
*
|
|
1774
|
+
* You can read more about Immer here.
|
|
1774
1775
|
*
|
|
1775
1776
|
* Returns the new modified value.
|
|
1776
1777
|
*
|
|
1777
1778
|
* @example
|
|
1778
1779
|
*
|
|
1779
|
-
* const data = { name: "Oliver" }
|
|
1780
|
+
* const data = { name: "Oliver" };
|
|
1780
1781
|
* modifyWithImmer(draft => {
|
|
1781
1782
|
* draft.name = "Oliver smith";
|
|
1782
1783
|
* })(data);
|