@bigbinary/neeto-commons-frontend 2.1.39 → 3.0.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 +6 -51
- package/configs/scripts/dead-code-eliminator/index.js +1 -4
- package/configs/scripts/jsdoc-builder/utils.mjs +1 -1
- package/configs/webpack/helpers/customize-default-rules.js +1 -4
- package/initializers.cjs.js +10 -9
- package/initializers.cjs.js.map +1 -1
- package/initializers.js +2 -1
- package/initializers.js.map +1 -1
- package/package.json +3 -7
- package/react-utils.cjs.js +2 -2
- package/react-utils.cjs.js.map +1 -1
- package/react-utils.js +1 -1
- package/react-utils.js.map +1 -1
- package/utils.cjs.js +3 -3
- package/utils.cjs.js.map +1 -1
- package/utils.js +1 -1
- package/utils.js.map +1 -1
- package/pure.cjs.js +0 -1191
- package/pure.cjs.js.map +0 -1
- package/pure.d.ts +0 -1801
- package/pure.js +0 -1115
- package/pure.js.map +0 -1
package/pure.d.ts
DELETED
|
@@ -1,1801 +0,0 @@
|
|
|
1
|
-
import { Draft } from "immer";
|
|
2
|
-
export type Primitives = symbol | string | number | boolean | null | undefined;
|
|
3
|
-
export type ObjectAndPrimitives = Primitives | object;
|
|
4
|
-
type KeyType = string | number | symbol;
|
|
5
|
-
type NilOr<T> = T | null | undefined;
|
|
6
|
-
type Matchable<Obj, Parent, key extends keyof Obj> = ((object: Obj[key], parent: Parent) => boolean) | MatchPattern<Obj[key], Parent> | Primitives;
|
|
7
|
-
type MatchPattern<Obj = any, Parent = Obj> = Obj extends any[] ? Matchable<Obj, Parent, number>[] | {
|
|
8
|
-
[key: number]: Matchable<Obj, Parent, number>;
|
|
9
|
-
} : Obj extends Primitives ? Obj : ({ [key in keyof Partial<Obj>]: Matchable<Obj, Parent, key> } & {
|
|
10
|
-
[key: KeyType]: Matchable<any, Parent, KeyType>;
|
|
11
|
-
});
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* The camelToSnakeCase function converts a camelCase string to snake_case.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
*
|
|
18
|
-
* camelToSnakeCase("firstName"); // "first_name"
|
|
19
|
-
* @endexample
|
|
20
|
-
*/
|
|
21
|
-
export function camelToSnakeCase(string: string): string;
|
|
22
|
-
export function _camelToSnakeCase(string: NilOr<string>): NilOr<string>;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* The capitalize function converts the first character of a string to uppercase.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
*
|
|
29
|
-
* capitalize("oliver"); // "Oliver"
|
|
30
|
-
* capitalize("OLIVER"); // "OLIVER"
|
|
31
|
-
* capitalize("oLIVER"); // "OLIVER"
|
|
32
|
-
* @endexample
|
|
33
|
-
*/
|
|
34
|
-
export function capitalize(string: string): string;
|
|
35
|
-
export function _capitalize(string: NilOr<string>): NilOr<string>;
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* The copyKeys function is similar to the renameKeys function
|
|
39
|
-
*
|
|
40
|
-
* but retains both the source and destination keys in the resulting array. For
|
|
41
|
-
*
|
|
42
|
-
* deep copying of nested objects refer to copyKeysDeep
|
|
43
|
-
*
|
|
44
|
-
* function.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
*
|
|
48
|
-
* const data = [
|
|
49
|
-
* { id: 1, name: "Tomato", quantity: 10 },
|
|
50
|
-
* { id: 2, name: "Potato", quantity: 20 },
|
|
51
|
-
* ];
|
|
52
|
-
*
|
|
53
|
-
* // copy name to label and id to value
|
|
54
|
-
* copyKeys({ name: "label", id: "value" }, data);
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* output: [
|
|
58
|
-
* { label: "Tomato", value: 1, id: 1, name: "Tomato", quantity: 10 },
|
|
59
|
-
* { label: "Potato", value: 2, id: 2, name: "Potato", quantity: 20 },
|
|
60
|
-
* ];
|
|
61
|
-
*
|
|
62
|
-
* @endexample
|
|
63
|
-
*/
|
|
64
|
-
export function copyKeys<T>(keyMap: { [key in keyof Partial<T>]: string }, objectArray: T[]): (T & {
|
|
65
|
-
[key: string]: any;
|
|
66
|
-
})[];
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
* The copyKeys function is similar to the renameKeys function
|
|
70
|
-
*
|
|
71
|
-
* but retains both the source and destination keys in the resulting array. For
|
|
72
|
-
*
|
|
73
|
-
* deep copying of nested objects refer to copyKeysDeep
|
|
74
|
-
*
|
|
75
|
-
* function.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
*
|
|
79
|
-
* const data = [
|
|
80
|
-
* { id: 1, name: "Tomato", quantity: 10 },
|
|
81
|
-
* { id: 2, name: "Potato", quantity: 20 },
|
|
82
|
-
* ];
|
|
83
|
-
*
|
|
84
|
-
* // copy name to label and id to value
|
|
85
|
-
* copyKeys({ name: "label", id: "value" }, data);
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* output: [
|
|
89
|
-
* { label: "Tomato", value: 1, id: 1, name: "Tomato", quantity: 10 },
|
|
90
|
-
* { label: "Potato", value: 2, id: 2, name: "Potato", quantity: 20 },
|
|
91
|
-
* ];
|
|
92
|
-
*
|
|
93
|
-
* @endexample
|
|
94
|
-
*/
|
|
95
|
-
export function copyKeys(keyMap: {
|
|
96
|
-
[key: string]: string;
|
|
97
|
-
}): <T>(objectArray: T[]) => (T & {
|
|
98
|
-
[key: string]: any;
|
|
99
|
-
})[];
|
|
100
|
-
export function _copyKeys<T>(keyMap: { [key in keyof Partial<T>]: string }, objectArray: NilOr<T[]>): NilOr<(T & {
|
|
101
|
-
[key: string]: any;
|
|
102
|
-
})[]>;
|
|
103
|
-
export function _copyKeys(keyMap: {
|
|
104
|
-
[key: string]: string;
|
|
105
|
-
}): <T>(objectArray: NilOr<T[]>) => NilOr<(T & {
|
|
106
|
-
[key: string]: any;
|
|
107
|
-
})[]>;
|
|
108
|
-
/**
|
|
109
|
-
*
|
|
110
|
-
* The copyKeysDeep function is an advanced version of the
|
|
111
|
-
*
|
|
112
|
-
* copyKeys function. It supports deep copying with nested objects
|
|
113
|
-
*
|
|
114
|
-
* and offers flexibility in specifying key mappings for the copy operation.
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
*
|
|
118
|
-
* const data = [
|
|
119
|
-
* {
|
|
120
|
-
* id: 1,
|
|
121
|
-
* name: "Tomato",
|
|
122
|
-
* quantity: 10,
|
|
123
|
-
* user: { id: 1, name: "John", bonusQty: 3 },
|
|
124
|
-
* address: { street: "First street", pin: 101283 },
|
|
125
|
-
* },
|
|
126
|
-
* {
|
|
127
|
-
* id: 2,
|
|
128
|
-
* name: "Potato",
|
|
129
|
-
* quantity: 20,
|
|
130
|
-
* user: { id: 2, name: "Jane", bonusQty: 2 },
|
|
131
|
-
* address: { street: "Second street", pin: 998472 },
|
|
132
|
-
* },
|
|
133
|
-
* ];
|
|
134
|
-
*
|
|
135
|
-
* // Create a new array to hold the transformed objects
|
|
136
|
-
* copyKeysDeep(
|
|
137
|
-
* {
|
|
138
|
-
* name: "label",
|
|
139
|
-
* quantity: (qty, root) => qty + root.user.bonusQty,
|
|
140
|
-
* user: { pin: ["address", "pin"] },
|
|
141
|
-
* },
|
|
142
|
-
* data
|
|
143
|
-
* );
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* output: [
|
|
147
|
-
* {
|
|
148
|
-
* label: "Tomato", // label copied
|
|
149
|
-
* id: 1,
|
|
150
|
-
* name: "Tomato",
|
|
151
|
-
* quantity: 13, // quantity updated
|
|
152
|
-
* user: { pin: 101283, id: 1, name: "John", bonusQty: 3 }, // pin copied
|
|
153
|
-
* address: { street: "First street", pin: 101283 },
|
|
154
|
-
* },
|
|
155
|
-
* {
|
|
156
|
-
* label: "Potato",
|
|
157
|
-
* id: 2,
|
|
158
|
-
* name: "Potato",
|
|
159
|
-
* quantity: 22,
|
|
160
|
-
* user: { id: 2, name: "Jane", bonusQty: 2 },
|
|
161
|
-
* address: { pin: 998472, street: "Second street" },
|
|
162
|
-
* },
|
|
163
|
-
* ];
|
|
164
|
-
*
|
|
165
|
-
* @endexample
|
|
166
|
-
*/
|
|
167
|
-
export function copyKeysDeep(keyMap: object, objectArray: object[]): object[];
|
|
168
|
-
/**
|
|
169
|
-
*
|
|
170
|
-
* The copyKeysDeep function is an advanced version of the
|
|
171
|
-
*
|
|
172
|
-
* copyKeys function. It supports deep copying with nested objects
|
|
173
|
-
*
|
|
174
|
-
* and offers flexibility in specifying key mappings for the copy operation.
|
|
175
|
-
*
|
|
176
|
-
* @example
|
|
177
|
-
*
|
|
178
|
-
* const data = [
|
|
179
|
-
* {
|
|
180
|
-
* id: 1,
|
|
181
|
-
* name: "Tomato",
|
|
182
|
-
* quantity: 10,
|
|
183
|
-
* user: { id: 1, name: "John", bonusQty: 3 },
|
|
184
|
-
* address: { street: "First street", pin: 101283 },
|
|
185
|
-
* },
|
|
186
|
-
* {
|
|
187
|
-
* id: 2,
|
|
188
|
-
* name: "Potato",
|
|
189
|
-
* quantity: 20,
|
|
190
|
-
* user: { id: 2, name: "Jane", bonusQty: 2 },
|
|
191
|
-
* address: { street: "Second street", pin: 998472 },
|
|
192
|
-
* },
|
|
193
|
-
* ];
|
|
194
|
-
*
|
|
195
|
-
* // Create a new array to hold the transformed objects
|
|
196
|
-
* copyKeysDeep(
|
|
197
|
-
* {
|
|
198
|
-
* name: "label",
|
|
199
|
-
* quantity: (qty, root) => qty + root.user.bonusQty,
|
|
200
|
-
* user: { pin: ["address", "pin"] },
|
|
201
|
-
* },
|
|
202
|
-
* data
|
|
203
|
-
* );
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* output: [
|
|
207
|
-
* {
|
|
208
|
-
* label: "Tomato", // label copied
|
|
209
|
-
* id: 1,
|
|
210
|
-
* name: "Tomato",
|
|
211
|
-
* quantity: 13, // quantity updated
|
|
212
|
-
* user: { pin: 101283, id: 1, name: "John", bonusQty: 3 }, // pin copied
|
|
213
|
-
* address: { street: "First street", pin: 101283 },
|
|
214
|
-
* },
|
|
215
|
-
* {
|
|
216
|
-
* label: "Potato",
|
|
217
|
-
* id: 2,
|
|
218
|
-
* name: "Potato",
|
|
219
|
-
* quantity: 22,
|
|
220
|
-
* user: { id: 2, name: "Jane", bonusQty: 2 },
|
|
221
|
-
* address: { pin: 998472, street: "Second street" },
|
|
222
|
-
* },
|
|
223
|
-
* ];
|
|
224
|
-
*
|
|
225
|
-
* @endexample
|
|
226
|
-
*/
|
|
227
|
-
export function copyKeysDeep(keyMap: object): (objectArray: object[]) => object[];
|
|
228
|
-
export function _copyKeysDeep(keyMap: object, objectArray: NilOr<object[]>): NilOr<object[]>;
|
|
229
|
-
export function _copyKeysDeep(keyMap: object): (objectArray: NilOr<object[]>) => NilOr<object[]>;
|
|
230
|
-
/**
|
|
231
|
-
*
|
|
232
|
-
* The countBy function counts the number of items in an array that match the
|
|
233
|
-
*
|
|
234
|
-
* provided pattern.
|
|
235
|
-
*
|
|
236
|
-
* @example
|
|
237
|
-
*
|
|
238
|
-
* const array = [
|
|
239
|
-
* { name: "Oliver", age: 20 },
|
|
240
|
-
* { name: "Sam", age: 40 },
|
|
241
|
-
* { name: "George", age: 41 },
|
|
242
|
-
* { name: "Smith", age: 20 },
|
|
243
|
-
* ];
|
|
244
|
-
*
|
|
245
|
-
* countBy({ age: 20 }, array); // returns 2
|
|
246
|
-
* countBy({ age: gt(__, 40) }, array); // returns 1
|
|
247
|
-
* countBy({ age: 50 }, array); // returns 0
|
|
248
|
-
* @endexample
|
|
249
|
-
*/
|
|
250
|
-
export function countBy<T>(pattern: MatchPattern<T>, entityArray: T[]): number;
|
|
251
|
-
/**
|
|
252
|
-
*
|
|
253
|
-
* The countBy function counts the number of items in an array that match the
|
|
254
|
-
*
|
|
255
|
-
* provided pattern.
|
|
256
|
-
*
|
|
257
|
-
* @example
|
|
258
|
-
*
|
|
259
|
-
* const array = [
|
|
260
|
-
* { name: "Oliver", age: 20 },
|
|
261
|
-
* { name: "Sam", age: 40 },
|
|
262
|
-
* { name: "George", age: 41 },
|
|
263
|
-
* { name: "Smith", age: 20 },
|
|
264
|
-
* ];
|
|
265
|
-
*
|
|
266
|
-
* countBy({ age: 20 }, array); // returns 2
|
|
267
|
-
* countBy({ age: gt(__, 40) }, array); // returns 1
|
|
268
|
-
* countBy({ age: 50 }, array); // returns 0
|
|
269
|
-
* @endexample
|
|
270
|
-
*/
|
|
271
|
-
export function countBy(pattern: MatchPattern): (entityArray: object[]) => number;
|
|
272
|
-
export function _countBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>): NilOr<number>;
|
|
273
|
-
export function _countBy(pattern: MatchPattern): (entityArray: NilOr<object[]>) => NilOr<number>;
|
|
274
|
-
/**
|
|
275
|
-
*
|
|
276
|
-
* The deepFreezeObject function is used to make an object immutable by
|
|
277
|
-
*
|
|
278
|
-
* recursively freezing each property that is of type object. Freezing an object
|
|
279
|
-
*
|
|
280
|
-
* prevents any changes to its properties, making it effectively immutable.
|
|
281
|
-
*
|
|
282
|
-
* @example
|
|
283
|
-
*
|
|
284
|
-
* const user = {
|
|
285
|
-
* address: { city: "Miami", phoneNumber: "389791382" },
|
|
286
|
-
* firstName: "Oliver",
|
|
287
|
-
* };
|
|
288
|
-
* deepFreezeObject(user);
|
|
289
|
-
*
|
|
290
|
-
* user.address.phoneNumber = "123456789"; // fails silently in non-strict mode
|
|
291
|
-
* user.lastName = "Smith"; // fails silently in non-strict mode
|
|
292
|
-
*
|
|
293
|
-
* console.log(user);
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* {
|
|
297
|
-
* address: { city: "Miami", phoneNumber: "389791382" },
|
|
298
|
-
* firstName: "Oliver",
|
|
299
|
-
* };
|
|
300
|
-
*
|
|
301
|
-
* @endexample
|
|
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.
|
|
305
|
-
*
|
|
306
|
-
* @example
|
|
307
|
-
*
|
|
308
|
-
* "use strict"; user.address.phoneNumber = "123456789";
|
|
309
|
-
*
|
|
310
|
-
* Cannot assign to read only property 'phoneNumber' of object '#<Object>
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
* "use strict"; user.lastName = "Smith";
|
|
314
|
-
*
|
|
315
|
-
* Cannot add property lastName, object is not extensible
|
|
316
|
-
*
|
|
317
|
-
* @endexample
|
|
318
|
-
*/
|
|
319
|
-
export function deepFreezeObject<T>(object: T): Readonly<T>;
|
|
320
|
-
/**
|
|
321
|
-
*
|
|
322
|
-
* The dynamicArray function constructs an array of a specified length using a
|
|
323
|
-
*
|
|
324
|
-
* provided function to generate each element. The function takes the index as a
|
|
325
|
-
*
|
|
326
|
-
* parameter and is expected to return the element corresponding to that index.
|
|
327
|
-
*
|
|
328
|
-
* This function does not include a failsafe mechanism, so it is important to
|
|
329
|
-
*
|
|
330
|
-
* ensure that the provided function and length are valid to prevent errors.
|
|
331
|
-
*
|
|
332
|
-
* @example
|
|
333
|
-
*
|
|
334
|
-
* dynamicArray(3, index => `option ${index + 1}`);
|
|
335
|
-
*
|
|
336
|
-
* // output: ["option 1", "option 2", "option 3"]
|
|
337
|
-
* @endexample
|
|
338
|
-
*/
|
|
339
|
-
export function dynamicArray<T>(count: number, elementGenerator: (index: number) => T): T[];
|
|
340
|
-
/**
|
|
341
|
-
*
|
|
342
|
-
* The existsBy function searches for an item in the array that matches the
|
|
343
|
-
*
|
|
344
|
-
* provided pattern and returns true if found, or false otherwise.
|
|
345
|
-
*
|
|
346
|
-
* @example
|
|
347
|
-
*
|
|
348
|
-
* const array = [
|
|
349
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
|
|
350
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
|
|
351
|
-
* ];
|
|
352
|
-
*
|
|
353
|
-
* existsBy({ name: "Sam" }, array); // true
|
|
354
|
-
* existsBy({ name: "Harry" }, array); // false
|
|
355
|
-
* @endexample
|
|
356
|
-
*/
|
|
357
|
-
export function existsBy<T>(pattern: MatchPattern<T>, entityArray: T[]): boolean;
|
|
358
|
-
/**
|
|
359
|
-
*
|
|
360
|
-
* The existsBy function searches for an item in the array that matches the
|
|
361
|
-
*
|
|
362
|
-
* provided pattern and returns true if found, or false otherwise.
|
|
363
|
-
*
|
|
364
|
-
* @example
|
|
365
|
-
*
|
|
366
|
-
* const array = [
|
|
367
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
|
|
368
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
|
|
369
|
-
* ];
|
|
370
|
-
*
|
|
371
|
-
* existsBy({ name: "Sam" }, array); // true
|
|
372
|
-
* existsBy({ name: "Harry" }, array); // false
|
|
373
|
-
* @endexample
|
|
374
|
-
*/
|
|
375
|
-
export function existsBy(pattern: MatchPattern): (entityArray: object[]) => boolean;
|
|
376
|
-
export function _existsBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>): NilOr<boolean>;
|
|
377
|
-
export function _existsBy(pattern: MatchPattern): (entityArray: NilOr<object[]>) => NilOr<boolean>;
|
|
378
|
-
/**
|
|
379
|
-
*
|
|
380
|
-
* The existsById function searches for an item in the provided array using the
|
|
381
|
-
*
|
|
382
|
-
* given id.
|
|
383
|
-
*
|
|
384
|
-
* @example
|
|
385
|
-
*
|
|
386
|
-
* const array = [
|
|
387
|
-
* { id: 1, name: "Sam" },
|
|
388
|
-
* { id: 2, name: "Oliver" },
|
|
389
|
-
* ];
|
|
390
|
-
*
|
|
391
|
-
* existsById(2, array); // true Oliver's id is 2
|
|
392
|
-
* existsById(5, array); // false no one has an id of 5
|
|
393
|
-
* @endexample
|
|
394
|
-
*/
|
|
395
|
-
export function existsById(id: any, entityArray: object[]): boolean;
|
|
396
|
-
/**
|
|
397
|
-
*
|
|
398
|
-
* The existsById function searches for an item in the provided array using the
|
|
399
|
-
*
|
|
400
|
-
* given id.
|
|
401
|
-
*
|
|
402
|
-
* @example
|
|
403
|
-
*
|
|
404
|
-
* const array = [
|
|
405
|
-
* { id: 1, name: "Sam" },
|
|
406
|
-
* { id: 2, name: "Oliver" },
|
|
407
|
-
* ];
|
|
408
|
-
*
|
|
409
|
-
* existsById(2, array); // true Oliver's id is 2
|
|
410
|
-
* existsById(5, array); // false no one has an id of 5
|
|
411
|
-
* @endexample
|
|
412
|
-
*/
|
|
413
|
-
export function existsById(id: any): (entityArray: object[]) => boolean;
|
|
414
|
-
export function _existsById(id: any, entityArray: NilOr<object[]>): NilOr<boolean>;
|
|
415
|
-
export function _existsById(id: any): (entityArray: NilOr<object[]>) => NilOr<boolean>;
|
|
416
|
-
/**
|
|
417
|
-
*
|
|
418
|
-
* The filterBy function filters an array of items based on pattern matching.
|
|
419
|
-
*
|
|
420
|
-
* @example
|
|
421
|
-
*
|
|
422
|
-
* const array = [
|
|
423
|
-
* { name: "Oliver", age: 20 },
|
|
424
|
-
* { name: "Sam", age: 40 },
|
|
425
|
-
* { name: "George", age: 41 },
|
|
426
|
-
* { name: "Smith", age: 20 },
|
|
427
|
-
* ];
|
|
428
|
-
*
|
|
429
|
-
* filterBy({ age: 20 }, array); // [{ name: "Oliver", age: 20 }, { name: "Smith", age: 20 }]
|
|
430
|
-
* filterBy({ age: gt(__, 40) }, array); // [{ name: "George", age: 41 }]
|
|
431
|
-
* filterBy({ age: 50 }, array); // []
|
|
432
|
-
* @endexample
|
|
433
|
-
*/
|
|
434
|
-
export function filterBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T[];
|
|
435
|
-
/**
|
|
436
|
-
*
|
|
437
|
-
* The filterBy function filters an array of items based on pattern matching.
|
|
438
|
-
*
|
|
439
|
-
* @example
|
|
440
|
-
*
|
|
441
|
-
* const array = [
|
|
442
|
-
* { name: "Oliver", age: 20 },
|
|
443
|
-
* { name: "Sam", age: 40 },
|
|
444
|
-
* { name: "George", age: 41 },
|
|
445
|
-
* { name: "Smith", age: 20 },
|
|
446
|
-
* ];
|
|
447
|
-
*
|
|
448
|
-
* filterBy({ age: 20 }, array); // [{ name: "Oliver", age: 20 }, { name: "Smith", age: 20 }]
|
|
449
|
-
* filterBy({ age: gt(__, 40) }, array); // [{ name: "George", age: 41 }]
|
|
450
|
-
* filterBy({ age: 50 }, array); // []
|
|
451
|
-
* @endexample
|
|
452
|
-
*/
|
|
453
|
-
export function filterBy(pattern: MatchPattern): <T>(entityArray: T[]) => T[];
|
|
454
|
-
export function _filterBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>): NilOr<T[]>;
|
|
455
|
-
export function _filterBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
456
|
-
/**
|
|
457
|
-
*
|
|
458
|
-
* The filterNonNull function accepts an object and returns a new object with
|
|
459
|
-
*
|
|
460
|
-
* only the properties that are not null or undefined. It filters out
|
|
461
|
-
*
|
|
462
|
-
* properties with these values, creating a new object with only the non-null and
|
|
463
|
-
*
|
|
464
|
-
* non-undefined properties.
|
|
465
|
-
*
|
|
466
|
-
* @example
|
|
467
|
-
*
|
|
468
|
-
* filterNonNull({
|
|
469
|
-
* firstName: "Oliver",
|
|
470
|
-
* lastName: null,
|
|
471
|
-
* phoneNumbers: { home: undefined, office: "1234567890" },
|
|
472
|
-
* });
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
* {
|
|
476
|
-
* firstName: "Oliver",
|
|
477
|
-
* phoneNumbers: { office: "1234567890" },
|
|
478
|
-
* }
|
|
479
|
-
*
|
|
480
|
-
* @endexample
|
|
481
|
-
*/
|
|
482
|
-
export function filterNonNull(object: object): object;
|
|
483
|
-
export function _filterNonNull(object: NilOr<object>): NilOr<object>;
|
|
484
|
-
/**
|
|
485
|
-
*
|
|
486
|
-
* The findBy function locates the first item in the array that matches the
|
|
487
|
-
*
|
|
488
|
-
* provided pattern.
|
|
489
|
-
*
|
|
490
|
-
* @example
|
|
491
|
-
*
|
|
492
|
-
* const array = [
|
|
493
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 123456 } },
|
|
494
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 654321 } },
|
|
495
|
-
* ];
|
|
496
|
-
*
|
|
497
|
-
* findBy({ name: "Sam" }, array); // returns object corresponding to Sam
|
|
498
|
-
* findBy({ id: 2, address: { pin: 654321 } }, array); // returns object corresponding to Oliver
|
|
499
|
-
* findBy({ id: 3 }, array); // returns undefined
|
|
500
|
-
* @endexample
|
|
501
|
-
*/
|
|
502
|
-
export function findBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T;
|
|
503
|
-
/**
|
|
504
|
-
*
|
|
505
|
-
* The findBy function locates the first item in the array that matches the
|
|
506
|
-
*
|
|
507
|
-
* provided pattern.
|
|
508
|
-
*
|
|
509
|
-
* @example
|
|
510
|
-
*
|
|
511
|
-
* const array = [
|
|
512
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 123456 } },
|
|
513
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 654321 } },
|
|
514
|
-
* ];
|
|
515
|
-
*
|
|
516
|
-
* findBy({ name: "Sam" }, array); // returns object corresponding to Sam
|
|
517
|
-
* findBy({ id: 2, address: { pin: 654321 } }, array); // returns object corresponding to Oliver
|
|
518
|
-
* findBy({ id: 3 }, array); // returns undefined
|
|
519
|
-
* @endexample
|
|
520
|
-
*/
|
|
521
|
-
export function findBy(pattern: MatchPattern): <T>(entityArray: T[]) => T;
|
|
522
|
-
export function _findBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>): NilOr<T>;
|
|
523
|
-
export function _findBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) => NilOr<T>;
|
|
524
|
-
/**
|
|
525
|
-
*
|
|
526
|
-
* The findById function is used to locate an object within an array based on the
|
|
527
|
-
*
|
|
528
|
-
* provided Id.
|
|
529
|
-
*
|
|
530
|
-
* @example
|
|
531
|
-
*
|
|
532
|
-
* const array = [
|
|
533
|
-
* { id: 1, name: "Sam" },
|
|
534
|
-
* { id: 2, name: "Oliver" },
|
|
535
|
-
* ];
|
|
536
|
-
* const idOfItemToBeFind = 2;
|
|
537
|
-
*
|
|
538
|
-
* findById(idOfItemToBeFind, array);
|
|
539
|
-
* // { id: 2, name: "Oliver" }
|
|
540
|
-
* @endexample
|
|
541
|
-
*/
|
|
542
|
-
export function findById<T>(id: any, entityArray: T[]): T;
|
|
543
|
-
/**
|
|
544
|
-
*
|
|
545
|
-
* The findById function is used to locate an object within an array based on the
|
|
546
|
-
*
|
|
547
|
-
* provided Id.
|
|
548
|
-
*
|
|
549
|
-
* @example
|
|
550
|
-
*
|
|
551
|
-
* const array = [
|
|
552
|
-
* { id: 1, name: "Sam" },
|
|
553
|
-
* { id: 2, name: "Oliver" },
|
|
554
|
-
* ];
|
|
555
|
-
* const idOfItemToBeFind = 2;
|
|
556
|
-
*
|
|
557
|
-
* findById(idOfItemToBeFind, array);
|
|
558
|
-
* // { id: 2, name: "Oliver" }
|
|
559
|
-
* @endexample
|
|
560
|
-
*/
|
|
561
|
-
export function findById(id: any): <T>(entityArray: T[]) => T;
|
|
562
|
-
export function _findById<T>(id: any, entityArray: NilOr<T[]>): NilOr<T>;
|
|
563
|
-
export function _findById(id: any): <T>(entityArray: NilOr<T[]>) => NilOr<T>;
|
|
564
|
-
/**
|
|
565
|
-
*
|
|
566
|
-
* The findIndexBy function finds the index of the item in the array that matches
|
|
567
|
-
*
|
|
568
|
-
* the provided pattern.
|
|
569
|
-
*
|
|
570
|
-
* @example
|
|
571
|
-
*
|
|
572
|
-
* const array = [
|
|
573
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 123456 } },
|
|
574
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 654321 } },
|
|
575
|
-
* ];
|
|
576
|
-
*
|
|
577
|
-
* findIndexBy({ name: "Sam" }, array); // returns 0
|
|
578
|
-
* findIndexBy({ id: 2, address: { pin: 654321 } }, array); // returns 1
|
|
579
|
-
* findIndexBy({ id: 3 }, array); // returns -1
|
|
580
|
-
* @endexample
|
|
581
|
-
*/
|
|
582
|
-
export function findIndexBy<T>(pattern: MatchPattern<T>, entityArray: T[]): number;
|
|
583
|
-
/**
|
|
584
|
-
*
|
|
585
|
-
* The findIndexBy function finds the index of the item in the array that matches
|
|
586
|
-
*
|
|
587
|
-
* the provided pattern.
|
|
588
|
-
*
|
|
589
|
-
* @example
|
|
590
|
-
*
|
|
591
|
-
* const array = [
|
|
592
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 123456 } },
|
|
593
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 654321 } },
|
|
594
|
-
* ];
|
|
595
|
-
*
|
|
596
|
-
* findIndexBy({ name: "Sam" }, array); // returns 0
|
|
597
|
-
* findIndexBy({ id: 2, address: { pin: 654321 } }, array); // returns 1
|
|
598
|
-
* findIndexBy({ id: 3 }, array); // returns -1
|
|
599
|
-
* @endexample
|
|
600
|
-
*/
|
|
601
|
-
export function findIndexBy(pattern: MatchPattern): (entityArray: object[]) => number;
|
|
602
|
-
export function _findIndexBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>): NilOr<number>;
|
|
603
|
-
export function _findIndexBy(pattern: MatchPattern): (entityArray: NilOr<object[]>) => NilOr<number>;
|
|
604
|
-
/**
|
|
605
|
-
*
|
|
606
|
-
* The findIndexById function is used to find the index of an item within an
|
|
607
|
-
*
|
|
608
|
-
* array of items based on the id property of the entities within it.
|
|
609
|
-
*
|
|
610
|
-
* @example
|
|
611
|
-
*
|
|
612
|
-
* const array = [
|
|
613
|
-
* { id: "1001", name: "Sam" },
|
|
614
|
-
* { id: "2001", name: "Oliver" },
|
|
615
|
-
* ];
|
|
616
|
-
*
|
|
617
|
-
* findIndexById("2001", array); // returns 1
|
|
618
|
-
* findIndexById("1001", array); // returns 0
|
|
619
|
-
* findIndexById("3001", array); // returns -1
|
|
620
|
-
* @endexample
|
|
621
|
-
*/
|
|
622
|
-
export function findIndexById(id: any, entityArray: object[]): number;
|
|
623
|
-
/**
|
|
624
|
-
*
|
|
625
|
-
* The findIndexById function is used to find the index of an item within an
|
|
626
|
-
*
|
|
627
|
-
* array of items based on the id property of the entities within it.
|
|
628
|
-
*
|
|
629
|
-
* @example
|
|
630
|
-
*
|
|
631
|
-
* const array = [
|
|
632
|
-
* { id: "1001", name: "Sam" },
|
|
633
|
-
* { id: "2001", name: "Oliver" },
|
|
634
|
-
* ];
|
|
635
|
-
*
|
|
636
|
-
* findIndexById("2001", array); // returns 1
|
|
637
|
-
* findIndexById("1001", array); // returns 0
|
|
638
|
-
* findIndexById("3001", array); // returns -1
|
|
639
|
-
* @endexample
|
|
640
|
-
*/
|
|
641
|
-
export function findIndexById(id: any): (entityArray: object[]) => number;
|
|
642
|
-
export function _findIndexById(id: any, entityArray: NilOr<object[]>): NilOr<number>;
|
|
643
|
-
export function _findIndexById(id: any): (entityArray: NilOr<object[]>) => NilOr<number>;
|
|
644
|
-
/**
|
|
645
|
-
*
|
|
646
|
-
* The findLastBy function finds the last item in the array that matches the
|
|
647
|
-
*
|
|
648
|
-
* provided pattern.
|
|
649
|
-
*
|
|
650
|
-
* @example
|
|
651
|
-
*
|
|
652
|
-
* const array = [
|
|
653
|
-
* { name: "Oliver", age: 20 },
|
|
654
|
-
* { name: "Sam", age: 40 },
|
|
655
|
-
* { name: "George", age: 41 },
|
|
656
|
-
* { name: "Smith", age: 20 },
|
|
657
|
-
* ];
|
|
658
|
-
*
|
|
659
|
-
* findLastBy({ age: 20 }, array); // { name: "Smith", age: 20 }
|
|
660
|
-
* findLastBy({ name: includes("e") }, array); // { name: "George", age: 41 }
|
|
661
|
-
* @endexample
|
|
662
|
-
*/
|
|
663
|
-
export function findLastBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T;
|
|
664
|
-
/**
|
|
665
|
-
*
|
|
666
|
-
* The findLastBy function finds the last item in the array that matches the
|
|
667
|
-
*
|
|
668
|
-
* provided pattern.
|
|
669
|
-
*
|
|
670
|
-
* @example
|
|
671
|
-
*
|
|
672
|
-
* const array = [
|
|
673
|
-
* { name: "Oliver", age: 20 },
|
|
674
|
-
* { name: "Sam", age: 40 },
|
|
675
|
-
* { name: "George", age: 41 },
|
|
676
|
-
* { name: "Smith", age: 20 },
|
|
677
|
-
* ];
|
|
678
|
-
*
|
|
679
|
-
* findLastBy({ age: 20 }, array); // { name: "Smith", age: 20 }
|
|
680
|
-
* findLastBy({ name: includes("e") }, array); // { name: "George", age: 41 }
|
|
681
|
-
* @endexample
|
|
682
|
-
*/
|
|
683
|
-
export function findLastBy(pattern: MatchPattern): <T>(entityArray: T[]) => T;
|
|
684
|
-
export function _findLastBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>): NilOr<T>;
|
|
685
|
-
export function _findLastBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) => NilOr<T>;
|
|
686
|
-
/**
|
|
687
|
-
*
|
|
688
|
-
* The findLastIndexBy function finds the last index of an item in the array that
|
|
689
|
-
*
|
|
690
|
-
* matches the provided pattern.
|
|
691
|
-
*
|
|
692
|
-
* @example
|
|
693
|
-
*
|
|
694
|
-
* const array = [
|
|
695
|
-
* { name: "Oliver", age: 20 },
|
|
696
|
-
* { name: "Sam", age: 40 },
|
|
697
|
-
* { name: "George", age: 41 },
|
|
698
|
-
* { name: "Smith", age: 20 },
|
|
699
|
-
* ];
|
|
700
|
-
*
|
|
701
|
-
* findLastIndexBy({ age: 20 }, array); // returns 3
|
|
702
|
-
* findLastIndexBy({ name: includes("e") }, array); // returns 2
|
|
703
|
-
* @endexample
|
|
704
|
-
*/
|
|
705
|
-
export function findLastIndexBy(id: any, entityArray: object[]): number;
|
|
706
|
-
/**
|
|
707
|
-
*
|
|
708
|
-
* The findLastIndexBy function finds the last index of an item in the array that
|
|
709
|
-
*
|
|
710
|
-
* matches the provided pattern.
|
|
711
|
-
*
|
|
712
|
-
* @example
|
|
713
|
-
*
|
|
714
|
-
* const array = [
|
|
715
|
-
* { name: "Oliver", age: 20 },
|
|
716
|
-
* { name: "Sam", age: 40 },
|
|
717
|
-
* { name: "George", age: 41 },
|
|
718
|
-
* { name: "Smith", age: 20 },
|
|
719
|
-
* ];
|
|
720
|
-
*
|
|
721
|
-
* findLastIndexBy({ age: 20 }, array); // returns 3
|
|
722
|
-
* findLastIndexBy({ name: includes("e") }, array); // returns 2
|
|
723
|
-
* @endexample
|
|
724
|
-
*/
|
|
725
|
-
export function findLastIndexBy(id: any): (entityArray: object[]) => number;
|
|
726
|
-
export function _findLastIndexBy(id: any, entityArray: NilOr<object[]>): NilOr<number>;
|
|
727
|
-
export function _findLastIndexBy(id: any): (entityArray: NilOr<object[]>) => NilOr<number>;
|
|
728
|
-
/**
|
|
729
|
-
*
|
|
730
|
-
* The getRandomInt function generates a random integer within a specified range.
|
|
731
|
-
*
|
|
732
|
-
* If only one argument is provided, it is considered as the upper bound, and the
|
|
733
|
-
*
|
|
734
|
-
* lower bound is assumed to be 0.
|
|
735
|
-
*
|
|
736
|
-
* @example
|
|
737
|
-
*
|
|
738
|
-
* getRandomInt(); // returns a random integer between 0 and 9007199254740991 (MAX_SAFE_INTEGER)
|
|
739
|
-
* getRandomInt(10); // returns a random integer between 0 and 10
|
|
740
|
-
* getRandomInt(1, 5); // returns a random integer between 1 and 5
|
|
741
|
-
* @endexample
|
|
742
|
-
*/
|
|
743
|
-
export function getRandomInt(a?: number, b?: number): number;
|
|
744
|
-
/**
|
|
745
|
-
*
|
|
746
|
-
* The humanize function converts common developer-friendly string formats such
|
|
747
|
-
*
|
|
748
|
-
* as camelCase, snake_case, dash-case, etc., into human-readable strings.
|
|
749
|
-
*
|
|
750
|
-
* @example
|
|
751
|
-
*
|
|
752
|
-
* humanize("helloWorld"); // "Hello world"
|
|
753
|
-
* humanize("hello-world"); // "Hello world"
|
|
754
|
-
* humanize("__hello_world"); // "Hello world"
|
|
755
|
-
* humanize("HelloUSA"); // "Hello usa"
|
|
756
|
-
* @endexample
|
|
757
|
-
*/
|
|
758
|
-
export function humanize(string: string): string;
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
817
|
-
export function isNot(a: any): (b: any) => boolean;
|
|
818
|
-
/**
|
|
819
|
-
*
|
|
820
|
-
* The isNotEmpty returns true if the given value is not empty (includes
|
|
821
|
-
*
|
|
822
|
-
* strings, arrays, objects) and false otherwise. It provides the opposite
|
|
823
|
-
*
|
|
824
|
-
* behavior of checking if a value is empty, similar to the isEmpty function in
|
|
825
|
-
*
|
|
826
|
-
* Ramda.
|
|
827
|
-
*
|
|
828
|
-
* @example
|
|
829
|
-
*
|
|
830
|
-
* isNotEmpty(""); // returns false
|
|
831
|
-
* isNotEmpty(["a"]); // returns true
|
|
832
|
-
* isNotEmpty({ name: "Oliver" }); //return true
|
|
833
|
-
* @endexample
|
|
834
|
-
*/
|
|
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
|
-
*/
|
|
860
|
-
export function isNotEqualDeep(a: any, b: any): boolean;
|
|
861
|
-
/**
|
|
862
|
-
*
|
|
863
|
-
* The isNotEqualDeep function returns true if the given values are not equal,
|
|
864
|
-
*
|
|
865
|
-
* considering deep equality. It checks for deep inequality between objects or
|
|
866
|
-
*
|
|
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.
|
|
891
|
-
*
|
|
892
|
-
* @example
|
|
893
|
-
*
|
|
894
|
-
* keysToCamelCase({
|
|
895
|
-
* first_name: "Oliver",
|
|
896
|
-
* last_name: "Smith",
|
|
897
|
-
* address: { city: "Miami", phone_number: "389791382" },
|
|
898
|
-
* });
|
|
899
|
-
*
|
|
900
|
-
* {
|
|
901
|
-
* address: {city: 'Miami', phoneNumber: '389791382'},
|
|
902
|
-
* firstName: "Oliver",
|
|
903
|
-
* lastName: "Smith",
|
|
904
|
-
* }
|
|
905
|
-
*
|
|
906
|
-
* @endexample
|
|
907
|
-
*/
|
|
908
|
-
export function keysToCamelCase(object: any): any;
|
|
909
|
-
/**
|
|
910
|
-
*
|
|
911
|
-
* The keysToSnakeCase function recursively converts the camel-cased object keys
|
|
912
|
-
*
|
|
913
|
-
* to snake case.
|
|
914
|
-
*
|
|
915
|
-
* @example
|
|
916
|
-
*
|
|
917
|
-
* keysToSnakeCase({
|
|
918
|
-
* address: { city: "Miami", phoneNumber: "389791382" },
|
|
919
|
-
* firstName: "Oliver",
|
|
920
|
-
* lastName: "Smith",
|
|
921
|
-
* });
|
|
922
|
-
*
|
|
923
|
-
* {
|
|
924
|
-
* first_name: "Oliver",
|
|
925
|
-
* last_name: "Smith",
|
|
926
|
-
* address: { city: "Miami", phone_number: "389791382" },
|
|
927
|
-
* }
|
|
928
|
-
*
|
|
929
|
-
* @endexample
|
|
930
|
-
*/
|
|
931
|
-
export function keysToSnakeCase(object: any): any;
|
|
932
|
-
/**
|
|
933
|
-
*
|
|
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
|
|
937
|
-
*
|
|
938
|
-
* object with the corresponding values in the pattern (deeply) and checks if all
|
|
939
|
-
*
|
|
940
|
-
* conditions (functions) are satisfied for a match.
|
|
941
|
-
*
|
|
942
|
-
* @example
|
|
943
|
-
*
|
|
944
|
-
* const user = {
|
|
945
|
-
* firstName: "Oliver",
|
|
946
|
-
* address: { city: "Miami", phoneNumber: "389791382" },
|
|
947
|
-
* cars: [{ brand: "Ford" }, { brand: "Honda" }],
|
|
948
|
-
* };
|
|
949
|
-
*
|
|
950
|
-
* matches({ firstName: "Oliver" }, user); // true
|
|
951
|
-
* matches({ address: { city: "Miami" } }, user); // true
|
|
952
|
-
* matches({ cars: [{ brand: "Ford" }] }, user); // true
|
|
953
|
-
* matches({ firstName: "Sam" }, user); // false
|
|
954
|
-
* matches({ address: { country: "US" } }, user); // false
|
|
955
|
-
* matches({ cars: [{ brand: "Honda" }] }, user); // false
|
|
956
|
-
* // array index as object key
|
|
957
|
-
* matches({ cars: { 1: { brand: "Honda" } } }, user); // true
|
|
958
|
-
* // conditional functions
|
|
959
|
-
* matches({ cars: arr => arr.length === 2 }, user); // true
|
|
960
|
-
* // point-free functions with ramda
|
|
961
|
-
* matches({ firstName: startsWith("O") }, user); // true
|
|
962
|
-
* @endexample
|
|
963
|
-
*/
|
|
964
|
-
export function matches<T>(pattern: MatchPattern<T>, data: T): boolean;
|
|
965
|
-
/**
|
|
966
|
-
*
|
|
967
|
-
* The matches function checks whether the given object matches the given
|
|
968
|
-
*
|
|
969
|
-
* pattern. It compares the primitive value (int, boolean, string, etc.) in the
|
|
970
|
-
*
|
|
971
|
-
* object with the corresponding values in the pattern (deeply) and checks if all
|
|
972
|
-
*
|
|
973
|
-
* conditions (functions) are satisfied for a match.
|
|
974
|
-
*
|
|
975
|
-
* @example
|
|
976
|
-
*
|
|
977
|
-
* const user = {
|
|
978
|
-
* firstName: "Oliver",
|
|
979
|
-
* address: { city: "Miami", phoneNumber: "389791382" },
|
|
980
|
-
* cars: [{ brand: "Ford" }, { brand: "Honda" }],
|
|
981
|
-
* };
|
|
982
|
-
*
|
|
983
|
-
* matches({ firstName: "Oliver" }, user); // true
|
|
984
|
-
* matches({ address: { city: "Miami" } }, user); // true
|
|
985
|
-
* matches({ cars: [{ brand: "Ford" }] }, user); // true
|
|
986
|
-
* matches({ firstName: "Sam" }, user); // false
|
|
987
|
-
* matches({ address: { country: "US" } }, user); // false
|
|
988
|
-
* matches({ cars: [{ brand: "Honda" }] }, user); // false
|
|
989
|
-
* // array index as object key
|
|
990
|
-
* matches({ cars: { 1: { brand: "Honda" } } }, user); // true
|
|
991
|
-
* // conditional functions
|
|
992
|
-
* matches({ cars: arr => arr.length === 2 }, user); // true
|
|
993
|
-
* // point-free functions with ramda
|
|
994
|
-
* matches({ firstName: startsWith("O") }, user); // true
|
|
995
|
-
* @endexample
|
|
996
|
-
*/
|
|
997
|
-
export function matches(pattern: MatchPattern): (data: any) => boolean;
|
|
998
|
-
/**
|
|
999
|
-
*
|
|
1000
|
-
* The modifyBy function modifies all items in the array that match the provided
|
|
1001
|
-
*
|
|
1002
|
-
* pattern using the given modifier function.
|
|
1003
|
-
*
|
|
1004
|
-
* @example
|
|
1005
|
-
*
|
|
1006
|
-
* const array = [
|
|
1007
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
|
|
1008
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
|
|
1009
|
-
* ];
|
|
1010
|
-
* const modifier = item => assoc("name", item.name.toUpperCase(), item);
|
|
1011
|
-
*
|
|
1012
|
-
* modifyBy({ name: "Oliver" }, modifier, array);
|
|
1013
|
-
*
|
|
1014
|
-
* [{id: 1, name: "Sam"}, {id: 2, name: "OLIVER"}]
|
|
1015
|
-
*
|
|
1016
|
-
* @endexample
|
|
1017
|
-
*/
|
|
1018
|
-
export function modifyBy<T>(pattern: MatchPattern<T>, modifier: (previous: T) => T, entityArray: T[]): T[];
|
|
1019
|
-
/**
|
|
1020
|
-
*
|
|
1021
|
-
* The modifyBy function modifies all items in the array that match the provided
|
|
1022
|
-
*
|
|
1023
|
-
* pattern using the given modifier function.
|
|
1024
|
-
*
|
|
1025
|
-
* @example
|
|
1026
|
-
*
|
|
1027
|
-
* const array = [
|
|
1028
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
|
|
1029
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
|
|
1030
|
-
* ];
|
|
1031
|
-
* const modifier = item => assoc("name", item.name.toUpperCase(), item);
|
|
1032
|
-
*
|
|
1033
|
-
* modifyBy({ name: "Oliver" }, modifier, array);
|
|
1034
|
-
*
|
|
1035
|
-
* [{id: 1, name: "Sam"}, {id: 2, name: "OLIVER"}]
|
|
1036
|
-
*
|
|
1037
|
-
* @endexample
|
|
1038
|
-
*/
|
|
1039
|
-
export function modifyBy<T>(pattern: MatchPattern<T>, modifier: (previous: T) => T): (entityArray: T[]) => T[];
|
|
1040
|
-
/**
|
|
1041
|
-
*
|
|
1042
|
-
* The modifyBy function modifies all items in the array that match the provided
|
|
1043
|
-
*
|
|
1044
|
-
* pattern using the given modifier function.
|
|
1045
|
-
*
|
|
1046
|
-
* @example
|
|
1047
|
-
*
|
|
1048
|
-
* const array = [
|
|
1049
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
|
|
1050
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
|
|
1051
|
-
* ];
|
|
1052
|
-
* const modifier = item => assoc("name", item.name.toUpperCase(), item);
|
|
1053
|
-
*
|
|
1054
|
-
* modifyBy({ name: "Oliver" }, modifier, array);
|
|
1055
|
-
*
|
|
1056
|
-
* [{id: 1, name: "Sam"}, {id: 2, name: "OLIVER"}]
|
|
1057
|
-
*
|
|
1058
|
-
* @endexample
|
|
1059
|
-
*/
|
|
1060
|
-
export function modifyBy(pattern: MatchPattern): <T>(modifier: (previous: T) => T, entityArray: T[]) => T[];
|
|
1061
|
-
/**
|
|
1062
|
-
*
|
|
1063
|
-
* The modifyBy function modifies all items in the array that match the provided
|
|
1064
|
-
*
|
|
1065
|
-
* pattern using the given modifier function.
|
|
1066
|
-
*
|
|
1067
|
-
* @example
|
|
1068
|
-
*
|
|
1069
|
-
* const array = [
|
|
1070
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
|
|
1071
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
|
|
1072
|
-
* ];
|
|
1073
|
-
* const modifier = item => assoc("name", item.name.toUpperCase(), item);
|
|
1074
|
-
*
|
|
1075
|
-
* modifyBy({ name: "Oliver" }, modifier, array);
|
|
1076
|
-
*
|
|
1077
|
-
* [{id: 1, name: "Sam"}, {id: 2, name: "OLIVER"}]
|
|
1078
|
-
*
|
|
1079
|
-
* @endexample
|
|
1080
|
-
*/
|
|
1081
|
-
export function modifyBy(pattern: MatchPattern): <T>(modifier: (previous: T) => T) => (entityArray: T[]) => T[];
|
|
1082
|
-
export function _modifyBy<T>(pattern: MatchPattern<T>, modifier: (previous: T) => T, entityArray: NilOr<T[]>): NilOr<T[]>;
|
|
1083
|
-
export function _modifyBy<T>(pattern: MatchPattern<T>, modifier: (previous: T) => T): (entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1084
|
-
export function _modifyBy(pattern: MatchPattern): <T>(modifier: (previous: T) => T, entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1085
|
-
export function _modifyBy(pattern: MatchPattern): <T>(modifier: (previous: T) => T) => (entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1086
|
-
/**
|
|
1087
|
-
*
|
|
1088
|
-
* The modifyById function applies a modifier function to the item with the
|
|
1089
|
-
*
|
|
1090
|
-
* specified id in an array and returns a new array with the modified item in the
|
|
1091
|
-
*
|
|
1092
|
-
* same index.
|
|
1093
|
-
*
|
|
1094
|
-
* @example
|
|
1095
|
-
*
|
|
1096
|
-
* const array = [
|
|
1097
|
-
* { id: 1, name: "Sam" },
|
|
1098
|
-
* { id: 2, name: "Oliver" },
|
|
1099
|
-
* ];
|
|
1100
|
-
* const idOfItemToBeModified = 2;
|
|
1101
|
-
* const modifier = item => assoc("name", item.name.toUpperCase(), item);
|
|
1102
|
-
*
|
|
1103
|
-
* modifyById(idOfItemToBeModified, modifier, array);
|
|
1104
|
-
*
|
|
1105
|
-
* [{ id: 1, name: "Sam" }, { id: 2, name: "OLIVER" }]
|
|
1106
|
-
*
|
|
1107
|
-
* @endexample
|
|
1108
|
-
*/
|
|
1109
|
-
export function modifyById<T>(id: any, modifier: (previous: T) => T, entityArray: T[]): T[];
|
|
1110
|
-
/**
|
|
1111
|
-
*
|
|
1112
|
-
* The modifyById function applies a modifier function to the item with the
|
|
1113
|
-
*
|
|
1114
|
-
* specified id in an array and returns a new array with the modified item in the
|
|
1115
|
-
*
|
|
1116
|
-
* same index.
|
|
1117
|
-
*
|
|
1118
|
-
* @example
|
|
1119
|
-
*
|
|
1120
|
-
* const array = [
|
|
1121
|
-
* { id: 1, name: "Sam" },
|
|
1122
|
-
* { id: 2, name: "Oliver" },
|
|
1123
|
-
* ];
|
|
1124
|
-
* const idOfItemToBeModified = 2;
|
|
1125
|
-
* const modifier = item => assoc("name", item.name.toUpperCase(), item);
|
|
1126
|
-
*
|
|
1127
|
-
* modifyById(idOfItemToBeModified, modifier, array);
|
|
1128
|
-
*
|
|
1129
|
-
* [{ id: 1, name: "Sam" }, { id: 2, name: "OLIVER" }]
|
|
1130
|
-
*
|
|
1131
|
-
* @endexample
|
|
1132
|
-
*/
|
|
1133
|
-
export function modifyById<T>(id: any, modifier: (previous: T) => T): (entityArray: T[]) => T[];
|
|
1134
|
-
/**
|
|
1135
|
-
*
|
|
1136
|
-
* The modifyById function applies a modifier function to the item with the
|
|
1137
|
-
*
|
|
1138
|
-
* specified id in an array and returns a new array with the modified item in the
|
|
1139
|
-
*
|
|
1140
|
-
* same index.
|
|
1141
|
-
*
|
|
1142
|
-
* @example
|
|
1143
|
-
*
|
|
1144
|
-
* const array = [
|
|
1145
|
-
* { id: 1, name: "Sam" },
|
|
1146
|
-
* { id: 2, name: "Oliver" },
|
|
1147
|
-
* ];
|
|
1148
|
-
* const idOfItemToBeModified = 2;
|
|
1149
|
-
* const modifier = item => assoc("name", item.name.toUpperCase(), item);
|
|
1150
|
-
*
|
|
1151
|
-
* modifyById(idOfItemToBeModified, modifier, array);
|
|
1152
|
-
*
|
|
1153
|
-
* [{ id: 1, name: "Sam" }, { id: 2, name: "OLIVER" }]
|
|
1154
|
-
*
|
|
1155
|
-
* @endexample
|
|
1156
|
-
*/
|
|
1157
|
-
export function modifyById(id: any): <T>(modifier: (previous: T) => T, entityArray: T[]) => T[];
|
|
1158
|
-
/**
|
|
1159
|
-
*
|
|
1160
|
-
* The modifyById function applies a modifier function to the item with the
|
|
1161
|
-
*
|
|
1162
|
-
* specified id in an array and returns a new array with the modified item in the
|
|
1163
|
-
*
|
|
1164
|
-
* same index.
|
|
1165
|
-
*
|
|
1166
|
-
* @example
|
|
1167
|
-
*
|
|
1168
|
-
* const array = [
|
|
1169
|
-
* { id: 1, name: "Sam" },
|
|
1170
|
-
* { id: 2, name: "Oliver" },
|
|
1171
|
-
* ];
|
|
1172
|
-
* const idOfItemToBeModified = 2;
|
|
1173
|
-
* const modifier = item => assoc("name", item.name.toUpperCase(), item);
|
|
1174
|
-
*
|
|
1175
|
-
* modifyById(idOfItemToBeModified, modifier, array);
|
|
1176
|
-
*
|
|
1177
|
-
* [{ id: 1, name: "Sam" }, { id: 2, name: "OLIVER" }]
|
|
1178
|
-
*
|
|
1179
|
-
* @endexample
|
|
1180
|
-
*/
|
|
1181
|
-
export function modifyById(id: any): <T>(modifier: (previous: T) => T) => (entityArray: T[]) => T[];
|
|
1182
|
-
export function _modifyById<T>(id: any, modifier: (previous: T) => T, entityArray: NilOr<T[]>): NilOr<T[]>;
|
|
1183
|
-
export function _modifyById<T>(id: any, modifier: (previous: T) => T): (entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1184
|
-
export function _modifyById(id: any): <T>(modifier: (previous: T) => T, entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1185
|
-
export function _modifyById(id: any): <T>(modifier: (previous: T) => T) => (entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1186
|
-
/**
|
|
1187
|
-
*
|
|
1188
|
-
* The noop function is a "no-operation" function that does nothing when called and
|
|
1189
|
-
*
|
|
1190
|
-
* returns undefined. It is often used as a placeholder or a default function
|
|
1191
|
-
*
|
|
1192
|
-
* when a function is expected but no action is required.
|
|
1193
|
-
*
|
|
1194
|
-
*/
|
|
1195
|
-
export function noop(...args: any[]): void;
|
|
1196
|
-
export function notEquals(a: any, b: any): boolean;
|
|
1197
|
-
export function notEquals(a: any): (b: any) => boolean;
|
|
1198
|
-
export function notEqualsDeep(a: any, b: any): boolean;
|
|
1199
|
-
export function notEqualsDeep(a: any): (b: any) => boolean;
|
|
1200
|
-
/**
|
|
1201
|
-
*
|
|
1202
|
-
* The randomPick function accepts a variable number of arguments and returns a
|
|
1203
|
-
*
|
|
1204
|
-
* random element from the list of arguments. It randomly selects one of the
|
|
1205
|
-
*
|
|
1206
|
-
* provided values and returns it.
|
|
1207
|
-
*
|
|
1208
|
-
* @example
|
|
1209
|
-
*
|
|
1210
|
-
* randomPick("arg1", "arg2", "arg3", "arg4", "arg5");
|
|
1211
|
-
*
|
|
1212
|
-
* // output: a random element from the list "arg1", "arg2", "arg3", "arg4" and "arg5"
|
|
1213
|
-
* @endexample
|
|
1214
|
-
*/
|
|
1215
|
-
export function randomPick<T>(...args: T[]): T;
|
|
1216
|
-
/**
|
|
1217
|
-
*
|
|
1218
|
-
* The removeBy function removes all items in the array that match the provided
|
|
1219
|
-
*
|
|
1220
|
-
* pattern.
|
|
1221
|
-
*
|
|
1222
|
-
* @example
|
|
1223
|
-
*
|
|
1224
|
-
* const array = [
|
|
1225
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
|
|
1226
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
|
|
1227
|
-
* ];
|
|
1228
|
-
*
|
|
1229
|
-
* removeBy({ name: "Sam" }, array); // removes Sam
|
|
1230
|
-
* removeBy({ id: 2, address: { pin: 654321 } }, array); // removes Oliver
|
|
1231
|
-
* removeBy({ id: 3 }, array); // does nothing
|
|
1232
|
-
* @endexample
|
|
1233
|
-
*/
|
|
1234
|
-
export function removeBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T[];
|
|
1235
|
-
/**
|
|
1236
|
-
*
|
|
1237
|
-
* The removeBy function removes all items in the array that match the provided
|
|
1238
|
-
*
|
|
1239
|
-
* pattern.
|
|
1240
|
-
*
|
|
1241
|
-
* @example
|
|
1242
|
-
*
|
|
1243
|
-
* const array = [
|
|
1244
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
|
|
1245
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
|
|
1246
|
-
* ];
|
|
1247
|
-
*
|
|
1248
|
-
* removeBy({ name: "Sam" }, array); // removes Sam
|
|
1249
|
-
* removeBy({ id: 2, address: { pin: 654321 } }, array); // removes Oliver
|
|
1250
|
-
* removeBy({ id: 3 }, array); // does nothing
|
|
1251
|
-
* @endexample
|
|
1252
|
-
*/
|
|
1253
|
-
export function removeBy(pattern: MatchPattern): <T>(entityArray: T[]) => T[];
|
|
1254
|
-
export function _removeBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>): NilOr<T[]>;
|
|
1255
|
-
export function _removeBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1256
|
-
/**
|
|
1257
|
-
*
|
|
1258
|
-
* The removeById function generates a new array with the item possessing the
|
|
1259
|
-
*
|
|
1260
|
-
* specified id removed.
|
|
1261
|
-
*
|
|
1262
|
-
* @example
|
|
1263
|
-
*
|
|
1264
|
-
* const array = [
|
|
1265
|
-
* { id: 1, name: "Sam" },
|
|
1266
|
-
* { id: 2, name: "Oliver" },
|
|
1267
|
-
* ];
|
|
1268
|
-
* const idOfItemToBeRemoved = 2;
|
|
1269
|
-
*
|
|
1270
|
-
* removeById(idOfItemToBeRemoved, array);
|
|
1271
|
-
* // [{ id: 1, name: "Sam" }]
|
|
1272
|
-
* @endexample
|
|
1273
|
-
*/
|
|
1274
|
-
export function removeById<T>(id: any, entityArray: T[]): T[];
|
|
1275
|
-
/**
|
|
1276
|
-
*
|
|
1277
|
-
* The removeById function generates a new array with the item possessing the
|
|
1278
|
-
*
|
|
1279
|
-
* specified id removed.
|
|
1280
|
-
*
|
|
1281
|
-
* @example
|
|
1282
|
-
*
|
|
1283
|
-
* const array = [
|
|
1284
|
-
* { id: 1, name: "Sam" },
|
|
1285
|
-
* { id: 2, name: "Oliver" },
|
|
1286
|
-
* ];
|
|
1287
|
-
* const idOfItemToBeRemoved = 2;
|
|
1288
|
-
*
|
|
1289
|
-
* removeById(idOfItemToBeRemoved, array);
|
|
1290
|
-
* // [{ id: 1, name: "Sam" }]
|
|
1291
|
-
* @endexample
|
|
1292
|
-
*/
|
|
1293
|
-
export function removeById(id: any): <T>(entityArray: T[]) => T[];
|
|
1294
|
-
export function _removeById<T>(id: any, entityArray: NilOr<T[]>): NilOr<T[]>;
|
|
1295
|
-
export function _removeById(id: any): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1296
|
-
/**
|
|
1297
|
-
*
|
|
1298
|
-
* The renameKeys function renames specified keys in each object of an array
|
|
1299
|
-
*
|
|
1300
|
-
* while keeping their values the same. It creates a new instance and does not
|
|
1301
|
-
*
|
|
1302
|
-
* mutate the original array.
|
|
1303
|
-
*
|
|
1304
|
-
* @example
|
|
1305
|
-
*
|
|
1306
|
-
* const data = [
|
|
1307
|
-
* { id: 1, name: "Tomato", quantity: 10 },
|
|
1308
|
-
* { id: 2, name: "Potato", quantity: 20 },
|
|
1309
|
-
* ];
|
|
1310
|
-
*
|
|
1311
|
-
* // rename name to label and id to value
|
|
1312
|
-
* renameKeys({ name: "label", id: "value" }, data);
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1315
|
-
* output: [
|
|
1316
|
-
* { label: "Tomato", value: 1, quantity: 10 },
|
|
1317
|
-
* { label: "Potato", value: 2, quantity: 20 },
|
|
1318
|
-
* ];
|
|
1319
|
-
*
|
|
1320
|
-
* @endexample
|
|
1321
|
-
*/
|
|
1322
|
-
export function renameKeys<T, M extends { [key in keyof Partial<T>]: string }>(keyMap: M, entityArray: T[]): (Omit<T, keyof M> & {
|
|
1323
|
-
[key: string]: any;
|
|
1324
|
-
})[];
|
|
1325
|
-
/**
|
|
1326
|
-
*
|
|
1327
|
-
* The renameKeys function renames specified keys in each object of an array
|
|
1328
|
-
*
|
|
1329
|
-
* while keeping their values the same. It creates a new instance and does not
|
|
1330
|
-
*
|
|
1331
|
-
* mutate the original array.
|
|
1332
|
-
*
|
|
1333
|
-
* @example
|
|
1334
|
-
*
|
|
1335
|
-
* const data = [
|
|
1336
|
-
* { id: 1, name: "Tomato", quantity: 10 },
|
|
1337
|
-
* { id: 2, name: "Potato", quantity: 20 },
|
|
1338
|
-
* ];
|
|
1339
|
-
*
|
|
1340
|
-
* // rename name to label and id to value
|
|
1341
|
-
* renameKeys({ name: "label", id: "value" }, data);
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1344
|
-
* output: [
|
|
1345
|
-
* { label: "Tomato", value: 1, quantity: 10 },
|
|
1346
|
-
* { label: "Potato", value: 2, quantity: 20 },
|
|
1347
|
-
* ];
|
|
1348
|
-
*
|
|
1349
|
-
* @endexample
|
|
1350
|
-
*/
|
|
1351
|
-
export function renameKeys<M extends {
|
|
1352
|
-
[key: string]: string;
|
|
1353
|
-
}>(keyMap: M): <T>(entityArray: T[]) => (Omit<T, keyof M> & {
|
|
1354
|
-
[key: string]: any;
|
|
1355
|
-
})[];
|
|
1356
|
-
export function _renameKeys<T, M extends { [key in keyof Partial<T>]: string }>(keyMap: M, entityArray: NilOr<T[]>): NilOr<(Omit<T, keyof M> & {
|
|
1357
|
-
[key: string]: any;
|
|
1358
|
-
})[]>;
|
|
1359
|
-
export function _renameKeys<M extends {
|
|
1360
|
-
[key: string]: string;
|
|
1361
|
-
}>(keyMap: M): <T>(entityArray: NilOr<T[]>) => NilOr<(Omit<T, keyof M> & {
|
|
1362
|
-
[key: string]: any;
|
|
1363
|
-
})[]>;
|
|
1364
|
-
/**
|
|
1365
|
-
*
|
|
1366
|
-
* The replaceBy function replaces all items in the array that match the provided
|
|
1367
|
-
*
|
|
1368
|
-
* pattern with the given item.
|
|
1369
|
-
*
|
|
1370
|
-
* @example
|
|
1371
|
-
*
|
|
1372
|
-
* const array = [
|
|
1373
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
|
|
1374
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
|
|
1375
|
-
* ];
|
|
1376
|
-
* const newItem = { id: 2, name: "John" };
|
|
1377
|
-
*
|
|
1378
|
-
* replaceBy({ name: "Oliver" }, newItem, array);
|
|
1379
|
-
*
|
|
1380
|
-
* [{id: 1, name: "Sam"}, {id: 2, name: "John"}]
|
|
1381
|
-
*
|
|
1382
|
-
* @endexample
|
|
1383
|
-
*/
|
|
1384
|
-
export function replaceBy<T>(pattern: MatchPattern<T>, entity: T, entityArray: T[]): T[];
|
|
1385
|
-
/**
|
|
1386
|
-
*
|
|
1387
|
-
* The replaceBy function replaces all items in the array that match the provided
|
|
1388
|
-
*
|
|
1389
|
-
* pattern with the given item.
|
|
1390
|
-
*
|
|
1391
|
-
* @example
|
|
1392
|
-
*
|
|
1393
|
-
* const array = [
|
|
1394
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
|
|
1395
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
|
|
1396
|
-
* ];
|
|
1397
|
-
* const newItem = { id: 2, name: "John" };
|
|
1398
|
-
*
|
|
1399
|
-
* replaceBy({ name: "Oliver" }, newItem, array);
|
|
1400
|
-
*
|
|
1401
|
-
* [{id: 1, name: "Sam"}, {id: 2, name: "John"}]
|
|
1402
|
-
*
|
|
1403
|
-
* @endexample
|
|
1404
|
-
*/
|
|
1405
|
-
export function replaceBy<T>(pattern: MatchPattern<T>, entity: T): <T>(entityArray: T[]) => T[];
|
|
1406
|
-
/**
|
|
1407
|
-
*
|
|
1408
|
-
* The replaceBy function replaces all items in the array that match the provided
|
|
1409
|
-
*
|
|
1410
|
-
* pattern with the given item.
|
|
1411
|
-
*
|
|
1412
|
-
* @example
|
|
1413
|
-
*
|
|
1414
|
-
* const array = [
|
|
1415
|
-
* { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
|
|
1416
|
-
* { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
|
|
1417
|
-
* ];
|
|
1418
|
-
* const newItem = { id: 2, name: "John" };
|
|
1419
|
-
*
|
|
1420
|
-
* replaceBy({ name: "Oliver" }, newItem, array);
|
|
1421
|
-
*
|
|
1422
|
-
* [{id: 1, name: "Sam"}, {id: 2, name: "John"}]
|
|
1423
|
-
*
|
|
1424
|
-
* @endexample
|
|
1425
|
-
*/
|
|
1426
|
-
export function replaceBy(pattern: MatchPattern): <T>(entity: T) => (entityArray: T[]) => T[];
|
|
1427
|
-
export function _replaceBy<T>(pattern: MatchPattern<T>, entity: NilOr<T>, entityArray: NilOr<T[]>): NilOr<T[]>;
|
|
1428
|
-
export function _replaceBy<T>(pattern: MatchPattern<T>, entity: NilOr<T>): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1429
|
-
export function _replaceBy(pattern: MatchPattern): <T>(entity: NilOr<T>) => <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1430
|
-
/**
|
|
1431
|
-
*
|
|
1432
|
-
* The replaceById function returns a new array with the item having the
|
|
1433
|
-
*
|
|
1434
|
-
* specified id replaced by the provided object.
|
|
1435
|
-
*
|
|
1436
|
-
* @example
|
|
1437
|
-
*
|
|
1438
|
-
* const array = [
|
|
1439
|
-
* { id: 1, name: "Sam" },
|
|
1440
|
-
* { id: 2, name: "Oliver" },
|
|
1441
|
-
* ];
|
|
1442
|
-
* const idOfItemToBeReplaced = 2;
|
|
1443
|
-
* const newItem = { id: 3, name: "John" };
|
|
1444
|
-
*
|
|
1445
|
-
* replaceById(idOfItemToBeReplaced, newItem, array);
|
|
1446
|
-
*
|
|
1447
|
-
* [{ id: 1, name: "Sam" }, { id: 3, name: "John" }]
|
|
1448
|
-
*
|
|
1449
|
-
* @endexample
|
|
1450
|
-
*/
|
|
1451
|
-
export function replaceById<T>(id: any, entity: T, entityArray: T[]): T[];
|
|
1452
|
-
/**
|
|
1453
|
-
*
|
|
1454
|
-
* The replaceById function returns a new array with the item having the
|
|
1455
|
-
*
|
|
1456
|
-
* specified id replaced by the provided object.
|
|
1457
|
-
*
|
|
1458
|
-
* @example
|
|
1459
|
-
*
|
|
1460
|
-
* const array = [
|
|
1461
|
-
* { id: 1, name: "Sam" },
|
|
1462
|
-
* { id: 2, name: "Oliver" },
|
|
1463
|
-
* ];
|
|
1464
|
-
* const idOfItemToBeReplaced = 2;
|
|
1465
|
-
* const newItem = { id: 3, name: "John" };
|
|
1466
|
-
*
|
|
1467
|
-
* replaceById(idOfItemToBeReplaced, newItem, array);
|
|
1468
|
-
*
|
|
1469
|
-
* [{ id: 1, name: "Sam" }, { id: 3, name: "John" }]
|
|
1470
|
-
*
|
|
1471
|
-
* @endexample
|
|
1472
|
-
*/
|
|
1473
|
-
export function replaceById<T>(id: any, entity: T): <T>(entityArray: T[]) => T[];
|
|
1474
|
-
/**
|
|
1475
|
-
*
|
|
1476
|
-
* The replaceById function returns a new array with the item having the
|
|
1477
|
-
*
|
|
1478
|
-
* specified id replaced by the provided object.
|
|
1479
|
-
*
|
|
1480
|
-
* @example
|
|
1481
|
-
*
|
|
1482
|
-
* const array = [
|
|
1483
|
-
* { id: 1, name: "Sam" },
|
|
1484
|
-
* { id: 2, name: "Oliver" },
|
|
1485
|
-
* ];
|
|
1486
|
-
* const idOfItemToBeReplaced = 2;
|
|
1487
|
-
* const newItem = { id: 3, name: "John" };
|
|
1488
|
-
*
|
|
1489
|
-
* replaceById(idOfItemToBeReplaced, newItem, array);
|
|
1490
|
-
*
|
|
1491
|
-
* [{ id: 1, name: "Sam" }, { id: 3, name: "John" }]
|
|
1492
|
-
*
|
|
1493
|
-
* @endexample
|
|
1494
|
-
*/
|
|
1495
|
-
export function replaceById(id: any): <T>(entity: T) => <T>(entityArray: T[]) => T[];
|
|
1496
|
-
export function _replaceById<T>(id: any, entity: NilOr<T>, entityArray: NilOr<T[]>): NilOr<T[]>;
|
|
1497
|
-
export function _replaceById<T>(id: any, entity: NilOr<T>): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1498
|
-
export function _replaceById(id: any): <T>(entity: NilOr<T>) => <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
|
|
1499
|
-
/**
|
|
1500
|
-
*
|
|
1501
|
-
* The serializeKeysToSnakeCase function recursively converts the camel-cased
|
|
1502
|
-
*
|
|
1503
|
-
* object keys to snake case. It gracefully handles special objects like Date and
|
|
1504
|
-
*
|
|
1505
|
-
* dayjs instances. Additionally, while converting, this function checks if the
|
|
1506
|
-
*
|
|
1507
|
-
* value being processed is an object and if it has a toJSON function. If the
|
|
1508
|
-
*
|
|
1509
|
-
* toJSON function is present, it calls the function and uses the return value
|
|
1510
|
-
*
|
|
1511
|
-
* for further processing.
|
|
1512
|
-
*
|
|
1513
|
-
* Example 1:
|
|
1514
|
-
*
|
|
1515
|
-
* @example
|
|
1516
|
-
*
|
|
1517
|
-
* serializeKeysToSnakeCase({
|
|
1518
|
-
* name: { toJSON: () => ({ firstName: "Oliver", lastName: "Smith" }) },
|
|
1519
|
-
* phoneNumber: "389791382",
|
|
1520
|
-
* });
|
|
1521
|
-
*
|
|
1522
|
-
*
|
|
1523
|
-
* {
|
|
1524
|
-
* name: { first_name: "Oliver", last_name: "Smith" },
|
|
1525
|
-
* phone_number: "389791382",
|
|
1526
|
-
* }
|
|
1527
|
-
*
|
|
1528
|
-
* @endexample
|
|
1529
|
-
* Example 2: (Real world example)
|
|
1530
|
-
*
|
|
1531
|
-
* @example
|
|
1532
|
-
*
|
|
1533
|
-
* serializeKeysToSnakeCase({
|
|
1534
|
-
* address: { city: "Miami", phoneNumber: "389791382" },
|
|
1535
|
-
* firstName: "Oliver",
|
|
1536
|
-
* lastName: "Smith",
|
|
1537
|
-
* dob: new Date("1980-01-01"),
|
|
1538
|
-
* });
|
|
1539
|
-
*
|
|
1540
|
-
*
|
|
1541
|
-
* {
|
|
1542
|
-
* first_name: "Oliver",
|
|
1543
|
-
* last_name: "Smith",
|
|
1544
|
-
* address: { city: "Miami", phone_number: "389791382" },
|
|
1545
|
-
* dob: "1980-01-01T00:00:00.000Z",
|
|
1546
|
-
* }
|
|
1547
|
-
*
|
|
1548
|
-
* @endexample
|
|
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.
|
|
1556
|
-
*
|
|
1557
|
-
*/
|
|
1558
|
-
export function serializeKeysToSnakeCase(object: object): object;
|
|
1559
|
-
/**
|
|
1560
|
-
*
|
|
1561
|
-
* The preprocessForSerialization function creates a ready-to-be-serialized
|
|
1562
|
-
*
|
|
1563
|
-
* version of the given object by recursively traversing all the object properties
|
|
1564
|
-
*
|
|
1565
|
-
* and replacing them with their JSON serializable versions. This is particularly
|
|
1566
|
-
*
|
|
1567
|
-
* helpful when serializing objects that include non-serializable data types, such
|
|
1568
|
-
*
|
|
1569
|
-
* as Date objects, dayjs objects or custom classes.
|
|
1570
|
-
*
|
|
1571
|
-
* @example
|
|
1572
|
-
*
|
|
1573
|
-
* preprocessForSerialization(dayjs("1980-01-01")); // returns "1980-01-01T00:00:00.000Z"
|
|
1574
|
-
* preprocessForSerialization({
|
|
1575
|
-
* toJSON: () => ({ firstName: "Oliver", lastName: "Smith" }),
|
|
1576
|
-
* }); // returns { firstName: "Oliver", lastName: "Smith" }
|
|
1577
|
-
* @endexample
|
|
1578
|
-
*/
|
|
1579
|
-
export function preprocessForSerialization(object: object): object;
|
|
1580
|
-
/**
|
|
1581
|
-
*
|
|
1582
|
-
* The slugify function converts a given string into a slug. A slug is a
|
|
1583
|
-
*
|
|
1584
|
-
* URL-friendly representation of a string, typically used for creating
|
|
1585
|
-
*
|
|
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.
|
|
1591
|
-
*
|
|
1592
|
-
* @example
|
|
1593
|
-
*
|
|
1594
|
-
* slugify("My quiz"); // "my-quiz"
|
|
1595
|
-
* slugify("my-quiz"); // "my-quiz"
|
|
1596
|
-
* slugify("-----my----quiz"); // "my-quiz"
|
|
1597
|
-
* slugify("Me & my quiz"); // "me-and-my-quiz"
|
|
1598
|
-
* slugify("my!@#$%^*(quiz"); // "myquiz"
|
|
1599
|
-
* @endexample
|
|
1600
|
-
*/
|
|
1601
|
-
export function slugify(string: string): string;
|
|
1602
|
-
export function _slugify(string: NilOr<string>): NilOr<string>;
|
|
1603
|
-
/**
|
|
1604
|
-
*
|
|
1605
|
-
* The snakeToCamelCase function converts a snake_case string to camelCase.
|
|
1606
|
-
*
|
|
1607
|
-
* @example
|
|
1608
|
-
*
|
|
1609
|
-
* snakeToCamelCase("first_name"); // "firstName"
|
|
1610
|
-
* @endexample
|
|
1611
|
-
*/
|
|
1612
|
-
export function snakeToCamelCase(string: string): string;
|
|
1613
|
-
export function _snakeToCamelCase(string: NilOr<string>): NilOr<string>;
|
|
1614
|
-
/**
|
|
1615
|
-
*
|
|
1616
|
-
* The toLabelAndValue function takes a string as an argument and returns an
|
|
1617
|
-
*
|
|
1618
|
-
* object with keys "label" and "value." It is often used to transform a string
|
|
1619
|
-
*
|
|
1620
|
-
* into an object with specific key-value pairs.
|
|
1621
|
-
*
|
|
1622
|
-
* @example
|
|
1623
|
-
*
|
|
1624
|
-
* toLabelAndValue("test");
|
|
1625
|
-
*
|
|
1626
|
-
* // output: {label: "test", value: "test"}
|
|
1627
|
-
* @endexample
|
|
1628
|
-
*/
|
|
1629
|
-
export function toLabelAndValue(string: string): {
|
|
1630
|
-
label: string;
|
|
1631
|
-
value: string;
|
|
1632
|
-
};
|
|
1633
|
-
/**
|
|
1634
|
-
*
|
|
1635
|
-
* The transformObjectDeep function passes each key and value of the given object
|
|
1636
|
-
*
|
|
1637
|
-
* (recursively) to the provided transformer function. It reconstructs an object of
|
|
1638
|
-
*
|
|
1639
|
-
* the same hierarchy with the key-value pairs that the transformer function
|
|
1640
|
-
*
|
|
1641
|
-
* returns.
|
|
1642
|
-
*
|
|
1643
|
-
* Usage:
|
|
1644
|
-
*
|
|
1645
|
-
* @example
|
|
1646
|
-
*
|
|
1647
|
-
* transformObjectDeep(
|
|
1648
|
-
* {
|
|
1649
|
-
* name: "Oliver",
|
|
1650
|
-
* email: "oliver@example.com",
|
|
1651
|
-
* address: { street: "First street", pin: 123456 },
|
|
1652
|
-
* },
|
|
1653
|
-
* (key, value) => [key.toUpperCase(), value]
|
|
1654
|
-
* );
|
|
1655
|
-
*
|
|
1656
|
-
* output: {
|
|
1657
|
-
* NAME: "Oliver",
|
|
1658
|
-
* EMAIL: "oliver@example.com",
|
|
1659
|
-
* ADDRESS: { STREET: "First street", PIN: 123456 },
|
|
1660
|
-
* }
|
|
1661
|
-
*
|
|
1662
|
-
*
|
|
1663
|
-
* transformObjectDeep(
|
|
1664
|
-
* [
|
|
1665
|
-
* [1, 2, 3],
|
|
1666
|
-
* [4, 5, 6],
|
|
1667
|
-
* [7, 8, 9],
|
|
1668
|
-
* ],
|
|
1669
|
-
* (key, value) => [key, value],
|
|
1670
|
-
* item => (Array.isArray(item) ? item.slice(1) : item)
|
|
1671
|
-
* );
|
|
1672
|
-
*
|
|
1673
|
-
* output: [[5, 6], [8, 9]]
|
|
1674
|
-
*
|
|
1675
|
-
* @endexample
|
|
1676
|
-
*/
|
|
1677
|
-
export function transformObjectDeep(object: object, keyValueTransformer: (key: string | number | symbol, object: any) => any[], objectPreProcessor?: (object: any) => any): object;
|
|
1678
|
-
/**
|
|
1679
|
-
*
|
|
1680
|
-
* The truncate function truncates a string by adding "..." if it exceeds a
|
|
1681
|
-
*
|
|
1682
|
-
* specified maximum length.
|
|
1683
|
-
*
|
|
1684
|
-
* @example
|
|
1685
|
-
*
|
|
1686
|
-
* truncate("Hello World", 5); // "Hello..."
|
|
1687
|
-
* truncate("Hello World", 15); // "Hello World"
|
|
1688
|
-
* @endexample
|
|
1689
|
-
*/
|
|
1690
|
-
export function truncate(string: string, length: number): string;
|
|
1691
|
-
/**
|
|
1692
|
-
*
|
|
1693
|
-
* The truncate function truncates a string by adding "..." if it exceeds a
|
|
1694
|
-
*
|
|
1695
|
-
* specified maximum length.
|
|
1696
|
-
*
|
|
1697
|
-
* @example
|
|
1698
|
-
*
|
|
1699
|
-
* truncate("Hello World", 5); // "Hello..."
|
|
1700
|
-
* truncate("Hello World", 15); // "Hello World"
|
|
1701
|
-
* @endexample
|
|
1702
|
-
*/
|
|
1703
|
-
export function truncate(string: NilOr<string>, length: number): NilOr<string>;
|
|
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
|
-
*/
|
|
1716
|
-
export function isNotPresent(object: any): boolean;
|
|
1717
|
-
export function isPresent(object: any): boolean;
|
|
1718
|
-
/**
|
|
1719
|
-
*
|
|
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
|
|
1729
|
-
*
|
|
1730
|
-
* it with care, especially when working with complex data structures.
|
|
1731
|
-
*
|
|
1732
|
-
* You can read more about Immer here.
|
|
1733
|
-
*
|
|
1734
|
-
* Returns the new modified value.
|
|
1735
|
-
*
|
|
1736
|
-
* @example
|
|
1737
|
-
*
|
|
1738
|
-
* const data = { name: "Oliver" };
|
|
1739
|
-
* modifyWithImmer(draft => {
|
|
1740
|
-
* draft.name = "Oliver smith";
|
|
1741
|
-
* })(data);
|
|
1742
|
-
* // outputs: { name: "Oliver smith" }
|
|
1743
|
-
* @endexample
|
|
1744
|
-
* We can utilize currying with state updator functions:
|
|
1745
|
-
*
|
|
1746
|
-
* @example
|
|
1747
|
-
*
|
|
1748
|
-
* const { setUsers } = useZustandStore.pick();
|
|
1749
|
-
*
|
|
1750
|
-
* setUsers(
|
|
1751
|
-
* modifyWithImmer(draft => {
|
|
1752
|
-
* draft[0].addresses.push("Oliver smith");
|
|
1753
|
-
* })
|
|
1754
|
-
* );
|
|
1755
|
-
*
|
|
1756
|
-
* // updates users to: [{ name: "Oliver smith" }, { name: "Eve" }]
|
|
1757
|
-
* @endexample
|
|
1758
|
-
*/
|
|
1759
|
-
export function modifyWithImmer<T>(modifier: (draft: Draft<T>) => void, data: T): T;
|
|
1760
|
-
/**
|
|
1761
|
-
*
|
|
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
|
|
1771
|
-
*
|
|
1772
|
-
* it with care, especially when working with complex data structures.
|
|
1773
|
-
*
|
|
1774
|
-
* You can read more about Immer here.
|
|
1775
|
-
*
|
|
1776
|
-
* Returns the new modified value.
|
|
1777
|
-
*
|
|
1778
|
-
* @example
|
|
1779
|
-
*
|
|
1780
|
-
* const data = { name: "Oliver" };
|
|
1781
|
-
* modifyWithImmer(draft => {
|
|
1782
|
-
* draft.name = "Oliver smith";
|
|
1783
|
-
* })(data);
|
|
1784
|
-
* // outputs: { name: "Oliver smith" }
|
|
1785
|
-
* @endexample
|
|
1786
|
-
* We can utilize currying with state updator functions:
|
|
1787
|
-
*
|
|
1788
|
-
* @example
|
|
1789
|
-
*
|
|
1790
|
-
* const { setUsers } = useZustandStore.pick();
|
|
1791
|
-
*
|
|
1792
|
-
* setUsers(
|
|
1793
|
-
* modifyWithImmer(draft => {
|
|
1794
|
-
* draft[0].addresses.push("Oliver smith");
|
|
1795
|
-
* })
|
|
1796
|
-
* );
|
|
1797
|
-
*
|
|
1798
|
-
* // updates users to: [{ name: "Oliver smith" }, { name: "Eve" }]
|
|
1799
|
-
* @endexample
|
|
1800
|
-
*/
|
|
1801
|
-
export function modifyWithImmer<T>(modifier: (draft: Draft<T>) => void): (data: T) => T;
|