@bigbinary/neeto-commons-frontend 2.0.99 → 2.0.100

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.
@@ -239,7 +239,7 @@ export function initializeCredentials(props: {
239
239
  *
240
240
  * This function joins the given strings with hyphen.
241
241
  *
242
- * Usage:
242
+ * Any number of string arguments.
243
243
  *
244
244
  * @example
245
245
  *
package/initializers.d.ts CHANGED
@@ -74,5 +74,17 @@ export const globalProps: GlobalPropsType;
74
74
  *
75
75
  * for more details.
76
76
  *
77
+ * @example
78
+ *
79
+ * const App = () => {
80
+ * const isError = useDisplayErrorPage();
81
+ *
82
+ * if (isError) {
83
+ * return <ErrorPage />;
84
+ * }
85
+ *
86
+ * return <Main />;
87
+ * };
88
+ * @endexample
77
89
  */
78
90
  export function useDisplayErrorPage(): Boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "2.0.99",
3
+ "version": "2.0.100",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
package/pure.d.ts CHANGED
@@ -14,7 +14,7 @@ type MatchPattern<Obj = any, Parent = Obj> = Obj extends any[] ? Matchable<Obj,
14
14
  *
15
15
  * Failsafe status: alternative available
16
16
  *
17
- * Converts camelCase to snake_case.
17
+ * Converts camelCase string to snake_case.
18
18
  *
19
19
  * @example
20
20
  *
@@ -50,24 +50,6 @@ export function _capitalize(string: NilOr<string>): NilOr<string>;
50
50
  *
51
51
  * keys in the resulting array.
52
52
  *
53
- * A function that accepts an input array and returns a new array with elements
54
- *
55
- * such that: each element will contain the newly specified keys with its value
56
- *
57
- * same as the value of specified source keys.
58
- *
59
- * Usage:
60
- *
61
- * @example
62
- *
63
- * copyKeys({
64
- * sourceKey1: "destinationKey1",
65
- * sourceKey2: "destinationKey2",
66
- * ...
67
- * }, arrayOfObjects);
68
- * @endexample
69
- * Example:
70
- *
71
53
  * @example
72
54
  *
73
55
  * const data = [
@@ -99,24 +81,6 @@ export function copyKeys<T>(keyMap: { [key in keyof Partial<T>]: string }, objec
99
81
  *
100
82
  * keys in the resulting array.
101
83
  *
102
- * A function that accepts an input array and returns a new array with elements
103
- *
104
- * such that: each element will contain the newly specified keys with its value
105
- *
106
- * same as the value of specified source keys.
107
- *
108
- * Usage:
109
- *
110
- * @example
111
- *
112
- * copyKeys({
113
- * sourceKey1: "destinationKey1",
114
- * sourceKey2: "destinationKey2",
115
- * ...
116
- * }, arrayOfObjects);
117
- * @endexample
118
- * Example:
119
- *
120
84
  * @example
121
85
  *
122
86
  * const data = [
@@ -158,29 +122,6 @@ export function _copyKeys(keyMap: {
158
122
  *
159
123
  * has a different structure for the key mapping to support nesting.
160
124
  *
161
- * They key mapping object is completely different from the one used in copyKeys
162
- *
163
- * to support object nesting. It accepts destination as key and source as value.
164
- *
165
- * Source can be of three types
166
- *
167
- * Usage:
168
- *
169
- * @example
170
- *
171
- * copyKeysDeep({
172
- * destinationKey: "sourceKey",
173
- * {
174
- * destinationKey: "sourceKeyInNestedObject",
175
- * },
176
- * {
177
- * destinationKey2: ["path", "to", "sourceKeyInNestedObject"],
178
- * destinationKey3: (value, root) => value + root.id,
179
- * }
180
- * }, arrayOfObjects);
181
- * @endexample
182
- * Example:
183
- *
184
125
  * @example
185
126
  *
186
127
  * const data = [
@@ -201,7 +142,7 @@ export function _copyKeys(keyMap: {
201
142
  * ];
202
143
  *
203
144
  * // reformatting `data` to label-and-value format for neetoui-select.
204
- * copyKeys(
145
+ * copyKeysDeep(
205
146
  * {
206
147
  * name: "label",
207
148
  * quantity: (qty, root) => qty + root.user.bonusQty,
@@ -243,29 +184,6 @@ export function copyKeysDeep(keyMap: object, objectArray: object[]): object[];
243
184
  *
244
185
  * has a different structure for the key mapping to support nesting.
245
186
  *
246
- * They key mapping object is completely different from the one used in copyKeys
247
- *
248
- * to support object nesting. It accepts destination as key and source as value.
249
- *
250
- * Source can be of three types
251
- *
252
- * Usage:
253
- *
254
- * @example
255
- *
256
- * copyKeysDeep({
257
- * destinationKey: "sourceKey",
258
- * {
259
- * destinationKey: "sourceKeyInNestedObject",
260
- * },
261
- * {
262
- * destinationKey2: ["path", "to", "sourceKeyInNestedObject"],
263
- * destinationKey3: (value, root) => value + root.id,
264
- * }
265
- * }, arrayOfObjects);
266
- * @endexample
267
- * Example:
268
- *
269
187
  * @example
270
188
  *
271
189
  * const data = [
@@ -286,7 +204,7 @@ export function copyKeysDeep(keyMap: object, objectArray: object[]): object[];
286
204
  * ];
287
205
  *
288
206
  * // reformatting `data` to label-and-value format for neetoui-select.
289
- * copyKeys(
207
+ * copyKeysDeep(
290
208
  * {
291
209
  * name: "label",
292
210
  * quantity: (qty, root) => qty + root.user.bonusQty,
@@ -328,8 +246,6 @@ export function _copyKeysDeep(keyMap: object): (objectArray: NilOr<object[]>) =>
328
246
  *
329
247
  * Counts an array of items for items that matches the given pattern.
330
248
  *
331
- * Usage:
332
- *
333
249
  * @example
334
250
  *
335
251
  * const array = [
@@ -353,8 +269,6 @@ export function countBy<T>(pattern: MatchPattern<T>, entityArray: T[]): number;
353
269
  *
354
270
  * Counts an array of items for items that matches the given pattern.
355
271
  *
356
- * Usage:
357
- *
358
272
  * @example
359
273
  *
360
274
  * const array = [
@@ -378,11 +292,7 @@ export function _countBy(pattern: MatchPattern): (entityArray: NilOr<object[]>)
378
292
  *
379
293
  * Failsafe status: failsafe by default
380
294
  *
381
- * To make an object immutable, recursively freeze each property which is of type
382
- *
383
- * object.
384
- *
385
- * Usage:
295
+ * To make an object immutable, recursively freeze each property which is of type object.
386
296
  *
387
297
  * @example
388
298
  *
@@ -404,9 +314,7 @@ export function _countBy(pattern: MatchPattern): (entityArray: NilOr<object[]>)
404
314
  * };
405
315
  *
406
316
  * @endexample
407
- * The assignment operation will throw the error only when we execute it in strict
408
- *
409
- * mode, in non-strict mode it will fail silently.
317
+ * The assignment operation will throw the error only when we execute it in strict mode, in non-strict mode it will fail silently.
410
318
  *
411
319
  * @example
412
320
  *
@@ -434,8 +342,6 @@ export function deepFreezeObject<T>(object: T): Readonly<T>;
434
342
  *
435
343
  * corresponding to that index.
436
344
  *
437
- * Usage:
438
- *
439
345
  * @example
440
346
  *
441
347
  * dynamicArray(3, index => `option ${index + 1}`);
@@ -454,8 +360,6 @@ export function dynamicArray<T>(count: number, elementGenerator: (index: number)
454
360
  *
455
361
  * found, false otherwise.
456
362
  *
457
- * Usage:
458
- *
459
363
  * @example
460
364
  *
461
365
  * const array = [
@@ -478,8 +382,6 @@ export function existsBy<T>(pattern: MatchPattern<T>, entityArray: T[]): boolean
478
382
  *
479
383
  * found, false otherwise.
480
384
  *
481
- * Usage:
482
- *
483
385
  * @example
484
386
  *
485
387
  * const array = [
@@ -502,8 +404,6 @@ export function _existsBy(pattern: MatchPattern): (entityArray: NilOr<object[]>)
502
404
  *
503
405
  * Search for an item in the given array using the given id.
504
406
  *
505
- * Usage:
506
- *
507
407
  * @example
508
408
  *
509
409
  * const array = [
@@ -524,8 +424,6 @@ export function existsById(id: any, entityArray: object[]): boolean;
524
424
  *
525
425
  * Search for an item in the given array using the given id.
526
426
  *
527
- * Usage:
528
- *
529
427
  * @example
530
428
  *
531
429
  * const array = [
@@ -548,8 +446,6 @@ export function _existsById(id: any): (entityArray: NilOr<object[]>) => NilOr<bo
548
446
  *
549
447
  * Filter an array of items based on pattern matching.
550
448
  *
551
- * Usage:
552
- *
553
449
  * @example
554
450
  *
555
451
  * const array = [
@@ -573,8 +469,6 @@ export function filterBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T[];
573
469
  *
574
470
  * Filter an array of items based on pattern matching.
575
471
  *
576
- * Usage:
577
- *
578
472
  * @example
579
473
  *
580
474
  * const array = [
@@ -628,8 +522,6 @@ export function _filterNonNull(object: NilOr<object>): NilOr<object>;
628
522
  *
629
523
  * Find the first item that matches the given pattern from an array.
630
524
  *
631
- * Usage:
632
- *
633
525
  * @example
634
526
  *
635
527
  * const array = [
@@ -651,8 +543,6 @@ export function findBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T;
651
543
  *
652
544
  * Find the first item that matches the given pattern from an array.
653
545
  *
654
- * Usage:
655
- *
656
546
  * @example
657
547
  *
658
548
  * const array = [
@@ -676,8 +566,6 @@ export function _findBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) =>
676
566
  *
677
567
  * Find an object having the given id from an array.
678
568
  *
679
- * Usage:
680
- *
681
569
  * @example
682
570
  *
683
571
  * const array = [
@@ -699,8 +587,6 @@ export function findById<T>(id: any, entityArray: T[]): T;
699
587
  *
700
588
  * Find an object having the given id from an array.
701
589
  *
702
- * Usage:
703
- *
704
590
  * @example
705
591
  *
706
592
  * const array = [
@@ -724,8 +610,6 @@ export function _findById(id: any): <T>(entityArray: NilOr<T[]>) => NilOr<T>;
724
610
  *
725
611
  * Find the index of an item that matches the pattern from the given array.
726
612
  *
727
- * Usage:
728
- *
729
613
  * @example
730
614
  *
731
615
  * const array = [
@@ -747,8 +631,6 @@ export function findIndexBy<T>(pattern: MatchPattern<T>, entityArray: T[]): numb
747
631
  *
748
632
  * Find the index of an item that matches the pattern from the given array.
749
633
  *
750
- * Usage:
751
- *
752
634
  * @example
753
635
  *
754
636
  * const array = [
@@ -774,8 +656,6 @@ export function _findIndexBy(pattern: MatchPattern): (entityArray: NilOr<object[
774
656
  *
775
657
  * entities inside it.
776
658
  *
777
- * Usage:
778
- *
779
659
  * @example
780
660
  *
781
661
  * const array = [
@@ -799,8 +679,6 @@ export function findIndexById(id: any, entityArray: object[]): number;
799
679
  *
800
680
  * entities inside it.
801
681
  *
802
- * Usage:
803
- *
804
682
  * @example
805
683
  *
806
684
  * const array = [
@@ -824,8 +702,6 @@ export function _findIndexById(id: any): (entityArray: NilOr<object[]>) => NilOr
824
702
  *
825
703
  * Find the last item that matches the given pattern.
826
704
  *
827
- * Usage:
828
- *
829
705
  * @example
830
706
  *
831
707
  * const array = [
@@ -848,8 +724,6 @@ export function findLastBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T;
848
724
  *
849
725
  * Find the last item that matches the given pattern.
850
726
  *
851
- * Usage:
852
- *
853
727
  * @example
854
728
  *
855
729
  * const array = [
@@ -874,8 +748,6 @@ export function _findLastBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>)
874
748
  *
875
749
  * Find the last index of item that matches the given pattern.
876
750
  *
877
- * Usage:
878
- *
879
751
  * @example
880
752
  *
881
753
  * const array = [
@@ -898,8 +770,6 @@ export function findLastIndexBy(id: any, entityArray: object[]): number;
898
770
  *
899
771
  * Find the last index of item that matches the given pattern.
900
772
  *
901
- * Usage:
902
- *
903
773
  * @example
904
774
  *
905
775
  * const array = [
@@ -922,9 +792,7 @@ export function _findLastIndexBy(id: any): (entityArray: NilOr<object[]>) => Nil
922
792
  *
923
793
  * Failsafe status: not failsafe
924
794
  *
925
- * This function is used to generate a random integer.
926
- *
927
- * Here are some sample usages:
795
+ * This function is used to generate a random integer in the given range. If only 1 argument is provided, it is considered as the upper bound.
928
796
  *
929
797
  * @example
930
798
  *
@@ -966,6 +834,12 @@ export function isNot(a: any): (b: any) => boolean;
966
834
  *
967
835
  * objects). False otherwise. (the opposite of isEmpty in ramda)
968
836
  *
837
+ * @example
838
+ *
839
+ * isNotEmpty(""); // returns false
840
+ * isNotEmpty(["a"]); // returns true
841
+ * isNotEMpty({ name: "Oliver" }); //return true
842
+ * @endexample
969
843
  */
970
844
  export const isNotEmpty: (a: any) => boolean;
971
845
  export function isNotEqualDeep(a: any, b: any): boolean;
@@ -978,8 +852,6 @@ export function isNotEqualDeep(a: any): (b: any) => boolean;
978
852
  *
979
853
  * Recursively converts the snake cased object keys to camel case
980
854
  *
981
- * Usage:
982
- *
983
855
  * @example
984
856
  *
985
857
  * keysToCamelCase({
@@ -1005,8 +877,6 @@ export function keysToCamelCase(object: any): any;
1005
877
  *
1006
878
  * Recursively converts the camel cased object keys to snake case.
1007
879
  *
1008
- * Usage:
1009
- *
1010
880
  * @example
1011
881
  *
1012
882
  * keysToSnakeCase({
@@ -1030,33 +900,7 @@ export function keysToSnakeCase(object: any): any;
1030
900
  *
1031
901
  * Failsafe status: failsafe by default
1032
902
  *
1033
- * Checks whether the given object matches the given pattern. Each primitive value
1034
- *
1035
- * (int, boolean, string, etc.) in the pattern should be same as the corresponding
1036
- *
1037
- * value in the object (deeply) for a match.
1038
- *
1039
- * This function accepts two objects (pattern and data) as parameters and returns
1040
- *
1041
- * true if all the keys in pattern exist in data and the primitive values of those
1042
- *
1043
- * keys are identical to the data. Object values are compared recursively for inner
1044
- *
1045
- * primitives.
1046
- *
1047
- * If a function is passed as pattern's property, and equality test is performed
1048
- *
1049
- * with corresponding object property. If equality fails, the function will be
1050
- *
1051
- * evaluated with the value of the corresponding property of the data. If function
1052
- *
1053
- * returns true, it will be considered as a match.
1054
- *
1055
- * In short, this function checks whether all the primitive keys in the pattern is
1056
- *
1057
- * equal to corresponding keys in the data and all conditions (functions) are
1058
- *
1059
- * satisfied.
903
+ * Checks whether the given object matches the given pattern. Each primitive value (int, boolean, string, etc.) in the pattern should be same as the corresponding value in the object (deeply) and all conditions (functions) should be satisfied for a match.
1060
904
  *
1061
905
  * @example
1062
906
  *
@@ -1087,33 +931,7 @@ export function matches<T>(pattern: MatchPattern<T>, data: T): boolean;
1087
931
  *
1088
932
  * Failsafe status: failsafe by default
1089
933
  *
1090
- * Checks whether the given object matches the given pattern. Each primitive value
1091
- *
1092
- * (int, boolean, string, etc.) in the pattern should be same as the corresponding
1093
- *
1094
- * value in the object (deeply) for a match.
1095
- *
1096
- * This function accepts two objects (pattern and data) as parameters and returns
1097
- *
1098
- * true if all the keys in pattern exist in data and the primitive values of those
1099
- *
1100
- * keys are identical to the data. Object values are compared recursively for inner
1101
- *
1102
- * primitives.
1103
- *
1104
- * If a function is passed as pattern's property, and equality test is performed
1105
- *
1106
- * with corresponding object property. If equality fails, the function will be
1107
- *
1108
- * evaluated with the value of the corresponding property of the data. If function
1109
- *
1110
- * returns true, it will be considered as a match.
1111
- *
1112
- * In short, this function checks whether all the primitive keys in the pattern is
1113
- *
1114
- * equal to corresponding keys in the data and all conditions (functions) are
1115
- *
1116
- * satisfied.
934
+ * Checks whether the given object matches the given pattern. Each primitive value (int, boolean, string, etc.) in the pattern should be same as the corresponding value in the object (deeply) and all conditions (functions) should be satisfied for a match.
1117
935
  *
1118
936
  * @example
1119
937
  *
@@ -1148,8 +966,6 @@ export function matches(pattern: MatchPattern): (data: any) => boolean;
1148
966
  *
1149
967
  * argument to the function.
1150
968
  *
1151
- * Usage:
1152
- *
1153
969
  * @example
1154
970
  *
1155
971
  * const array = [
@@ -1175,8 +991,6 @@ export function modifyBy<T>(pattern: MatchPattern<T>, modifier: (previous: T) =>
1175
991
  *
1176
992
  * argument to the function.
1177
993
  *
1178
- * Usage:
1179
- *
1180
994
  * @example
1181
995
  *
1182
996
  * const array = [
@@ -1202,8 +1016,6 @@ export function modifyBy<T>(pattern: MatchPattern<T>, modifier: (previous: T) =>
1202
1016
  *
1203
1017
  * argument to the function.
1204
1018
  *
1205
- * Usage:
1206
- *
1207
1019
  * @example
1208
1020
  *
1209
1021
  * const array = [
@@ -1229,8 +1041,6 @@ export function modifyBy(pattern: MatchPattern): <T>(modifier: (previous: T) =>
1229
1041
  *
1230
1042
  * argument to the function.
1231
1043
  *
1232
- * Usage:
1233
- *
1234
1044
  * @example
1235
1045
  *
1236
1046
  * const array = [
@@ -1262,8 +1072,6 @@ export function _modifyBy(pattern: MatchPattern): <T>(modifier: (previous: T) =>
1262
1072
  *
1263
1073
  * of the match.
1264
1074
  *
1265
- * Usage:
1266
- *
1267
1075
  * @example
1268
1076
  *
1269
1077
  * const array = [
@@ -1292,8 +1100,6 @@ export function modifyById<T>(id: any, modifier: (previous: T) => T, entityArray
1292
1100
  *
1293
1101
  * of the match.
1294
1102
  *
1295
- * Usage:
1296
- *
1297
1103
  * @example
1298
1104
  *
1299
1105
  * const array = [
@@ -1322,8 +1128,6 @@ export function modifyById<T>(id: any, modifier: (previous: T) => T): (entityArr
1322
1128
  *
1323
1129
  * of the match.
1324
1130
  *
1325
- * Usage:
1326
- *
1327
1131
  * @example
1328
1132
  *
1329
1133
  * const array = [
@@ -1352,8 +1156,6 @@ export function modifyById(id: any): <T>(modifier: (previous: T) => T, entityArr
1352
1156
  *
1353
1157
  * of the match.
1354
1158
  *
1355
- * Usage:
1356
- *
1357
1159
  * @example
1358
1160
  *
1359
1161
  * const array = [
@@ -1398,8 +1200,6 @@ export function notEqualsDeep(a: any): (b: any) => boolean;
1398
1200
  *
1399
1201
  * element from the list of arguments.
1400
1202
  *
1401
- * Usage:
1402
- *
1403
1203
  * @example
1404
1204
  *
1405
1205
  * randomPick("arg1", "arg2", "arg3", "arg4", "arg5");
@@ -1416,8 +1216,6 @@ export function randomPick<T>(...args: T[]): T;
1416
1216
  *
1417
1217
  * Remove all items that matches the given pattern from an array of items.
1418
1218
  *
1419
- * Usage:
1420
- *
1421
1219
  * @example
1422
1220
  *
1423
1221
  * const array = [
@@ -1439,8 +1237,6 @@ export function removeBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T[];
1439
1237
  *
1440
1238
  * Remove all items that matches the given pattern from an array of items.
1441
1239
  *
1442
- * Usage:
1443
- *
1444
1240
  * @example
1445
1241
  *
1446
1242
  * const array = [
@@ -1464,8 +1260,6 @@ export function _removeBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) =
1464
1260
  *
1465
1261
  * Return a new array with the item with the given id removed.
1466
1262
  *
1467
- * Usage:
1468
- *
1469
1263
  * @example
1470
1264
  *
1471
1265
  * const array = [
@@ -1487,8 +1281,6 @@ export function removeById<T>(id: any, entityArray: T[]): T[];
1487
1281
  *
1488
1282
  * Return a new array with the item with the given id removed.
1489
1283
  *
1490
- * Usage:
1491
- *
1492
1284
  * @example
1493
1285
  *
1494
1286
  * const array = [
@@ -1514,26 +1306,6 @@ export function _removeById(id: any): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>
1514
1306
  *
1515
1307
  * array. This creates a new instance and doesn't mutate the array.
1516
1308
  *
1517
- * A function that accepts an input array and returns a new array with elements
1518
- *
1519
- * such that: each element will contain the newly specified keys with its value
1520
- *
1521
- * pointing to the value of specified source keys. The source keys will not be
1522
- *
1523
- * copied.
1524
- *
1525
- * Usage:
1526
- *
1527
- * @example
1528
- *
1529
- * renameKeys({
1530
- * sourceKey1: "destinationKey1",
1531
- * sourceKey2: "destinationKey2",
1532
- * ...
1533
- * }, arrayOfObjects);
1534
- * @endexample
1535
- * Example:
1536
- *
1537
1309
  * @example
1538
1310
  *
1539
1311
  * const data = [
@@ -1565,26 +1337,6 @@ export function renameKeys<T, M extends { [key in keyof Partial<T>]: string }>(k
1565
1337
  *
1566
1338
  * array. This creates a new instance and doesn't mutate the array.
1567
1339
  *
1568
- * A function that accepts an input array and returns a new array with elements
1569
- *
1570
- * such that: each element will contain the newly specified keys with its value
1571
- *
1572
- * pointing to the value of specified source keys. The source keys will not be
1573
- *
1574
- * copied.
1575
- *
1576
- * Usage:
1577
- *
1578
- * @example
1579
- *
1580
- * renameKeys({
1581
- * sourceKey1: "destinationKey1",
1582
- * sourceKey2: "destinationKey2",
1583
- * ...
1584
- * }, arrayOfObjects);
1585
- * @endexample
1586
- * Example:
1587
- *
1588
1340
  * @example
1589
1341
  *
1590
1342
  * const data = [
@@ -1624,8 +1376,6 @@ export function _renameKeys<M extends {
1624
1376
  *
1625
1377
  * Replace all items that matches the given pattern with the given item.
1626
1378
  *
1627
- * Usage:
1628
- *
1629
1379
  * @example
1630
1380
  *
1631
1381
  * const array = [
@@ -1649,8 +1399,6 @@ export function replaceBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T[];
1649
1399
  *
1650
1400
  * Replace all items that matches the given pattern with the given item.
1651
1401
  *
1652
- * Usage:
1653
- *
1654
1402
  * @example
1655
1403
  *
1656
1404
  * const array = [
@@ -1678,8 +1426,6 @@ export function _replaceBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>)
1678
1426
  *
1679
1427
  * object.
1680
1428
  *
1681
- * Usage:
1682
- *
1683
1429
  * @example
1684
1430
  *
1685
1431
  * const array = [
@@ -1706,8 +1452,6 @@ export function replaceById<T>(id: any, entityArray: T[]): T[];
1706
1452
  *
1707
1453
  * object.
1708
1454
  *
1709
- * Usage:
1710
- *
1711
1455
  * @example
1712
1456
  *
1713
1457
  * const array = [
@@ -1732,15 +1476,9 @@ export function _replaceById(id: any): <T>(entityArray: NilOr<T[]>) => NilOr<T[]
1732
1476
  *
1733
1477
  * Failsafe status: failsafe by default
1734
1478
  *
1735
- * Recursively converts the camel cased object keys to snake case. It will
1736
- *
1737
- * gracefully handle special objects like Date, dayjs instance etc.
1738
- *
1739
- * While converting, this function checks if the function named toJSON is present
1479
+ * Recursively converts the camel cased object keys to snake case. It will gracefully handle special objects like Date, dayjs instance etc.
1740
1480
  *
1741
- * in the value (if the value is an object) and if found, it calls the function and
1742
- *
1743
- * uses the return value for further processing.
1481
+ * While converting, this function checks if the function named toJSON is present in the value (if the value is an object) and if found, it calls the function and uses the return value for further processing.
1744
1482
  *
1745
1483
  * Example 1:
1746
1484
  *
@@ -1778,13 +1516,7 @@ export function _replaceById(id: any): <T>(entityArray: NilOr<T[]>) => NilOr<T[]
1778
1516
  * }
1779
1517
  *
1780
1518
  * @endexample
1781
- * In the above example, the value of dob is an date object and has toJSON
1782
- *
1783
- * method present in it. The toJSON method returns the date in ISO format which
1784
- *
1785
- * will be used for further processing instead of recursively converting the
1786
- *
1787
- * original date object.
1519
+ * In the above example, the value of dob is an date object and has toJSON method present in it. The toJSON method returns the date in ISO format which will be used for further processing instead of recursively converting the original date object.
1788
1520
  *
1789
1521
  */
1790
1522
  export function serializeKeysToSnakeCase(object: object): object;
@@ -1802,8 +1534,6 @@ export function serializeKeysToSnakeCase(object: object): object;
1802
1534
  *
1803
1535
  * This is helpful when serializing Date objects, dayjs objects etc.
1804
1536
  *
1805
- * Usage:
1806
- *
1807
1537
  * @example
1808
1538
  *
1809
1539
  * preprocessForSerialization(dayjs("1980-01-01")); // returns "1980-01-01T00:00:00.000Z"
@@ -1838,7 +1568,7 @@ export function _slugify(string: NilOr<string>): NilOr<string>;
1838
1568
  *
1839
1569
  * Failsafe status: alternative available
1840
1570
  *
1841
- * Converts snake_case to camelCase.
1571
+ * Converts snake_case string to camelCase.
1842
1572
  *
1843
1573
  * @example
1844
1574
  *
@@ -1857,8 +1587,6 @@ export function _snakeToCamelCase(string: NilOr<string>): NilOr<string>;
1857
1587
  *
1858
1588
  * "label" and "value".
1859
1589
  *
1860
- * Usage:
1861
- *
1862
1590
  * @example
1863
1591
  *
1864
1592
  * toLabelAndValue("test");
@@ -1876,18 +1604,12 @@ export function toLabelAndValue(string: string): {
1876
1604
  *
1877
1605
  * Failsafe status: failsafe by default
1878
1606
  *
1879
- * Passes each key and value of a the given object (recursively) to the given
1607
+ * Passes each key and value of the given object (recursively) to the given
1880
1608
  *
1881
1609
  * transformer function. Reconstructs an object of the same hierarchy with the key
1882
1610
  *
1883
1611
  * value pair the transformer function returns.
1884
1612
  *
1885
- * You can optionally pass an object transformer which will be executed on every
1886
- *
1887
- * value (including the supplied object itself) before any processing is done to
1888
- *
1889
- * it.
1890
- *
1891
1613
  * Usage:
1892
1614
  *
1893
1615
  * @example
package/react-utils.d.ts CHANGED
@@ -93,20 +93,6 @@ type OptionsType = {
93
93
  *
94
94
  * on the screen.
95
95
  *
96
- * This hook will accept two arguments an element and an options object. Passing an
97
- *
98
- * element using ref requires you to pass ref.current as an argument or pass an
99
- *
100
- * element that you accessed via getElementById/querySelector etc. Since it uses
101
- *
102
- * Intersection Observer API you can pass observer options such as root,
103
- *
104
- * rootMargin, threshold, etc as the second argument. You can read more about
105
- *
106
- * Intersection Observer API and the supported options from
107
- *
108
- * MDN Intersection Observer API.
109
- *
110
96
  * @example
111
97
  *
112
98
  * const ref = useRef(null);
@@ -133,9 +119,7 @@ export function useIsElementVisibleInDom(target: Element | null, options?: Optio
133
119
  *
134
120
  * until the updates are stopped. We can use this to limit the number of API calls
135
121
  *
136
- * triggered from a user input like search box.
137
- *
138
- * This hook accepts a value and a delay as an argument. The value returned by the
122
+ * triggered from a user input like search box. The value returned by the
139
123
  *
140
124
  * hook will only reflect the latest value when the hook has not been called for
141
125
  *
@@ -162,9 +146,7 @@ export function useDebounce<T>(value: T, delay?: number): T;
162
146
  *
163
147
  * function will be executed only when the dependencies stops changing for a while.
164
148
  *
165
- * This hook accepts a function as an argument. It will return a debounced version
166
- *
167
- * of that function. The debounced function comes with a cancel method which can
149
+ * The debounced function comes with a cancel method which can
168
150
  *
169
151
  * be used to cancel the delayed function invocation.
170
152
  *
@@ -196,12 +178,6 @@ export function useFuncDebounce<F extends Function>(func: F, delay?: number): F
196
178
  *
197
179
  * operations on the localStorage, prefer the vanilla localStorage API functions.
198
180
  *
199
- * This hook is very similar to useState. The only difference is that you must
200
- *
201
- * pass the storage key in the 1st parameter so that we can default to that value
202
- *
203
- * on page load instead of specified initial value.
204
- *
205
181
  * @example
206
182
  *
207
183
  * // here "theme" is the storage key and "light" is the initial value
@@ -228,12 +204,6 @@ export function useLocalStorage<T>(key: string, initialValue?: T): [T, (value: T
228
204
  *
229
205
  * A hook used to detect clicks outside of a specified element.
230
206
  *
231
- * This hook will accept two arguments: a ref and a handler. The ref is a reference
232
- *
233
- * to the element for which we want to detect outside clicks and handler is the
234
- *
235
- * action we want to perform when we click outside the element.
236
- *
237
207
  * @example
238
208
  *
239
209
  * const ref = useRef();
@@ -278,6 +248,12 @@ export function usePrevious<T>(value: T): T;
278
248
  *
279
249
  * if the dependencies change.
280
250
  *
251
+ * @example
252
+ *
253
+ * useUpdateEffect(() => {
254
+ * setTitle(value)
255
+ * }, [value]);
256
+ * @endexample
281
257
  */
282
258
  export function useUpdateEffect(effect: () => void, deps: any[]): void;
283
259
  /**
@@ -292,6 +268,18 @@ export function useUpdateEffect(effect: () => void, deps: any[]): void;
292
268
  *
293
269
  * for more details.
294
270
  *
271
+ * @example
272
+ *
273
+ * const App = () => {
274
+ * const isError = useDisplayErrorPage();
275
+ *
276
+ * if (isError) {
277
+ * return <ErrorPage />;
278
+ * }
279
+ *
280
+ * return <Main />;
281
+ * };
282
+ * @endexample
295
283
  */
296
284
  export function useDisplayErrorPage(): boolean;
297
285
  /**
@@ -325,12 +313,6 @@ type TimerType = {
325
313
  *
326
314
  * application to be manually refreshed.
327
315
  *
328
- * This hook accepts a single argument timerIntervalInSeconds, which is the
329
- *
330
- * number of seconds after which the component will re-render. The default value is
331
- *
332
- * 60 seconds.
333
- *
334
316
  * All invocations of useTimer hooks are attached to a single setInterval call
335
317
  *
336
318
  * which ticks every 1 second. So using that hook in multiple components won't
@@ -362,8 +344,6 @@ type ZustandConfigType = (set: (data: any) => void, get: () => any, api: any) =>
362
344
  *
363
345
  * overwritten.
364
346
  *
365
- * Usage:
366
- *
367
347
  * @example
368
348
  *
369
349
  * const useStore = create(
@@ -414,15 +394,9 @@ export declare type ZustandStoreHook = UseBoundStore<StoreApi<any>> & {
414
394
  *
415
395
  * will not submit when Shift + Enter is pressed. Shift + Enter can be used to
416
396
  *
417
- * add new lines to text area in the form.
418
- *
419
- * The hook accepts a callback, onSubmit, which will be called with no arguments
420
- *
421
- * when Enter key press is detected.
397
+ * add new lines to text area in the form. The hook returns a ref. This need to be
422
398
  *
423
- * The hook returns a ref. This need to be attached to the input element to be
424
- *
425
- * listened to.
399
+ * attached to the input element to be listened to.
426
400
  *
427
401
  * @example
428
402
  *
@@ -460,6 +434,8 @@ export function withTitle(Component: () => JSX.Element, title?: string): (props)
460
434
  *
461
435
  * send notifications and then register the browser with the notification service.
462
436
  *
437
+ * The VAPID public key.
438
+ *
463
439
  * After the user logs in, we need to ask the user permissions to send
464
440
  *
465
441
  * notifications and then register the browser with the notification service.
@@ -550,14 +526,12 @@ export async function destroyBrowserSubscription(): Promise<void>;
550
526
  *
551
527
  * This function can be used to handle onClick actions that redirects to a URL.
552
528
  *
553
- * It opens up the URL in a new tab if ctrl/cmd + click event is recieved.
529
+ * It opens up the URL in a new tab if ctrl/cmd + click event is received.
554
530
  *
555
531
  * Otherwise, simply redirects to the provided URL in the same tab. URL can be
556
532
  *
557
533
  * passed as string or a history location object can be passed instead.
558
534
  *
559
- * Usage:
560
- *
561
535
  * @example
562
536
  *
563
537
  * handleMetaClick(history, "/dashboard", e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise simply redirects to "/dashboard".
@@ -571,14 +545,12 @@ export function handleMetaClick(history: History, params: string | object, event
571
545
  *
572
546
  * This function can be used to handle onClick actions that redirects to a URL.
573
547
  *
574
- * It opens up the URL in a new tab if ctrl/cmd + click event is recieved.
548
+ * It opens up the URL in a new tab if ctrl/cmd + click event is received.
575
549
  *
576
550
  * Otherwise, simply redirects to the provided URL in the same tab. URL can be
577
551
  *
578
552
  * passed as string or a history location object can be passed instead.
579
553
  *
580
- * Usage:
581
- *
582
554
  * @example
583
555
  *
584
556
  * handleMetaClick(history, "/dashboard", e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise simply redirects to "/dashboard".
@@ -592,14 +564,12 @@ export function handleMetaClick(history: History, params: string | object): (eve
592
564
  *
593
565
  * This function can be used to handle onClick actions that redirects to a URL.
594
566
  *
595
- * It opens up the URL in a new tab if ctrl/cmd + click event is recieved.
567
+ * It opens up the URL in a new tab if ctrl/cmd + click event is received.
596
568
  *
597
569
  * Otherwise, simply redirects to the provided URL in the same tab. URL can be
598
570
  *
599
571
  * passed as string or a history location object can be passed instead.
600
572
  *
601
- * Usage:
602
- *
603
573
  * @example
604
574
  *
605
575
  * handleMetaClick(history, "/dashboard", e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise simply redirects to "/dashboard".
@@ -615,8 +585,6 @@ export function handleMetaClick(history: History): (params: string | object, eve
615
585
  *
616
586
  * ctrlKey pressed.
617
587
  *
618
- * Usage:
619
- *
620
588
  * @example
621
589
  *
622
590
  * isMetaKeyPressed(event); //returns true if "event.metaKey || event.ctrlKey" is true, otherwise returns false.
@@ -636,8 +604,6 @@ type ConfigType = {
636
604
  *
637
605
  * corresponding handler will be invoked.
638
606
  *
639
- * This hook accepts 3 arguments hotkey, handler & config.
640
- *
641
607
  * @example
642
608
  *
643
609
  * // openSidebar function will only be called if the user is focused inside the textarea and performs the key combination.
@@ -662,8 +628,6 @@ export function useHotKeys(hotkey: string | string[], handler: (event: React.Key
662
628
  *
663
629
  * listen to other variable changes.
664
630
  *
665
- * This hook accepts a defaultValue and an optional array called dependencies.
666
- *
667
631
  * If dependencies is passed, the hook returns a state variable whose value will
668
632
  *
669
633
  * be updated to defaultValue in a useEffect that depends on the dependencies
@@ -713,10 +677,6 @@ export function useRegisterNavigationCheckpoint(): (key: string, path: string) =
713
677
  *
714
678
  * This hook returns the registered navigation checkpoint.
715
679
  *
716
- * This hook accepts key and will return the checkpoint path corresponding to the
717
- *
718
- * key from a Zustand store.
719
- *
720
680
  * @example
721
681
  *
722
682
  * const navigationCheckpoint = useRegisterNavigationCheckpoint(CHECK_POINT_KEY);
package/utils.d.ts CHANGED
@@ -10,8 +10,6 @@ export function resetAuthTokens(): void;
10
10
  *
11
11
  * event as the second, and executes the given function with event.target.value
12
12
  *
13
- * Usage:
14
- *
15
13
  * @example
16
14
  *
17
15
  * const onChange = val => console.log(`Value = ${val}`);
@@ -30,8 +28,6 @@ export function withEventTargetValue(func: (value: string) => void, event: React
30
28
  *
31
29
  * event as the second, and executes the given function with event.target.value
32
30
  *
33
- * Usage:
34
- *
35
31
  * @example
36
32
  *
37
33
  * const onChange = val => console.log(`Value = ${val}`);
@@ -48,8 +44,6 @@ export function withEventTargetValue(func: (value: string) => void): (event: Rea
48
44
  *
49
45
  * This function returns the subdomain of the current URL.
50
46
  *
51
- * Usage:
52
- *
53
47
  * @example
54
48
  *
55
49
  * // Let the current url be "https://spinkart.example.com".
@@ -63,10 +57,6 @@ export function getSubdomain(): string;
63
57
  *
64
58
  * Curried: false
65
59
  *
66
- * Returns the specified hardcoded data after some delay for simulating an API
67
- *
68
- * call.
69
- *
70
60
  * This function will simulate an API call and retrieve the hardcoded success/error
71
61
  *
72
62
  * responses after some delay based on the given error probability. This function
@@ -85,18 +75,6 @@ export function simulateApiCall<T>(result: T, error?: any, errorProbability?: nu
85
75
  *
86
76
  * Copies the given string to clipboard and shows a success toaster message.
87
77
  *
88
- * This function accepts a string as an argument and copies it to the clipboard.
89
- *
90
- * Also, it accepts two optional arguments: a boolean flag to indicate whether a
91
- *
92
- * toaster should be shown and a message to be shown in the toaster. By default the
93
- *
94
- * show toaster flag is set to true and the toaster message is set to "Copied to
95
- *
96
- * clipboard!". You can override these defaults by passing the appropriate values
97
- *
98
- * to the function.
99
- *
100
78
  * @example
101
79
  *
102
80
  * copyToClipboard("https://spinkart.example.com", {
@@ -162,12 +140,6 @@ export const dateFormat: typeof timeFormat;
162
140
  *
163
141
  * locale.
164
142
  *
165
- * The function also accepts options, which will be forwarded to
166
- *
167
- * Number.prototype.toLocaleString, which can be used for additional
168
- *
169
- * configurations like rounding, currency, units etc.
170
- *
171
143
  * @example
172
144
  *
173
145
  * toLocale(1000000); // "1,000,000" when locale is "en-US"
@@ -207,8 +179,6 @@ type QueryParamsType = {
207
179
  *
208
180
  * This function returns all the query parameters of the current URL as an object.
209
181
  *
210
- * Usage:
211
- *
212
182
  * @example
213
183
  *
214
184
  * // Let the current url be "https://example.com?search=something&sort=date".
@@ -224,7 +194,7 @@ export function getQueryParams(options?: qsOptionsType): QueryParamsType;
224
194
  *
225
195
  * This function joins the given strings with hyphen.
226
196
  *
227
- * Usage:
197
+ * Any number of string arguments.
228
198
  *
229
199
  * @example
230
200
  *
@@ -240,12 +210,6 @@ export function joinHyphenCase(...args: string[]): string;
240
210
  *
241
211
  * stated wait time in milliseconds has elapsed since the last time it was invoked.
242
212
  *
243
- * It accepts the function to be debounced as the first argument, the delay in
244
- *
245
- * milliseconds as the second argument.
246
- *
247
- * Usage:
248
- *
249
213
  * @example
250
214
  *
251
215
  * const searchForProducts = debounce(async key => {
@@ -263,8 +227,6 @@ export function debounce<F extends Function>(func: F, delay?: number): F;
263
227
  *
264
228
  * This function will return true if the current user has the given permission.
265
229
  *
266
- * Usage:
267
- *
268
230
  * @example
269
231
  *
270
232
  * hasPermission("user.view_settings");
@@ -279,7 +241,7 @@ export function hasPermission(permission: string): boolean;
279
241
  *
280
242
  * permissions.
281
243
  *
282
- * Usage:
244
+ * permissions: Any number of permission strings.
283
245
  *
284
246
  * @example
285
247
  *
@@ -295,7 +257,7 @@ export function hasAnyPermission(...permissions: string[]): boolean;
295
257
  *
296
258
  * permissions.
297
259
  *
298
- * Usage:
260
+ * permissions: Any number of permission strings.
299
261
  *
300
262
  * @example
301
263
  *
@@ -311,12 +273,10 @@ type ChannelNameWithParams = {
311
273
  *
312
274
  * Curried: false
313
275
  *
314
- * This function will create subscription were consumer is subscribed to rails
276
+ * This function will create subscription where consumer is subscribed to rails
315
277
  *
316
278
  * action cable channel.
317
279
  *
318
- * Usage:
319
- *
320
280
  * @example
321
281
  *
322
282
  * const subscription = createSubscription(