rambda 10.0.0-alpha.0 → 10.0.0-beta.3

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +125 -16
  2. package/README.md +8035 -3592
  3. package/dist/{rambda.esm.js → rambda.cjs} +800 -385
  4. package/dist/rambda.js +673 -486
  5. package/dist/rambda.umd.js +701 -388
  6. package/immutable.d.ts +896 -345
  7. package/index.d.ts +896 -345
  8. package/package.json +22 -15
  9. package/rambda.js +23 -2
  10. package/src/addProp.js +3 -0
  11. package/src/addPropToObjects.js +14 -0
  12. package/src/append.js +5 -5
  13. package/src/ascend.js +16 -0
  14. package/src/compact.js +12 -0
  15. package/src/concat.js +1 -1
  16. package/src/count.js +7 -7
  17. package/src/countBy.js +12 -12
  18. package/src/createObjectFromKeys.js +10 -0
  19. package/src/defaultTo.js +2 -6
  20. package/src/descend.js +10 -0
  21. package/src/drop.js +2 -6
  22. package/src/dropLast.js +1 -3
  23. package/src/eqProps.js +1 -2
  24. package/src/equals.js +2 -2
  25. package/src/evolve.js +2 -23
  26. package/src/filter.js +14 -14
  27. package/src/find.js +10 -10
  28. package/src/findIndex.js +9 -9
  29. package/src/findLast.js +8 -8
  30. package/src/findLastIndex.js +8 -8
  31. package/src/findNth.js +16 -0
  32. package/src/flattenObject.js +76 -0
  33. package/src/groupBy.js +14 -13
  34. package/src/includes.js +12 -13
  35. package/src/interpolate.js +29 -0
  36. package/src/intersection.js +1 -1
  37. package/src/intersperse.js +12 -12
  38. package/src/join.js +1 -1
  39. package/src/map.js +13 -9
  40. package/src/mapAsync.js +3 -3
  41. package/src/mapKeys.js +11 -0
  42. package/src/mapObjectAsync.js +9 -9
  43. package/src/mapParallelAsync.js +3 -0
  44. package/src/match.js +5 -5
  45. package/src/{replaceItemAtIndex.js → modifyItemAtIndex.js} +1 -1
  46. package/src/modifyProp.js +20 -0
  47. package/src/objectIncludes.js +12 -0
  48. package/src/partition.js +13 -37
  49. package/src/partitionObject.js +15 -0
  50. package/src/path.js +24 -26
  51. package/src/pathSatisfies.js +5 -0
  52. package/src/permutations.js +40 -0
  53. package/src/pipeAsync.js +7 -6
  54. package/src/pluck.js +9 -9
  55. package/src/prepend.js +1 -1
  56. package/src/propOr.js +1 -1
  57. package/src/propSatisfies.js +1 -3
  58. package/src/range.js +29 -13
  59. package/src/reject.js +1 -1
  60. package/src/rejectObject.js +13 -0
  61. package/src/shuffle.js +13 -0
  62. package/src/sort.js +1 -1
  63. package/src/sortBy.js +20 -9
  64. package/src/sortByDescending.js +5 -0
  65. package/src/sortByPath.js +6 -0
  66. package/src/sortByPathDescending.js +6 -0
  67. package/src/sortObject.js +15 -0
  68. package/src/sortWith.js +8 -8
  69. package/src/split.js +2 -2
  70. package/src/splitEvery.js +11 -11
  71. package/src/takeLastWhile.js +18 -18
  72. package/src/tap.js +4 -4
  73. package/src/test.js +1 -1
  74. package/src/uniqBy.js +4 -4
  75. package/src/uniqWith.js +10 -10
  76. package/src/modifyPath.js +0 -30
package/immutable.d.ts CHANGED
@@ -1,22 +1,18 @@
1
- export type RambdaTypes = "Object" | "Number" | "Boolean" | "String" | "Null" | "Array" | "RegExp" | "NaN" | "Function" | "Undefined" | "Async" | "Promise" | "Symbol" | "Set" | "Error" | "Map" | "WeakMap" | "Generator" | "GeneratorFunction" | "BigInt" | "ArrayBuffer" | "Date"
1
+ export type RambdaTypes = "Object" | "Number" | "Boolean" | "String" | "Null" | "Array" | "RegExp" | "NaN" | "Function" | "Undefined" | "Async" | "Promise" | "Symbol" | "Set" | "Error" | "Map" | "WeakMap" | "Generator" | "GeneratorFunction" | "BigInt" | "ArrayBuffer" | "Date";
2
2
 
3
3
  export type EqualTypes<X, Y> =
4
4
  (<T>() => T extends X ? 1 : 2) extends
5
- (<T>() => T extends Y ? 1 : 2) ? true : false
5
+ (<T>() => T extends Y ? 1 : 2) ? true : false;
6
6
 
7
- export type NonEmptyArray<T> = readonly [T, ...readonly T[]];
8
- export type ReadonlyNonEmptyArray<T> = readonly [T, ...readonly T[]];
9
7
  export type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly [];
10
8
 
11
-
12
-
13
9
  export type Mapped<T extends IterableContainer, K> = { readonly
14
10
  -readonly [P in keyof T]: K;
15
11
  };
16
12
 
17
13
  export type ElementOf<Type extends readonly any[]> = Type[number];
18
14
  export type MergeTypes<T> = { readonly[KeyType in keyof T]: T[KeyType]} & {};
19
- export type Simplify<T> = T extends infer O ? { readonly [K in keyof O]: O[K] } : never;
15
+ export type MergeTypesAlternative<T> = T extends infer O ? { readonly [K in keyof O]: O[K] } : never;
20
16
 
21
17
  export type EntryForKey<T, Key extends keyof T> = Key extends number | string
22
18
  ? readonly [key: `${Key}`, value: Required<T>[Key]]
@@ -26,16 +22,13 @@ export type Entry<T> = MergeTypes<{ readonly [P in keyof T]-?: EntryForKey<T, P>
26
22
 
27
23
  export type Ord = number | string | boolean | Date;
28
24
  export type Ordering = -1 | 0 | 1;
29
- type Path = ReadonlyArray<string> | string;
30
- type Prop<T, P extends keyof never> = P extends keyof Exclude<T, undefined>
31
- ? T extends undefined ? undefined : T[Extract<P, keyof T>]
32
- : undefined;
33
25
 
34
26
  interface KeyValuePair<K, V> extends Array<K | V> {
35
27
  readonly 0: K;
36
28
  readonly 1: V;
37
29
  }
38
- export type Functor<A> = { readonly map: <B>(fn: (a: A) => B) => Functor<B>; readonly [key: string]: any };
30
+
31
+ export type Functor<A> = { readonly map: <B>(fn: (x: A) => B) => Functor<B>; readonly [key: string]: any };
39
32
  export type DeepModify<Keys extends readonly PropertyKey[], U, T> =
40
33
  Keys extends readonly [infer K, ...infer Rest]
41
34
  ? K extends keyof U
@@ -48,44 +41,10 @@ export type DeepModify<Keys extends readonly PropertyKey[], U, T> =
48
41
  : never;
49
42
 
50
43
 
51
- export type PickStringToPickPath<T> = T extends `${infer Head},${infer Tail}` ? readonly [Head, ...PickStringToPickPath<Tail>]
44
+ export type PickStringToPickPath<T> = T extends `${infer Head},${infer Tail}` ? readonly [Head, ...PickStringToPickPath<Tail>]
52
45
  : T extends `${infer Head}` ? readonly [Head]
53
46
  : readonly [];
54
47
 
55
-
56
- export type Partial<T> = { readonly [P in keyof T]?: T[P]};
57
-
58
- type Evolvable<E extends Evolver> = { readonly[P in keyof E]?: Evolved<E[P]>};
59
-
60
- type Evolver<T extends Evolvable<any> = any> = { readonly [key in keyof Partial<T>]: ((value: T[key]) => T[key]) | (T[key] extends Evolvable<any> ? Evolver<T[key]> : never);
61
- };
62
-
63
- type Evolve<O extends Evolvable<E>, E extends Evolver> = { readonly [P in keyof O]: P extends keyof E
64
- ? EvolveValue<O[P], E[P]>
65
- : O[P];
66
- };
67
-
68
- type Evolved<A> =
69
- A extends (value: infer V) => any
70
- ? V
71
- : A extends Evolver
72
- ? Evolvable<A>
73
- : never;
74
-
75
- type EvolveNestedValue<O, E extends Evolver> =
76
- O extends object
77
- ? O extends Evolvable<E>
78
- ? Evolve<O, E>
79
- : never
80
- : never;
81
-
82
- type EvolveValue<V, E> =
83
- E extends (value: V) => any
84
- ? ReturnType<E>
85
- : E extends Evolver
86
- ? EvolveNestedValue<V, E>
87
- : never;
88
-
89
48
  declare const emptyObjectSymbol: unique symbol;
90
49
  type EmptyObject = {readonly [emptyObjectSymbol]?: never};
91
50
  type EnumerableStringKeyOf<T> =
@@ -105,12 +64,85 @@ type MappedValues<T extends object, Value> = MergeTypes<{ readonly
105
64
  -readonly [P in keyof T as `${P extends number | string ? P : never}`]: Value;
106
65
  }>;
107
66
 
108
- export function T(): boolean;
67
+ type SimpleMerge<Destination, Source> = { readonly
68
+ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
69
+ } & Source;
70
+
71
+ type OmitIndexSignature<ObjectType> = { readonly
72
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
73
+ ? never
74
+ : KeyType]: ObjectType[KeyType];
75
+ };
76
+
77
+ type PickIndexSignature<ObjectType> = { readonly
78
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
79
+ ? KeyType
80
+ : never]: ObjectType[KeyType];
81
+ };
82
+
83
+ type Merge<Destination, Source> =
84
+ MergeTypes<
85
+ SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
86
+ & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
87
+ >;
88
+
89
+ type StrictNonNullable<T> = Exclude<T, null | undefined>;
90
+
91
+ type Flatten<T> = T extends object
92
+ ? T extends readonly any[]
93
+ ? T
94
+ : { readonly
95
+ [K in keyof T]-?: NonNullable<T[K]> extends infer V
96
+ ? V extends object
97
+ ? V extends readonly any[]
98
+ ? never
99
+ : Flatten<V>
100
+ : V
101
+ : never
102
+ }
103
+ : T;
104
+
105
+ export type FlattenObject<T extends object> = object extends T
106
+ ? object
107
+ : { readonly
108
+ [K in keyof T]-?: (
109
+ x: NonNullable<T[K]> extends infer V
110
+ ? V extends object
111
+ ? V extends readonly any[]
112
+ ? never
113
+ : Flatten<V> extends infer FV
114
+ ? { readonly
115
+ [P in keyof FV as `${Extract<K, string>}.${Extract<P, string>}`]: FV[P]
116
+ }
117
+ : never
118
+ : Pick<T, K>
119
+ : never
120
+ ) => void
121
+ } extends Record<keyof T, (y: infer O) => void>
122
+ ? O
123
+ : never;
109
124
 
110
125
  /**
111
- * It adds `a` and `b`.
126
+ * It adds new key-value pair to the object.
112
127
  */
113
- export function add(a: number): (b: number) => number;
128
+ export function addProp<T extends object, P extends PropertyKey, V extends unknown>(
129
+ prop: P,
130
+ value: V
131
+ ): (obj: T) => MergeTypes<T & Record<P, V>>;
132
+
133
+ /**
134
+ * It receives list of objects and add new property to each item.
135
+ *
136
+ * The value is based on result of `fn` function, which receives the current object as argument.
137
+ */
138
+ export function addPropToObjects<
139
+ T extends object,
140
+ K extends string,
141
+ R
142
+ >(
143
+ property: K,
144
+ fn: (input: T) => R
145
+ ): (list: readonly T[]) => readonly MergeTypes<T & { readonly [P in K]: R }>[];
114
146
 
115
147
  /**
116
148
  * It returns `true`, if all members of array `list` returns `true`, when applied as argument to `predicate` function.
@@ -169,11 +201,27 @@ export function anyPass<F extends (...args: readonly any[]) => boolean>(predicat
169
201
  export function append<T>(el: T): (list: readonly T[]) => readonly T[];
170
202
  export function append<T>(el: T): (list: readonly T[]) => readonly T[];
171
203
 
204
+ /**
205
+ * Helper function to be used with `R.sort` to sort list in ascending order.
206
+ */
207
+ export function ascend<T>(fn: (obj: T) => Ord): (a: T, b: T)=> Ordering;
208
+
172
209
  /**
173
210
  * It returns `true` if all each property in `conditions` returns `true` when applied to corresponding property in `input` object.
174
211
  */
175
212
  export function checkObjectWithSpec<T>(spec: T): <U>(testObj: U) => boolean;
176
213
 
214
+ /**
215
+ * It removes `null` and `undefined` members from list or object input.
216
+ */
217
+ export function compact<T>(list: readonly T[]): ReadonlyArray<StrictNonNullable<T>>;
218
+ export function compact<T extends object>(record: T): { readonly
219
+ [K in keyof T as Exclude<T[K], null | undefined> extends never
220
+ ? never
221
+ : K
222
+ ]: Exclude<T[K], null | undefined>
223
+ };
224
+
177
225
  /**
178
226
  * It returns `inverted` version of `origin` function that accept `input` as argument.
179
227
  *
@@ -195,35 +243,41 @@ export function count<T>(predicate: (x: T) => boolean): (list: readonly T[]) =>
195
243
  /**
196
244
  * It counts elements in a list after each instance of the input list is passed through `transformFn` function.
197
245
  */
198
- export function countBy<T>(fn: (a: T) => string | number): (list: readonly T[]) => { readonly [index: string]: number };
246
+ export function countBy<T>(fn: (x: T) => string | number): (list: readonly T[]) => { readonly [index: string]: number };
199
247
 
200
- /**
201
- * It decrements a number.
202
- */
203
- export function dec(x: number): number;
248
+ export function createObjectFromKeys<const K extends readonly PropertyKey[], V>(
249
+ fn: (key: K[number]) => V
250
+ ): (keys: K) => { readonly [P in K[number]]: V };
251
+ export function createObjectFromKeys<const K extends readonly PropertyKey[], V>(
252
+ fn: (key: K[number], index: number) => V
253
+ ): (keys: K) => { readonly [P in K[number]]: V };
204
254
 
205
255
  /**
206
256
  * It returns `defaultValue`, if all of `inputArguments` are `undefined`, `null` or `NaN`.
207
257
  *
208
258
  * Else, it returns the first truthy `inputArguments` instance(from left to right).
209
259
  */
210
- export function defaultTo<T>(defaultValue: T, input: T | null | undefined): T;
211
- export function defaultTo<T>(defaultValue: T): <U>(input: U | null | undefined) => EqualTypes<U, T> extends true ? T : never
260
+ export function defaultTo<T>(defaultValue: T): (input: unknown) => T;
212
261
 
213
262
  /**
214
- * It returns `howMany` items dropped from beginning of list or string `input`.
263
+ * Helper function to be used with `R.sort` to sort list in descending order.
264
+ */
265
+ export function descend<T>(fn: (obj: T) => Ord): (a: T, b: T)=> Ordering;
266
+
267
+ /**
268
+ * It returns `howMany` items dropped from beginning of list.
215
269
  */
216
270
  export function drop<T>(howMany: number): (list: readonly T[]) => readonly T[];
217
271
 
218
272
  /**
219
- * It returns `howMany` items dropped from the end of list or string `input`.
273
+ * It returns `howMany` items dropped from the end of list.
220
274
  */
221
275
  export function dropLast<T>(howMany: number): (list: readonly T[]) => readonly T[];
222
276
 
223
277
  export function dropLastWhile<T>(predicate: (x: T, index: number) => boolean): (list: readonly T[]) => readonly T[];
224
278
  export function dropLastWhile<T>(predicate: (x: T) => boolean): (list: readonly T[]) => readonly T[];
225
279
 
226
- export function dropRepeatsBy<T, U>(fn: (a: T) => U): (list: readonly T[]) => readonly T[];
280
+ export function dropRepeatsBy<T, U>(fn: (x: T) => U): (list: readonly T[]) => readonly T[];
227
281
 
228
282
  export function dropRepeatsWith<T>(predicate: (x: T, y: T) => boolean): (list: readonly T[]) => readonly T[];
229
283
 
@@ -235,7 +289,7 @@ export function eqBy<T>(fn: (x: T) => unknown, a: T): (b: T) => boolean;
235
289
  /**
236
290
  * It returns `true` if property `prop` in `obj1` is equal to property `prop` in `obj2` according to `R.equals`.
237
291
  */
238
- export function eqProps<T>(prop: string, obj1: T): <U>(obj2: U) => boolean;
292
+ export function eqProps<T, K extends keyof T>(prop: K, obj1: T): (obj2: T) => boolean;
239
293
 
240
294
  /**
241
295
  * It deeply compares `x` and `y` and returns `true` if they are equal.
@@ -245,8 +299,11 @@ export function equals<T>(x: T): (y: T) => boolean;
245
299
 
246
300
  /**
247
301
  * It takes object of functions as set of rules. These `rules` are applied to the `iterable` input to produce the result.
302
+ * It doesn't support nested rules, i.e rules are only one level deep.
248
303
  */
249
- export function evolve<E extends Evolver>(rules: E): <V extends Evolvable<E>>(obj: V) => Evolve<V, E>;
304
+ export function evolve<T>(rules: { readonly
305
+ [K in keyof T]?: (x: T[K]) => T[K]
306
+ }): (obj: T) => T;
250
307
 
251
308
  /**
252
309
  * Opposite of `R.includes`
@@ -264,10 +321,10 @@ export function filter<T, S extends T>(
264
321
  ): (list: readonly T[]) => readonly S[];
265
322
  export function filter<T>(
266
323
  predicate: BooleanConstructor,
267
- ): (list: readonly T[]) => readonly NonNullable<T>[];
324
+ ): (list: readonly T[]) => readonly StrictNonNullable<T>[];
268
325
  export function filter<T>(
269
326
  predicate: BooleanConstructor,
270
- ): (list: readonly T[]) => readonly NonNullable<T>[];
327
+ ): (list: readonly T[]) => readonly StrictNonNullable<T>[];
271
328
  export function filter<T>(
272
329
  predicate: (value: T) => boolean,
273
330
  ): (list: readonly T[]) => readonly T[];
@@ -311,6 +368,11 @@ export function findLast<T>(fn: (x: T) => boolean): (list: readonly T[]) => T |
311
368
  */
312
369
  export function findLastIndex<T>(predicate: (x: T) => boolean): (list: readonly T[]) => number;
313
370
 
371
+ /**
372
+ * It returns the `nth` element of `list` that satisfy the `predicate` function.
373
+ */
374
+ export function findNth<T>(predicate: (x: T) => boolean, nth: number): (list: readonly T[]) => T | undefined;
375
+
314
376
  /**
315
377
  * It maps `fn` over `list` and then flatten the result by one-level.
316
378
  */
@@ -318,13 +380,19 @@ export function flatMap<T, U extends unknown>(transformFn: (x: T extends readonl
318
380
 
319
381
  /**
320
382
  * It deeply flattens an array.
383
+ * You must pass expected output type as a type argument.
321
384
  */
322
385
  export function flatten<T>(list: readonly any[]): readonly T[];
323
386
 
387
+ /**
388
+ * It transforms object to object where each value is represented with its path.
389
+ */
390
+ export function flattenObject<T extends object>(obj: T): FlattenObject<T>;
391
+
324
392
  /**
325
393
  * It splits `list` according to a provided `groupFn` function and returns an object.
326
394
  */
327
- export function groupBy<T, K extends string = string>(fn: (a: T) => K): (list: readonly T[]) => Partial<Record<K, readonly T[]>>;
395
+ export function groupBy<T, K extends string = string>(fn: (x: T) => K): (list: readonly T[]) => Partial<Record<K, readonly T[]>>;
328
396
 
329
397
  /**
330
398
  * It returns the first element of list or string `input`. It returns `undefined` if array has length of 0.
@@ -338,18 +406,6 @@ export function head<T>(listOrString: T): T extends string ? string :
338
406
  T extends readonly unknown[] ? T[number] :
339
407
  undefined;
340
408
 
341
- /**
342
- * It expects `condition`, `onTrue` and `onFalse` functions as inputs and it returns a new function with example name of `fn`.
343
- *
344
- * When `fn`` is called with `input` argument, it will return either `onTrue(input)` or `onFalse(input)` depending on `condition(input)` evaluation.
345
- */
346
- export function ifElse<T, TFiltered extends T, TOnTrueResult, TOnFalseResult>(
347
- pred: (a: T) => a is TFiltered,
348
- onTrue: (a: TFiltered) => TOnTrueResult,
349
- onFalse: (a: Exclude<T, TFiltered>) => TOnFalseResult,
350
- ): (a: T) => TOnTrueResult | TOnFalseResult;
351
- export function ifElse<TArgs extends readonly any[], TOnTrueResult, TOnFalseResult>(fn: (...args: TArgs) => boolean, onTrue: (...args: TArgs) => TOnTrueResult, onFalse: (...args: TArgs) => TOnFalseResult): (...args: TArgs) => TOnTrueResult | TOnFalseResult;
352
-
353
409
  /**
354
410
  * If `input` is string, then this method work as native `String.includes`.
355
411
  *
@@ -377,10 +433,20 @@ export function innerJoin<T1, T2>(
377
433
  list1: readonly T1[],
378
434
  ): (list2: readonly T2[]) => readonly T1[];
379
435
 
436
+ /**
437
+ * It generates a new string from `inputWithTags` by replacing all `{{x}}` occurrences with values provided by `templateArguments`.
438
+ */
439
+ export function interpolate(inputWithTags: string): (templateArguments: object) => string;
440
+
441
+
442
+ // API_MARKER_END
443
+ // ============================================
444
+
445
+ export as namespace R
446
+
380
447
  /**
381
448
  * It loops through `listA` and `listB` and returns the intersection of the two according to `R.equals`.
382
449
  */
383
- export function intersection<T>(listA: readonly T[], listB: readonly T[]): readonly T[];
384
450
  export function intersection<T>(listA: readonly T[]): (listB: readonly T[]) => readonly T[];
385
451
 
386
452
  /**
@@ -388,14 +454,9 @@ export function intersection<T>(listA: readonly T[]): (listB: readonly T[]) => r
388
454
  */
389
455
  export function intersperse<T>(separator: T): (list: readonly T[]) => readonly T[];
390
456
 
391
- export function isNotEmpty<T>(value: readonly T[]): value is NonEmptyArray<T>;
392
- export function isNotEmpty<T>(value: readonly T[]): value is ReadonlyNonEmptyArray<T>;
393
- export function isNotEmpty(value: any): boolean;
394
-
395
457
  /**
396
458
  * It returns a string of all `list` instances joined with a `glue`.
397
459
  */
398
- export function join<T>(glue: string, list: readonly T[]): string;
399
460
  export function join<T>(glue: string): (list: readonly T[]) => string;
400
461
 
401
462
  /**
@@ -417,7 +478,6 @@ export function last<T>(listOrString: T): T extends string ? string :
417
478
  *
418
479
  * If there is no such index, then `-1` is returned.
419
480
  */
420
- export function lastIndexOf<T>(target: T, list: readonly T[]): number;
421
481
  export function lastIndexOf<T>(target: T): (list: readonly T[]) => number;
422
482
 
423
483
  /**
@@ -458,6 +518,11 @@ export function mapAsync<T extends IterableContainer, U>(
458
518
  data: T
459
519
  ): Promise<Mapped<T, U>>;
460
520
 
521
+ /**
522
+ * It returns a copy of `obj` with keys transformed by `fn`.
523
+ */
524
+ export function mapKeys<T>(fn: (prop: string, value: T) => string): (obj: Record<string, T>) => Record<string, T>;
525
+
461
526
  export function mapObject<T extends object, Value>(
462
527
  valueMapper: (
463
528
  value: EnumerableStringKeyedValueOf<T>,
@@ -474,57 +539,38 @@ export function mapObjectAsync<T extends object, Value>(
474
539
  ) => Promise<Value>,
475
540
  ): (data: T) => Promise<MappedValues<T, Value>>;
476
541
 
477
- // API_MARKER_END
478
- // ============================================
479
-
480
- export as namespace R
481
-
482
- /**
483
- * Curried version of `String.prototype.match` which returns empty array, when there is no match.
484
- */
485
- export function match(regExpression: RegExp, str: string): readonly string[];
486
- export function match(regExpression: RegExp): (str: string) => readonly string[];
487
-
488
542
  /**
489
- * `R.mathMod` behaves like the modulo operator should mathematically, unlike the `%` operator (and by extension, `R.modulo`). So while `-17 % 5` is `-2`, `mathMod(-17, 5)` is `3`.
543
+ * Wrapper around `Promise.all` for asynchronous mapping with `fn` over members of `list`.
490
544
  */
491
- export function mathMod(x: number, y: number): number;
492
- export function mathMod(x: number): (y: number) => number;
545
+ export function mapParallelAsync<T extends IterableContainer, U>(
546
+ fn: (value: T[number], index: number) => Promise<U>,
547
+ ): (data: T) => Promise<Mapped<T, U>>;
548
+ export function mapParallelAsync<T extends IterableContainer, U>(
549
+ fn: (value: T[number]) => Promise<U>,
550
+ ): (data: T) => Promise<Mapped<T, U>>;
551
+ export function mapParallelAsync<T extends IterableContainer, U>(
552
+ fn: (value: T[number], index: number) => Promise<U>,
553
+ data: T
554
+ ): Promise<Mapped<T, U>>;
555
+ export function mapParallelAsync<T extends IterableContainer, U>(
556
+ fn: (value: T[number]) => Promise<U>,
557
+ data: T
558
+ ): Promise<Mapped<T, U>>;
493
559
 
494
560
  /**
495
- * It returns the greater value between `x` and `y`.
561
+ * Curried version of `String.prototype.match` which returns empty array, when there is no match.
496
562
  */
497
- export function max<T extends Ord>(x: T, y: T): T;
498
- export function max<T extends Ord>(x: T): (y: T) => T;
563
+ export function match(regExpression: RegExp): (str: string) => readonly string[];
499
564
 
500
565
  /**
501
566
  * It returns the greater value between `x` and `y` according to `compareFn` function.
502
567
  */
503
- export function maxBy<T>(compareFn: (input: T) => Ord, x: T, y: T): T;
504
568
  export function maxBy<T>(compareFn: (input: T) => Ord, x: T): (y: T) => T;
505
- export function maxBy<T>(compareFn: (input: T) => Ord): (x: T) => (y: T) => T;
506
569
 
507
570
  /**
508
- * It returns the mean value of `list` input.
571
+ * It creates a copy of `target` object with overwritten `newProps` properties.
509
572
  */
510
- export function mean(list: readonly number[]): number;
511
-
512
- /**
513
- * It returns the median value of `list` input.
514
- */
515
- export function median(list: readonly number[]): number;
516
-
517
- /**
518
- * Same as `R.mergeRight`.
519
- */
520
- export function merge<A, B>(target: A, newProps: B): A & B
521
- export function merge<Output>(target: any): (newProps: any) => Output;
522
-
523
- /**
524
- * It creates a copy of `target` object with overwritten `newProps` properties. Previously known as `R.merge` but renamed after Ramda did the same.
525
- */
526
- export function mergeRight<A, B>(target: A, newProps: B): A & B
527
- export function mergeRight<Output>(target: any): (newProps: any) => Output;
573
+ export function merge<Source>(source: Source): <T>(data: T) => Merge<T, Source>;
528
574
 
529
575
  /**
530
576
  * Helper to merge all calculated TypeScript definitions into one definition.
@@ -533,140 +579,22 @@ export function mergeRight<Output>(target: any): (newProps: any) => Output;
533
579
  export function mergeTypes<T>(x: T): MergeTypes<T>;
534
580
 
535
581
  /**
536
- * It returns the lesser value between `x` and `y`.
582
+ * It returns the lesser value between `x` and `y` according to `compareFn` function.
537
583
  */
538
- export function min<T extends Ord>(x: T): (y: T) => T;
584
+ export function minBy<T>(compareFn: (input: T) => Ord, x: T): (y: T) => T;
539
585
 
540
586
  /**
541
- * It returns the lesser value between `x` and `y` according to `compareFn` function.
587
+ * It replaces `index` in array `list` with the result of `replaceFn(list[i])`.
542
588
  */
543
- export function minBy<T>(compareFn: (input: T) => Ord, x: T): (y: T) => T;
589
+ export function modifyItemAtIndex<T>(index: number, replaceFn: (x: T) => T): (list: readonly T[]) => readonly T[];
544
590
 
545
591
  /**
546
592
  * It changes a property with the result of transformer function.
547
593
  */
548
- export function modify<K extends string, A, P>(
594
+ export function modifyProp<T, K extends keyof T>(
549
595
  prop: K,
550
- fn: (a: A) => P,
551
- ): <T extends Record<K, A>>(target: T) => Omit<T, K> & Record<K, P>;
552
-
553
- /**
554
- * It changes a property of object on the base of provided path and transformer function.
555
- */
556
- export function modifyPath<U, T>(path: readonly [], fn: (value: U) => T): (obj: U) => T;
557
- export function modifyPath<
558
- K0 extends keyof U,
559
- U,
560
- T
561
- >(path: readonly [K0], fn: (value: U[K0]) => T): (obj: U) => DeepModify<readonly [K0], U, T>;
562
- export function modifyPath<
563
- K0 extends keyof U,
564
- U,
565
- T
566
- >(path: `${K0}`, fn: (value: U[K0]) => T): (obj: U) => DeepModify<readonly [K0], U, T>;
567
- export function modifyPath<
568
- K0 extends keyof U,
569
- K1 extends keyof U[K0],
570
- U,
571
- T
572
- >(path: readonly [K0, K1], fn: (value: U[K0][K1]) => T): (obj: U) => DeepModify<readonly [K0, K1], U, T>;
573
- export function modifyPath<
574
- K0 extends keyof U,
575
- K1 extends keyof U[K0],
576
- U,
577
- T
578
- >(path: `${K0}.${K1}`, fn: (value: U[K0][K1]) => T): (obj: U) => DeepModify<readonly [K0, K1], U, T>;
579
- export function modifyPath<
580
- K0 extends keyof U,
581
- K1 extends keyof U[K0],
582
- K2 extends keyof U[K0][K1],
583
- U,
584
- T
585
- >(path: readonly [K0, K1, K2], fn: (value: U[K0][K1][K2]) => T): (obj: U) => DeepModify<readonly [K0, K1, K2], U, T>;
586
- export function modifyPath<
587
- K0 extends keyof U,
588
- K1 extends keyof U[K0],
589
- K2 extends keyof U[K0][K1],
590
- U,
591
- T
592
- >(path: `${K0}.${K1}.${K2}`, fn: (value: U[K0][K1][K2]) => T): (obj: U) => DeepModify<readonly [K0, K1, K2], U, T>;
593
- export function modifyPath<
594
- K0 extends keyof U,
595
- K1 extends keyof U[K0],
596
- K2 extends keyof U[K0][K1],
597
- K3 extends keyof U[K0][K1][K2],
598
- U,
599
- T
600
- >(path: readonly [K0, K1, K2, K3], fn: (value: U[K0][K1][K2][K3]) => T): (obj: U) => DeepModify<readonly [K0, K1, K2, K3], U, T>;
601
- export function modifyPath<
602
- K0 extends keyof U,
603
- K1 extends keyof U[K0],
604
- K2 extends keyof U[K0][K1],
605
- K3 extends keyof U[K0][K1][K2],
606
- U,
607
- T
608
- >(path: `${K0}.${K1}.${K2}.${K3}`, fn: (value: U[K0][K1][K2][K3]) => T): (obj: U) => DeepModify<readonly [K0, K1, K2, K3], U, T>;
609
- export function modifyPath<
610
- K0 extends keyof U,
611
- K1 extends keyof U[K0],
612
- K2 extends keyof U[K0][K1],
613
- K3 extends keyof U[K0][K1][K2],
614
- K4 extends keyof U[K0][K1][K2][K3],
615
- U,
616
- T
617
- >(path: readonly [K0, K1, K2, K3, K4], fn: (value: U[K0][K1][K2][K3][K4]) => T): (obj: U) => DeepModify<readonly [K0, K1, K2, K3, K4], U, T>;
618
- export function modifyPath<
619
- K0 extends keyof U,
620
- K1 extends keyof U[K0],
621
- K2 extends keyof U[K0][K1],
622
- K3 extends keyof U[K0][K1][K2],
623
- K4 extends keyof U[K0][K1][K2][K3],
624
- U,
625
- T
626
- >(path: `${K0}.${K1}.${K2}.${K3}.${K4}`, fn: (value: U[K0][K1][K2][K3][K4]) => T): (obj: U) => DeepModify<readonly [K0, K1, K2, K3, K4], U, T>;
627
- export function modifyPath<
628
- K0 extends keyof U,
629
- K1 extends keyof U[K0],
630
- K2 extends keyof U[K0][K1],
631
- K3 extends keyof U[K0][K1][K2],
632
- K4 extends keyof U[K0][K1][K2][K3],
633
- K5 extends keyof U[K0][K1][K2][K3][K4],
634
- U,
635
- T
636
- >(path: readonly [K0, K1, K2, K3, K4, K5], fn: (value: U[K0][K1][K2][K3][K4][K5]) => T): (obj: U) => DeepModify<readonly [K0, K1, K2, K3, K4, K5], U, T>;
637
- export function modifyPath<
638
- K0 extends keyof U,
639
- K1 extends keyof U[K0],
640
- K2 extends keyof U[K0][K1],
641
- K3 extends keyof U[K0][K1][K2],
642
- K4 extends keyof U[K0][K1][K2][K3],
643
- K5 extends keyof U[K0][K1][K2][K3][K4],
644
- U,
645
- T
646
- >(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}`, fn: (value: U[K0][K1][K2][K3][K4][K5]) => T): (obj: U) => DeepModify<readonly [K0, K1, K2, K3, K4, K5], U, T>;
647
- export function modifyPath<
648
- K0 extends keyof U,
649
- K1 extends keyof U[K0],
650
- K2 extends keyof U[K0][K1],
651
- K3 extends keyof U[K0][K1][K2],
652
- K4 extends keyof U[K0][K1][K2][K3],
653
- K5 extends keyof U[K0][K1][K2][K3][K4],
654
- K6 extends keyof U[K0][K1][K2][K3][K4][K5],
655
- U,
656
- T
657
- >(path: readonly [K0, K1, K2, K3, K4, K5, K6], fn: (value: U[K0][K1][K2][K3][K4][K5][K6]) => T): (obj: U) => DeepModify<readonly [K0, K1, K2, K3, K4, K5, K6], U, T>;
658
- export function modifyPath<
659
- K0 extends keyof U,
660
- K1 extends keyof U[K0],
661
- K2 extends keyof U[K0][K1],
662
- K3 extends keyof U[K0][K1][K2],
663
- K4 extends keyof U[K0][K1][K2][K3],
664
- K5 extends keyof U[K0][K1][K2][K3][K4],
665
- K6 extends keyof U[K0][K1][K2][K3][K4][K5],
666
- U,
667
- T
668
- >(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}`, fn: (value: U[K0][K1][K2][K3][K4][K5][K6]) => T): (obj: U) => DeepModify<readonly [K0, K1, K2, K3, K4, K5, K6], U, T>;
669
- export function modifyPath<B, A = any>(path: Path, fn: (a: any) => any): (obj: A) => B;
596
+ fn: (x: T[K]) => T[K],
597
+ ): (target: T) => T;
670
598
 
671
599
  /**
672
600
  * It returns `true`, if all members of array `list` returns `false`, when applied as argument to `predicate` function.
@@ -683,7 +611,7 @@ export function objOf<T, K extends PropertyKey>(key: K): (value: T) => { readonl
683
611
  *
684
612
  * `R.equals` is used to determine equality.
685
613
  */
686
- export function objectIncludes<T>(specification: T): <U>(obj: U) => boolean;
614
+ export function objectIncludes<T>(specification: T): (obj: Partial<T>) => boolean;
687
615
 
688
616
  /**
689
617
  * It returns a partial copy of an `obj` without `propsToOmit` properties.
@@ -691,11 +619,17 @@ export function objectIncludes<T>(specification: T): <U>(obj: U) => boolean;
691
619
  export function omit<
692
620
  S extends string,
693
621
  Keys extends PickStringToPickPath<S>,
694
- >(propsToPick: S): <U extends Partial<Record<ElementOf<Keys>, any>>>(obj: ElementOf<Keys> extends keyof U ? U : never) => ElementOf<Keys> extends keyof U ? MergeTypes<Omit<U, ElementOf<Keys>>> : never;
695
- export function omit<const Keys extends readonly PropertyKey[]>(propsToPick: Keys): <U extends Partial<Record<ElementOf<Keys>, any>>>(obj: ElementOf<Keys> extends keyof U ? U : never) => ElementOf<Keys> extends keyof U ? MergeTypes<Omit<U, ElementOf<Keys>>> : never;
622
+ >(propsToPick: S): <U extends Partial<Record<ElementOf<Keys>, any>>>(
623
+ obj: ElementOf<Keys> extends keyof U ? U : never
624
+ ) => ElementOf<Keys> extends keyof U ? MergeTypes<Omit<U, ElementOf<Keys>>> : never;
625
+ export function omit<const Keys extends readonly PropertyKey[]>(propsToPick: Keys): <
626
+ U extends Partial<Record<ElementOf<Keys>, any>>
627
+ >(
628
+ obj: ElementOf<Keys> extends keyof U ? U : never
629
+ ) => ElementOf<Keys> extends keyof U ? MergeTypes<Omit<U, ElementOf<Keys>>> : never;
696
630
 
697
631
  /**
698
- * It will return array of two objects/arrays according to `predicate` function. The first member holds all instances of `input` that pass the `predicate` function, while the second member - those who doesn't.
632
+ * It will return array of two arrays according to `predicate` function. The first member holds all instances of `input` that pass the `predicate` function, while the second member - those who doesn't.
699
633
  */
700
634
  export function partition<T, S extends T>(
701
635
  predicate: (value: T, index: number, data: ReadonlyArray<T>) => value is S,
@@ -704,27 +638,184 @@ export function partition<T>(
704
638
  predicate: (value: T, index: number, data: ReadonlyArray<T>) => boolean,
705
639
  ): (data: ReadonlyArray<T>) => readonly [ReadonlyArray<T>, ReadonlyArray<T>];
706
640
 
641
+ /**
642
+ * It returns an array containing two objects. The first object holds all properties of the input object for which the predicate returns true, while the second object holds those that do not.
643
+ */
644
+ export function partitionObject<T extends unknown, S extends T>(
645
+ predicate: (value: T, prop: string, obj: Record<string, T>) => value is S,
646
+ ): (obj: Record<string, T>) => readonly [Record<string, S>, Record<string, Exclude<T, S>>];
647
+ export function partitionObject<T extends unknown>(
648
+ predicate: (value: T, prop: string, obj: Record<string, T>) => boolean,
649
+ ): (obj: Record<string, T>) => readonly [Record<string, T>, Record<string, T>];
650
+
707
651
  /**
708
652
  * If `pathToSearch` is `'a.b'` then it will return `1` if `obj` is `{a:{b:1}}`.
709
653
  *
710
654
  * It will return `undefined`, if such path is not found.
711
655
  */
656
+ export function path<S, K0 extends string & keyof S>(path: `${K0}`): (obj: S) => S[K0];
657
+ export function path<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(path: `${K0}.${K1}`): (obj: S) => S[K0][K1];
658
+ export function path<
659
+ S,
660
+ K0 extends keyof S,
661
+ K1 extends keyof S[K0],
662
+ K2 extends keyof S[K0][K1]
663
+ >(path: readonly [K0, K1, K2]): (obj: S) => S[K0][K1][K2];
664
+ export function path<
665
+ S,
666
+ K0 extends string & keyof S,
667
+ K1 extends string & keyof S[K0],
668
+ K2 extends string & keyof S[K0][K1]
669
+ >(path: `${K0}.${K1}.${K2}`): (obj: S) => S[K0][K1][K2];
670
+ export function path<
671
+ S,
672
+ K0 extends keyof S,
673
+ K1 extends keyof S[K0],
674
+ K2 extends keyof S[K0][K1],
675
+ K3 extends keyof S[K0][K1][K2]
676
+ >(path: readonly [K0, K1, K2, K3]): (obj: S) => S[K0][K1][K2][K3];
677
+ export function path<
678
+ S,
679
+ K0 extends string & keyof S,
680
+ K1 extends string & keyof S[K0],
681
+ K2 extends string & keyof S[K0][K1],
682
+ K3 extends string & keyof S[K0][K1][K2]
683
+ >(path: `${K0}.${K1}.${K2}.${K3}`): (obj: S) => S[K0][K1][K2][K3];
684
+ export function path<
685
+ S,
686
+ K0 extends keyof S,
687
+ K1 extends keyof S[K0],
688
+ K2 extends keyof S[K0][K1],
689
+ K3 extends keyof S[K0][K1][K2],
690
+ K4 extends keyof S[K0][K1][K2][K3]
691
+ >(path: readonly [K0, K1, K2, K3, K4]): (obj: S) => S[K0][K1][K2][K3][K4];
692
+ export function path<
693
+ S,
694
+ K0 extends string & keyof S,
695
+ K1 extends string & keyof S[K0],
696
+ K2 extends string & keyof S[K0][K1],
697
+ K3 extends string & keyof S[K0][K1][K2],
698
+ K4 extends string & keyof S[K0][K1][K2][K3]
699
+ >(path: `${K0}.${K1}.${K2}.${K3}.${K4}`): (obj: S) => S[K0][K1][K2][K3][K4];
700
+ export function path<
701
+ S,
702
+ K0 extends keyof S,
703
+ K1 extends keyof S[K0],
704
+ K2 extends keyof S[K0][K1],
705
+ K3 extends keyof S[K0][K1][K2],
706
+ K4 extends keyof S[K0][K1][K2][K3]
707
+ >(path: readonly [K0, K1, K2, K3, K4], obj: S): S[K0][K1][K2][K3][K4];
708
+ export function path<
709
+ S,
710
+ K0 extends keyof S,
711
+ K1 extends keyof S[K0],
712
+ K2 extends keyof S[K0][K1],
713
+ K3 extends keyof S[K0][K1][K2],
714
+ K4 extends keyof S[K0][K1][K2][K3],
715
+ K5 extends keyof S[K0][K1][K2][K3][K4]
716
+ >(path: readonly [K0, K1, K2, K3, K4, K5]): (obj: S) => S[K0][K1][K2][K3][K4][K5];
717
+ export function path<
718
+ S,
719
+ K0 extends string & keyof S,
720
+ K1 extends string & keyof S[K0],
721
+ K2 extends string & keyof S[K0][K1],
722
+ K3 extends string & keyof S[K0][K1][K2],
723
+ K4 extends string & keyof S[K0][K1][K2][K3],
724
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
725
+ >(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}`): (obj: S) => S[K0][K1][K2][K3][K4][K5];
726
+ export function path<
727
+ S,
728
+ K0 extends keyof S,
729
+ K1 extends keyof S[K0],
730
+ K2 extends keyof S[K0][K1],
731
+ K3 extends keyof S[K0][K1][K2],
732
+ K4 extends keyof S[K0][K1][K2][K3],
733
+ K5 extends keyof S[K0][K1][K2][K3][K4]
734
+ >(path: readonly [K0, K1, K2, K3, K4, K5], obj: S): S[K0][K1][K2][K3][K4][K5];
735
+ export function path<
736
+ S,
737
+ K0 extends keyof S,
738
+ K1 extends keyof S[K0],
739
+ K2 extends keyof S[K0][K1],
740
+ K3 extends keyof S[K0][K1][K2],
741
+ K4 extends keyof S[K0][K1][K2][K3],
742
+ K5 extends keyof S[K0][K1][K2][K3][K4],
743
+ K6 extends keyof S[K0][K1][K2][K3][K4][K5]
744
+ >(path: readonly [K0, K1, K2, K3, K4, K5, K6]): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6];
745
+ export function path<
746
+ S,
747
+ K0 extends string & keyof S,
748
+ K1 extends string & keyof S[K0],
749
+ K2 extends string & keyof S[K0][K1],
750
+ K3 extends string & keyof S[K0][K1][K2],
751
+ K4 extends string & keyof S[K0][K1][K2][K3],
752
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
753
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
754
+ >(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}`): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6];
755
+ export function path<
756
+ S,
757
+ K0 extends keyof S,
758
+ K1 extends keyof S[K0],
759
+ K2 extends keyof S[K0][K1],
760
+ K3 extends keyof S[K0][K1][K2],
761
+ K4 extends keyof S[K0][K1][K2][K3],
762
+ K5 extends keyof S[K0][K1][K2][K3][K4],
763
+ K6 extends keyof S[K0][K1][K2][K3][K4][K5]
764
+ >(path: readonly [K0, K1, K2, K3, K4, K5, K6], obj: S): S[K0][K1][K2][K3][K4][K5][K6];
765
+ export function path<
766
+ S,
767
+ K0 extends keyof S,
768
+ K1 extends keyof S[K0],
769
+ K2 extends keyof S[K0][K1],
770
+ K3 extends keyof S[K0][K1][K2],
771
+ K4 extends keyof S[K0][K1][K2][K3],
772
+ K5 extends keyof S[K0][K1][K2][K3][K4],
773
+ K6 extends keyof S[K0][K1][K2][K3][K4][K5],
774
+ K7 extends keyof S[K0][K1][K2][K3][K4][K5][K6]
775
+ >(path: readonly [K0, K1, K2, K3, K4, K5, K6, K7]): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7];
776
+ export function path<
777
+ S,
778
+ K0 extends string & keyof S,
779
+ K1 extends string & keyof S[K0],
780
+ K2 extends string & keyof S[K0][K1],
781
+ K3 extends string & keyof S[K0][K1][K2],
782
+ K4 extends string & keyof S[K0][K1][K2][K3],
783
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
784
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
785
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
786
+ >(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}`): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7];
787
+ export function path<
788
+ S,
789
+ K0 extends keyof S,
790
+ K1 extends keyof S[K0],
791
+ K2 extends keyof S[K0][K1],
792
+ K3 extends keyof S[K0][K1][K2],
793
+ K4 extends keyof S[K0][K1][K2][K3],
794
+ K5 extends keyof S[K0][K1][K2][K3][K4],
795
+ K6 extends keyof S[K0][K1][K2][K3][K4][K5],
796
+ K7 extends keyof S[K0][K1][K2][K3][K4][K5][K6],
797
+ K8 extends keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
798
+ >(path: readonly [K0, K1, K2, K3, K4, K5, K6, K7, K8]): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7][K8];
799
+ export function path<
800
+ S,
801
+ K0 extends string & keyof S,
802
+ K1 extends string & keyof S[K0],
803
+ K2 extends string & keyof S[K0][K1],
804
+ K3 extends string & keyof S[K0][K1][K2],
805
+ K4 extends string & keyof S[K0][K1][K2][K3],
806
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
807
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
808
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
809
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
810
+ >(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}.${K8}`): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7][K8];
712
811
  export function path<S, K0 extends keyof S>(path: readonly [K0]): (obj: S) => S[K0];
713
- export function path<S, K0 extends keyof S>(path: `${K0}`): (obj: S) => S[K0];
714
812
  export function path<S, K0 extends keyof S, K1 extends keyof S[K0]>(path: readonly [K0, K1]): (obj: S) => S[K0][K1];
715
- export function path<S, K0 extends keyof S, K1 extends keyof S[K0]>(path: `${K0}.${K1}`): (obj: S) => S[K0][K1];
716
813
  export function path<
717
814
  S,
718
815
  K0 extends keyof S,
719
816
  K1 extends keyof S[K0],
720
817
  K2 extends keyof S[K0][K1]
721
818
  >(path: readonly [K0, K1, K2]): (obj: S) => S[K0][K1][K2];
722
- export function path<
723
- S,
724
- K0 extends keyof S,
725
- K1 extends keyof S[K0],
726
- K2 extends keyof S[K0][K1]
727
- >(path: `${K0}.${K1}.${K2}`): (obj: S) => S[K0][K1][K2];
728
819
  export function path<
729
820
  S,
730
821
  K0 extends keyof S,
@@ -732,13 +823,6 @@ export function path<
732
823
  K2 extends keyof S[K0][K1],
733
824
  K3 extends keyof S[K0][K1][K2]
734
825
  >(path: readonly [K0, K1, K2, K3]): (obj: S) => S[K0][K1][K2][K3];
735
- export function path<
736
- S,
737
- K0 extends keyof S,
738
- K1 extends keyof S[K0],
739
- K2 extends keyof S[K0][K1],
740
- K3 extends keyof S[K0][K1][K2]
741
- >(path: `${K0}.${K1}.${K2}.${K3}`): (obj: S) => S[K0][K1][K2][K3];
742
826
  export function path<
743
827
  S,
744
828
  K0 extends keyof S,
@@ -747,14 +831,6 @@ export function path<
747
831
  K3 extends keyof S[K0][K1][K2],
748
832
  K4 extends keyof S[K0][K1][K2][K3]
749
833
  >(path: readonly [K0, K1, K2, K3, K4]): (obj: S) => S[K0][K1][K2][K3][K4];
750
- export function path<
751
- S,
752
- K0 extends keyof S,
753
- K1 extends keyof S[K0],
754
- K2 extends keyof S[K0][K1],
755
- K3 extends keyof S[K0][K1][K2],
756
- K4 extends keyof S[K0][K1][K2][K3]
757
- >(path: `${K0}.${K1}.${K2}.${K3}.${K4}`): (obj: S) => S[K0][K1][K2][K3][K4];
758
834
  export function path<
759
835
  S,
760
836
  K0 extends keyof S,
@@ -772,15 +848,6 @@ export function path<
772
848
  K4 extends keyof S[K0][K1][K2][K3],
773
849
  K5 extends keyof S[K0][K1][K2][K3][K4]
774
850
  >(path: readonly [K0, K1, K2, K3, K4, K5]): (obj: S) => S[K0][K1][K2][K3][K4][K5];
775
- export function path<
776
- S,
777
- K0 extends keyof S,
778
- K1 extends keyof S[K0],
779
- K2 extends keyof S[K0][K1],
780
- K3 extends keyof S[K0][K1][K2],
781
- K4 extends keyof S[K0][K1][K2][K3],
782
- K5 extends keyof S[K0][K1][K2][K3][K4]
783
- >(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}`): (obj: S) => S[K0][K1][K2][K3][K4][K5];
784
851
  export function path<
785
852
  S,
786
853
  K0 extends keyof S,
@@ -800,16 +867,6 @@ export function path<
800
867
  K5 extends keyof S[K0][K1][K2][K3][K4],
801
868
  K6 extends keyof S[K0][K1][K2][K3][K4][K5]
802
869
  >(path: readonly [K0, K1, K2, K3, K4, K5, K6]): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6];
803
- export function path<
804
- S,
805
- K0 extends keyof S,
806
- K1 extends keyof S[K0],
807
- K2 extends keyof S[K0][K1],
808
- K3 extends keyof S[K0][K1][K2],
809
- K4 extends keyof S[K0][K1][K2][K3],
810
- K5 extends keyof S[K0][K1][K2][K3][K4],
811
- K6 extends keyof S[K0][K1][K2][K3][K4][K5]
812
- >(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}`): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6];
813
870
  export function path<
814
871
  S,
815
872
  K0 extends keyof S,
@@ -831,17 +888,6 @@ export function path<
831
888
  K6 extends keyof S[K0][K1][K2][K3][K4][K5],
832
889
  K7 extends keyof S[K0][K1][K2][K3][K4][K5][K6]
833
890
  >(path: readonly [K0, K1, K2, K3, K4, K5, K6, K7]): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7];
834
- export function path<
835
- S,
836
- K0 extends keyof S,
837
- K1 extends keyof S[K0],
838
- K2 extends keyof S[K0][K1],
839
- K3 extends keyof S[K0][K1][K2],
840
- K4 extends keyof S[K0][K1][K2][K3],
841
- K5 extends keyof S[K0][K1][K2][K3][K4],
842
- K6 extends keyof S[K0][K1][K2][K3][K4][K5],
843
- K7 extends keyof S[K0][K1][K2][K3][K4][K5][K6]
844
- >(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}`): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7];
845
891
  export function path<
846
892
  S,
847
893
  K0 extends keyof S,
@@ -854,18 +900,193 @@ export function path<
854
900
  K7 extends keyof S[K0][K1][K2][K3][K4][K5][K6],
855
901
  K8 extends keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
856
902
  >(path: readonly [K0, K1, K2, K3, K4, K5, K6, K7, K8]): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7][K8];
857
- export function path<
858
- S,
859
- K0 extends keyof S,
860
- K1 extends keyof S[K0],
861
- K2 extends keyof S[K0][K1],
862
- K3 extends keyof S[K0][K1][K2],
863
- K4 extends keyof S[K0][K1][K2][K3],
864
- K5 extends keyof S[K0][K1][K2][K3][K4],
865
- K6 extends keyof S[K0][K1][K2][K3][K4][K5],
866
- K7 extends keyof S[K0][K1][K2][K3][K4][K5][K6],
867
- K8 extends keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
868
- >(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}.${K8}`): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7][K8];
903
+
904
+ export function pathSatisfies<S, K0 extends string & keyof S>(
905
+ predicate: (x: S[K0]) => boolean,
906
+ path: readonly [K0]
907
+ ): (obj: S) => boolean;
908
+ export function pathSatisfies<S, K0 extends string & keyof S>(
909
+ predicate: (x: S[K0]) => boolean,
910
+ path: `${K0}`
911
+ ): (obj: S) => boolean;
912
+ export function pathSatisfies<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(
913
+ predicate: (x: S[K0][K1]) => boolean,
914
+ path: readonly [K0, K1]
915
+ ): (obj: S) => boolean;
916
+ export function pathSatisfies<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(
917
+ predicate: (x: S[K0][K1]) => boolean,
918
+ path: `${K0}.${K1}`
919
+ ): (obj: S) => boolean;
920
+ export function pathSatisfies<
921
+ S,
922
+ K0 extends string & keyof S,
923
+ K1 extends string & keyof S[K0],
924
+ K2 extends string & keyof S[K0][K1]
925
+ >(
926
+ predicate: (x: S[K0][K1][K2]) => boolean,
927
+ path: readonly [K0, K1, K2]
928
+ ): (obj: S) => boolean;
929
+ export function pathSatisfies<
930
+ S,
931
+ K0 extends string & keyof S,
932
+ K1 extends string & keyof S[K0],
933
+ K2 extends string & keyof S[K0][K1]
934
+ >(
935
+ predicate: (x: S[K0][K1][K2]) => boolean,
936
+ path: `${K0}.${K1}.${K2}`
937
+ ): (obj: S) => boolean;
938
+ export function pathSatisfies<
939
+ S,
940
+ K0 extends string & keyof S,
941
+ K1 extends string & keyof S[K0],
942
+ K2 extends string & keyof S[K0][K1],
943
+ K3 extends string & keyof S[K0][K1][K2]
944
+ >(
945
+ predicate: (x: S[K0][K1][K2][K3]) => boolean,
946
+ path: readonly [K0, K1, K2, K3]
947
+ ): (obj: S) => boolean;
948
+ export function pathSatisfies<
949
+ S,
950
+ K0 extends string & keyof S,
951
+ K1 extends string & keyof S[K0],
952
+ K2 extends string & keyof S[K0][K1],
953
+ K3 extends string & keyof S[K0][K1][K2]
954
+ >(
955
+ predicate: (x: S[K0][K1][K2][K3]) => boolean,
956
+ path: `${K0}.${K1}.${K2}.${K3}`
957
+ ): (obj: S) => boolean;
958
+ export function pathSatisfies<
959
+ S,
960
+ K0 extends string & keyof S,
961
+ K1 extends string & keyof S[K0],
962
+ K2 extends string & keyof S[K0][K1],
963
+ K3 extends string & keyof S[K0][K1][K2],
964
+ K4 extends string & keyof S[K0][K1][K2][K3]
965
+ >(
966
+ predicate: (x: S[K0][K1][K2][K3][K4]) => boolean,
967
+ path: readonly [K0, K1, K2, K3, K4]
968
+ ): (obj: S) => boolean;
969
+ export function pathSatisfies<
970
+ S,
971
+ K0 extends string & keyof S,
972
+ K1 extends string & keyof S[K0],
973
+ K2 extends string & keyof S[K0][K1],
974
+ K3 extends string & keyof S[K0][K1][K2],
975
+ K4 extends string & keyof S[K0][K1][K2][K3]
976
+ >(
977
+ predicate: (x: S[K0][K1][K2][K3][K4]) => boolean,
978
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}`
979
+ ): (obj: S) => boolean;
980
+ export function pathSatisfies<
981
+ S,
982
+ K0 extends string & keyof S,
983
+ K1 extends string & keyof S[K0],
984
+ K2 extends string & keyof S[K0][K1],
985
+ K3 extends string & keyof S[K0][K1][K2],
986
+ K4 extends string & keyof S[K0][K1][K2][K3],
987
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
988
+ >(
989
+ predicate: (x: S[K0][K1][K2][K3][K4][K5]) => boolean,
990
+ path: readonly [K0, K1, K2, K3, K4, K5]
991
+ ): (obj: S) => boolean;
992
+ export function pathSatisfies<
993
+ S,
994
+ K0 extends string & keyof S,
995
+ K1 extends string & keyof S[K0],
996
+ K2 extends string & keyof S[K0][K1],
997
+ K3 extends string & keyof S[K0][K1][K2],
998
+ K4 extends string & keyof S[K0][K1][K2][K3],
999
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
1000
+ >(
1001
+ predicate: (x: S[K0][K1][K2][K3][K4][K5]) => boolean,
1002
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}`
1003
+ ): (obj: S) => boolean;
1004
+ export function pathSatisfies<
1005
+ S,
1006
+ K0 extends string & keyof S,
1007
+ K1 extends string & keyof S[K0],
1008
+ K2 extends string & keyof S[K0][K1],
1009
+ K3 extends string & keyof S[K0][K1][K2],
1010
+ K4 extends string & keyof S[K0][K1][K2][K3],
1011
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1012
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
1013
+ >(
1014
+ predicate: (x: S[K0][K1][K2][K3][K4][K5][K6]) => boolean,
1015
+ path: readonly [K0, K1, K2, K3, K4, K5, K6]
1016
+ ): (obj: S) => boolean;
1017
+ export function pathSatisfies<
1018
+ S,
1019
+ K0 extends string & keyof S,
1020
+ K1 extends string & keyof S[K0],
1021
+ K2 extends string & keyof S[K0][K1],
1022
+ K3 extends string & keyof S[K0][K1][K2],
1023
+ K4 extends string & keyof S[K0][K1][K2][K3],
1024
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1025
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
1026
+ >(
1027
+ predicate: (x: S[K0][K1][K2][K3][K4][K5][K6]) => boolean,
1028
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}`
1029
+ ): (obj: S) => boolean;
1030
+ export function pathSatisfies<
1031
+ S,
1032
+ K0 extends string & keyof S,
1033
+ K1 extends string & keyof S[K0],
1034
+ K2 extends string & keyof S[K0][K1],
1035
+ K3 extends string & keyof S[K0][K1][K2],
1036
+ K4 extends string & keyof S[K0][K1][K2][K3],
1037
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1038
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1039
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
1040
+ >(
1041
+ predicate: (x: S[K0][K1][K2][K3][K4][K5][K6][K7]) => boolean,
1042
+ path: readonly [K0, K1, K2, K3, K4, K5, K6, K7]
1043
+ ): (obj: S) => boolean;
1044
+ export function pathSatisfies<
1045
+ S,
1046
+ K0 extends string & keyof S,
1047
+ K1 extends string & keyof S[K0],
1048
+ K2 extends string & keyof S[K0][K1],
1049
+ K3 extends string & keyof S[K0][K1][K2],
1050
+ K4 extends string & keyof S[K0][K1][K2][K3],
1051
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1052
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1053
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
1054
+ >(
1055
+ predicate: (x: S[K0][K1][K2][K3][K4][K5][K6][K7]) => boolean,
1056
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}`
1057
+ ): (obj: S) => boolean;
1058
+ export function pathSatisfies<
1059
+ S,
1060
+ K0 extends string & keyof S,
1061
+ K1 extends string & keyof S[K0],
1062
+ K2 extends string & keyof S[K0][K1],
1063
+ K3 extends string & keyof S[K0][K1][K2],
1064
+ K4 extends string & keyof S[K0][K1][K2][K3],
1065
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1066
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1067
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
1068
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
1069
+ >(
1070
+ predicate: (x: S[K0][K1][K2][K3][K4][K5][K6][K7][K8]) => boolean,
1071
+ path: readonly [K0, K1, K2, K3, K4, K5, K6, K7, K8]
1072
+ ): (obj: S) => boolean;
1073
+ export function pathSatisfies<
1074
+ S,
1075
+ K0 extends string & keyof S,
1076
+ K1 extends string & keyof S[K0],
1077
+ K2 extends string & keyof S[K0][K1],
1078
+ K3 extends string & keyof S[K0][K1][K2],
1079
+ K4 extends string & keyof S[K0][K1][K2][K3],
1080
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1081
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1082
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
1083
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
1084
+ >(
1085
+ predicate: (x: S[K0][K1][K2][K3][K4][K5][K6][K7][K8]) => boolean,
1086
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}.${K8}`
1087
+ ): (obj: S) => boolean;
1088
+
1089
+ export function permutations<T>(list: readonly T[]): readonly T[][];
869
1090
 
870
1091
  /**
871
1092
  * It returns a partial copy of an `input` containing only `propsToPick` properties.
@@ -1418,6 +1639,9 @@ export function propEq<T>(val: T): {
1418
1639
  export function propEq<T, K extends PropertyKey>(val: T, name: K): (obj: Record<K, T>) => boolean;
1419
1640
  export function propEq<K extends keyof U, U>(val: U[K], name: K, obj: U): boolean;
1420
1641
 
1642
+ /**
1643
+ * It returns either `defaultValue` or the value of `property` in `obj`.
1644
+ */
1421
1645
  export function propOr<T, P extends string>(defaultValue: T, property: P): (obj: Partial<Record<P, T>>) => T;
1422
1646
 
1423
1647
  /**
@@ -1427,6 +1651,7 @@ export function propSatisfies<T>(predicate: (x: T) => boolean, property: string)
1427
1651
 
1428
1652
  /**
1429
1653
  * It returns list of numbers between `startInclusive` to `endExclusive` markers.
1654
+ * If `start` is greater than `end`, then the result will be in descending order.
1430
1655
  */
1431
1656
  export function range(startInclusive: number): (endExclusive: number) => readonly number[];
1432
1657
 
@@ -1466,21 +1691,364 @@ export function rejectObject<T extends object>(
1466
1691
  export function replace(strOrRegex: RegExp | string, replacer: RegExp | string): (str: string) => string;
1467
1692
 
1468
1693
  /**
1469
- * It replaces `index` in array `list` with the result of `replaceFn(list[i])`.
1694
+ * It returns a randomized copy of array.
1470
1695
  */
1471
- export function replaceItemAtIndex<T>(index: number, replaceFn: (x: T) => T): (list: readonly T[]) => readonly T[];
1696
+ export function shuffle<T>(list: readonly T[]): readonly T[];
1472
1697
 
1473
1698
  /**
1474
1699
  * It returns copy of `list` sorted by `sortFn` function, where `sortFn` needs to return only `-1`, `0` or `1`.
1475
1700
  */
1476
- export function sort<T>(sortFn: (a: T, b: T) => number, list: readonly T[]): readonly T[];
1477
1701
  export function sort<T>(sortFn: (a: T, b: T) => number): (list: readonly T[]) => readonly T[];
1478
1702
 
1479
1703
  /**
1480
1704
  * It returns copy of `list` sorted by `sortFn` function, where `sortFn` function returns a value to compare, i.e. it doesn't need to return only `-1`, `0` or `1`.
1481
1705
  */
1482
- export function sortBy<T>(sortFn: (a: T) => Ord): (list: readonly T[]) => readonly T[];
1483
- export function sortBy(sortFn: (a: any) => Ord): <T>(list: readonly T[]) => readonly T[];
1706
+ export function sortBy<T>(sortFn: (x: T) => Ord): (list: readonly T[]) => readonly T[];
1707
+
1708
+ export function sortByDescending<T>(sortFn: (a: T, b: T) => number): (list: readonly T[]) => readonly T[];
1709
+
1710
+ /**
1711
+ * It sorts `list` by the value of `path` property.
1712
+ */
1713
+ export function sortByPath<S, K0 extends string & keyof S>(
1714
+ path: readonly [K0]
1715
+ ): (list: readonly S[]) => readonly S[];
1716
+ export function sortByPath<S, K0 extends string & keyof S>(
1717
+ path: `${K0}`
1718
+ ): (list: readonly S[]) => readonly S[];
1719
+ export function sortByPath<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(
1720
+ path: readonly [K0, K1]
1721
+ ): (list: readonly S[]) => readonly S[];
1722
+ export function sortByPath<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(
1723
+ path: `${K0}.${K1}`
1724
+ ): (list: readonly S[]) => readonly S[];
1725
+ export function sortByPath<
1726
+ S,
1727
+ K0 extends string & keyof S,
1728
+ K1 extends string & keyof S[K0],
1729
+ K2 extends string & keyof S[K0][K1]
1730
+ >(
1731
+ path: readonly [K0, K1, K2]
1732
+ ): (list: readonly S[]) => readonly S[];
1733
+ export function sortByPath<
1734
+ S,
1735
+ K0 extends string & keyof S,
1736
+ K1 extends string & keyof S[K0],
1737
+ K2 extends string & keyof S[K0][K1]
1738
+ >(
1739
+ path: `${K0}.${K1}.${K2}`
1740
+ ): (list: readonly S[]) => readonly S[];
1741
+ export function sortByPath<
1742
+ S,
1743
+ K0 extends string & keyof S,
1744
+ K1 extends string & keyof S[K0],
1745
+ K2 extends string & keyof S[K0][K1],
1746
+ K3 extends string & keyof S[K0][K1][K2]
1747
+ >(
1748
+ path: readonly [K0, K1, K2, K3]
1749
+ ): (list: readonly S[]) => readonly S[];
1750
+ export function sortByPath<
1751
+ S,
1752
+ K0 extends string & keyof S,
1753
+ K1 extends string & keyof S[K0],
1754
+ K2 extends string & keyof S[K0][K1],
1755
+ K3 extends string & keyof S[K0][K1][K2]
1756
+ >(
1757
+ path: `${K0}.${K1}.${K2}.${K3}`
1758
+ ): (list: readonly S[]) => readonly S[];
1759
+ export function sortByPath<
1760
+ S,
1761
+ K0 extends string & keyof S,
1762
+ K1 extends string & keyof S[K0],
1763
+ K2 extends string & keyof S[K0][K1],
1764
+ K3 extends string & keyof S[K0][K1][K2],
1765
+ K4 extends string & keyof S[K0][K1][K2][K3]
1766
+ >(
1767
+ path: readonly [K0, K1, K2, K3, K4]
1768
+ ): (list: readonly S[]) => readonly S[];
1769
+ export function sortByPath<
1770
+ S,
1771
+ K0 extends string & keyof S,
1772
+ K1 extends string & keyof S[K0],
1773
+ K2 extends string & keyof S[K0][K1],
1774
+ K3 extends string & keyof S[K0][K1][K2],
1775
+ K4 extends string & keyof S[K0][K1][K2][K3]
1776
+ >(
1777
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}`
1778
+ ): (list: readonly S[]) => readonly S[];
1779
+ export function sortByPath<
1780
+ S,
1781
+ K0 extends string & keyof S,
1782
+ K1 extends string & keyof S[K0],
1783
+ K2 extends string & keyof S[K0][K1],
1784
+ K3 extends string & keyof S[K0][K1][K2],
1785
+ K4 extends string & keyof S[K0][K1][K2][K3],
1786
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
1787
+ >(
1788
+ path: readonly [K0, K1, K2, K3, K4, K5]
1789
+ ): (list: readonly S[]) => readonly S[];
1790
+ export function sortByPath<
1791
+ S,
1792
+ K0 extends string & keyof S,
1793
+ K1 extends string & keyof S[K0],
1794
+ K2 extends string & keyof S[K0][K1],
1795
+ K3 extends string & keyof S[K0][K1][K2],
1796
+ K4 extends string & keyof S[K0][K1][K2][K3],
1797
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
1798
+ >(
1799
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}`
1800
+ ): (list: readonly S[]) => readonly S[];
1801
+ export function sortByPath<
1802
+ S,
1803
+ K0 extends string & keyof S,
1804
+ K1 extends string & keyof S[K0],
1805
+ K2 extends string & keyof S[K0][K1],
1806
+ K3 extends string & keyof S[K0][K1][K2],
1807
+ K4 extends string & keyof S[K0][K1][K2][K3],
1808
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1809
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
1810
+ >(
1811
+ path: readonly [K0, K1, K2, K3, K4, K5, K6]
1812
+ ): (list: readonly S[]) => readonly S[];
1813
+ export function sortByPath<
1814
+ S,
1815
+ K0 extends string & keyof S,
1816
+ K1 extends string & keyof S[K0],
1817
+ K2 extends string & keyof S[K0][K1],
1818
+ K3 extends string & keyof S[K0][K1][K2],
1819
+ K4 extends string & keyof S[K0][K1][K2][K3],
1820
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1821
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
1822
+ >(
1823
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}`
1824
+ ): (list: readonly S[]) => readonly S[];
1825
+ export function sortByPath<
1826
+ S,
1827
+ K0 extends string & keyof S,
1828
+ K1 extends string & keyof S[K0],
1829
+ K2 extends string & keyof S[K0][K1],
1830
+ K3 extends string & keyof S[K0][K1][K2],
1831
+ K4 extends string & keyof S[K0][K1][K2][K3],
1832
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1833
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1834
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
1835
+ >(
1836
+ path: readonly [K0, K1, K2, K3, K4, K5, K6, K7]
1837
+ ): (list: readonly S[]) => readonly S[];
1838
+ export function sortByPath<
1839
+ S,
1840
+ K0 extends string & keyof S,
1841
+ K1 extends string & keyof S[K0],
1842
+ K2 extends string & keyof S[K0][K1],
1843
+ K3 extends string & keyof S[K0][K1][K2],
1844
+ K4 extends string & keyof S[K0][K1][K2][K3],
1845
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1846
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1847
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
1848
+ >(
1849
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}`
1850
+ ): (list: readonly S[]) => readonly S[];
1851
+ export function sortByPath<
1852
+ S,
1853
+ K0 extends string & keyof S,
1854
+ K1 extends string & keyof S[K0],
1855
+ K2 extends string & keyof S[K0][K1],
1856
+ K3 extends string & keyof S[K0][K1][K2],
1857
+ K4 extends string & keyof S[K0][K1][K2][K3],
1858
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1859
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1860
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
1861
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
1862
+ >(
1863
+ path: readonly [K0, K1, K2, K3, K4, K5, K6, K7, K8]
1864
+ ): (list: readonly S[]) => readonly S[];
1865
+ export function sortByPath<
1866
+ S,
1867
+ K0 extends string & keyof S,
1868
+ K1 extends string & keyof S[K0],
1869
+ K2 extends string & keyof S[K0][K1],
1870
+ K3 extends string & keyof S[K0][K1][K2],
1871
+ K4 extends string & keyof S[K0][K1][K2][K3],
1872
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1873
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1874
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
1875
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
1876
+ >(
1877
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}.${K8}`
1878
+ ): (list: readonly S[]) => readonly S[];
1879
+
1880
+ export function sortByPathDescending<S, K0 extends string & keyof S>(
1881
+ path: readonly [K0]
1882
+ ): (list: readonly S[]) => readonly S[];
1883
+ export function sortByPathDescending<S, K0 extends string & keyof S>(
1884
+ path: `${K0}`
1885
+ ): (list: readonly S[]) => readonly S[];
1886
+ export function sortByPathDescending<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(
1887
+ path: readonly [K0, K1]
1888
+ ): (list: readonly S[]) => readonly S[];
1889
+ export function sortByPathDescending<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(
1890
+ path: `${K0}.${K1}`
1891
+ ): (list: readonly S[]) => readonly S[];
1892
+ export function sortByPathDescending<
1893
+ S,
1894
+ K0 extends string & keyof S,
1895
+ K1 extends string & keyof S[K0],
1896
+ K2 extends string & keyof S[K0][K1]
1897
+ >(
1898
+ path: readonly [K0, K1, K2]
1899
+ ): (list: readonly S[]) => readonly S[];
1900
+ export function sortByPathDescending<
1901
+ S,
1902
+ K0 extends string & keyof S,
1903
+ K1 extends string & keyof S[K0],
1904
+ K2 extends string & keyof S[K0][K1]
1905
+ >(
1906
+ path: `${K0}.${K1}.${K2}`
1907
+ ): (list: readonly S[]) => readonly S[];
1908
+ export function sortByPathDescending<
1909
+ S,
1910
+ K0 extends string & keyof S,
1911
+ K1 extends string & keyof S[K0],
1912
+ K2 extends string & keyof S[K0][K1],
1913
+ K3 extends string & keyof S[K0][K1][K2]
1914
+ >(
1915
+ path: readonly [K0, K1, K2, K3]
1916
+ ): (list: readonly S[]) => readonly S[];
1917
+ export function sortByPathDescending<
1918
+ S,
1919
+ K0 extends string & keyof S,
1920
+ K1 extends string & keyof S[K0],
1921
+ K2 extends string & keyof S[K0][K1],
1922
+ K3 extends string & keyof S[K0][K1][K2]
1923
+ >(
1924
+ path: `${K0}.${K1}.${K2}.${K3}`
1925
+ ): (list: readonly S[]) => readonly S[];
1926
+ export function sortByPathDescending<
1927
+ S,
1928
+ K0 extends string & keyof S,
1929
+ K1 extends string & keyof S[K0],
1930
+ K2 extends string & keyof S[K0][K1],
1931
+ K3 extends string & keyof S[K0][K1][K2],
1932
+ K4 extends string & keyof S[K0][K1][K2][K3]
1933
+ >(
1934
+ path: readonly [K0, K1, K2, K3, K4]
1935
+ ): (list: readonly S[]) => readonly S[];
1936
+ export function sortByPathDescending<
1937
+ S,
1938
+ K0 extends string & keyof S,
1939
+ K1 extends string & keyof S[K0],
1940
+ K2 extends string & keyof S[K0][K1],
1941
+ K3 extends string & keyof S[K0][K1][K2],
1942
+ K4 extends string & keyof S[K0][K1][K2][K3]
1943
+ >(
1944
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}`
1945
+ ): (list: readonly S[]) => readonly S[];
1946
+ export function sortByPathDescending<
1947
+ S,
1948
+ K0 extends string & keyof S,
1949
+ K1 extends string & keyof S[K0],
1950
+ K2 extends string & keyof S[K0][K1],
1951
+ K3 extends string & keyof S[K0][K1][K2],
1952
+ K4 extends string & keyof S[K0][K1][K2][K3],
1953
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
1954
+ >(
1955
+ path: readonly [K0, K1, K2, K3, K4, K5]
1956
+ ): (list: readonly S[]) => readonly S[];
1957
+ export function sortByPathDescending<
1958
+ S,
1959
+ K0 extends string & keyof S,
1960
+ K1 extends string & keyof S[K0],
1961
+ K2 extends string & keyof S[K0][K1],
1962
+ K3 extends string & keyof S[K0][K1][K2],
1963
+ K4 extends string & keyof S[K0][K1][K2][K3],
1964
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
1965
+ >(
1966
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}`
1967
+ ): (list: readonly S[]) => readonly S[];
1968
+ export function sortByPathDescending<
1969
+ S,
1970
+ K0 extends string & keyof S,
1971
+ K1 extends string & keyof S[K0],
1972
+ K2 extends string & keyof S[K0][K1],
1973
+ K3 extends string & keyof S[K0][K1][K2],
1974
+ K4 extends string & keyof S[K0][K1][K2][K3],
1975
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1976
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
1977
+ >(
1978
+ path: readonly [K0, K1, K2, K3, K4, K5, K6]
1979
+ ): (list: readonly S[]) => readonly S[];
1980
+ export function sortByPathDescending<
1981
+ S,
1982
+ K0 extends string & keyof S,
1983
+ K1 extends string & keyof S[K0],
1984
+ K2 extends string & keyof S[K0][K1],
1985
+ K3 extends string & keyof S[K0][K1][K2],
1986
+ K4 extends string & keyof S[K0][K1][K2][K3],
1987
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1988
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
1989
+ >(
1990
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}`
1991
+ ): (list: readonly S[]) => readonly S[];
1992
+ export function sortByPathDescending<
1993
+ S,
1994
+ K0 extends string & keyof S,
1995
+ K1 extends string & keyof S[K0],
1996
+ K2 extends string & keyof S[K0][K1],
1997
+ K3 extends string & keyof S[K0][K1][K2],
1998
+ K4 extends string & keyof S[K0][K1][K2][K3],
1999
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
2000
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
2001
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
2002
+ >(
2003
+ path: readonly [K0, K1, K2, K3, K4, K5, K6, K7]
2004
+ ): (list: readonly S[]) => readonly S[];
2005
+ export function sortByPathDescending<
2006
+ S,
2007
+ K0 extends string & keyof S,
2008
+ K1 extends string & keyof S[K0],
2009
+ K2 extends string & keyof S[K0][K1],
2010
+ K3 extends string & keyof S[K0][K1][K2],
2011
+ K4 extends string & keyof S[K0][K1][K2][K3],
2012
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
2013
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
2014
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
2015
+ >(
2016
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}`
2017
+ ): (list: readonly S[]) => readonly S[];
2018
+ export function sortByPathDescending<
2019
+ S,
2020
+ K0 extends string & keyof S,
2021
+ K1 extends string & keyof S[K0],
2022
+ K2 extends string & keyof S[K0][K1],
2023
+ K3 extends string & keyof S[K0][K1][K2],
2024
+ K4 extends string & keyof S[K0][K1][K2][K3],
2025
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
2026
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
2027
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
2028
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
2029
+ >(
2030
+ path: readonly [K0, K1, K2, K3, K4, K5, K6, K7, K8]
2031
+ ): (list: readonly S[]) => readonly S[];
2032
+ export function sortByPathDescending<
2033
+ S,
2034
+ K0 extends string & keyof S,
2035
+ K1 extends string & keyof S[K0],
2036
+ K2 extends string & keyof S[K0][K1],
2037
+ K3 extends string & keyof S[K0][K1][K2],
2038
+ K4 extends string & keyof S[K0][K1][K2][K3],
2039
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
2040
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
2041
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
2042
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
2043
+ >(
2044
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}.${K8}`
2045
+ ): (list: readonly S[]) => readonly S[];
2046
+
2047
+ /**
2048
+ * It returns a sorted version of `input` object.
2049
+ */
2050
+ export function sortObject<T, K extends string & keyof T>(predicate: (aProp: string, bProp: string, aValue: T[K], bValue: T[K]) => number): (obj: T) => T;
2051
+ export function sortObject<T>(predicate: (aProp: string, bProp: string) => number): (obj: T) => T;
1484
2052
 
1485
2053
  export function sortWith<T>(fns: ReadonlyArray<(a: T, b: T) => number>): (list: readonly T[]) => readonly T[];
1486
2054
 
@@ -1491,14 +2059,6 @@ export function split(separator: string | RegExp): (str: string) => readonly str
1491
2059
  */
1492
2060
  export function splitEvery<T>(sliceLength: number): (input: readonly T[]) => readonly ((readonly T[]))[];
1493
2061
 
1494
- /**
1495
- * Curried version of `x - y`
1496
- */
1497
- export function subtract(x: number, y: number): number;
1498
- export function subtract(x: number): (y: number) => number;
1499
-
1500
- export function sum(list: readonly number[]): number;
1501
-
1502
2062
  /**
1503
2063
  * It returns a merged list of `x` and `y` with all equal elements removed.
1504
2064
  *
@@ -1541,25 +2101,15 @@ export function takeWhile<T>(predicate: (x: T) => boolean): (input: readonly T[]
1541
2101
  *
1542
2102
  * One use case is debugging in the middle of `R.pipe` chain.
1543
2103
  */
1544
- export function tap<T>(fn: (x: T) => void, input: T): T;
1545
2104
  export function tap<T>(fn: (x: T) => void): (input: T) => T;
1546
2105
 
1547
2106
  /**
1548
2107
  * It determines whether `str` matches `regExpression`.
1549
2108
  */
1550
2109
  export function test(regExpression: RegExp): (str: string) => boolean;
1551
- export function test(regExpression: RegExp, str: string): boolean;
1552
-
1553
- /**
1554
- * It returns the result of applying function `fn` over members of range array.
1555
- *
1556
- * The range array includes numbers between `0` and `howMany`(exclusive).
1557
- */
1558
- export function times<T>(fn: (i: number) => T, howMany: number): readonly T[];
1559
- export function times<T>(fn: (i: number) => T): (howMany: number) => readonly T[];
1560
2110
 
1561
2111
  /**
1562
- * It returns function that runs `fn` in `try/catch` block. If there was an error, then `fallback` is used to return the result. Note that `fn` can be value or asynchronous/synchronous function(unlike `Ramda` where fallback can only be a synchronous function).
2112
+ * It returns function that runs `fn` in `try/catch` block. If there was an error, then `fallback` is used to return the result.
1563
2113
  */
1564
2114
  export function tryCatch<T, U>(
1565
2115
  fn: (input: T) => U,
@@ -1590,14 +2140,14 @@ export function uniq<T>(list: readonly T[]): readonly T[];
1590
2140
  *
1591
2141
  * `R.equals` is used to determine equality.
1592
2142
  */
1593
- export function uniqBy<T, U>(fn: (a: T) => U): (list: readonly T[]) => readonly T[];
2143
+ export function uniqBy<T, U>(fn: (x: T) => U): (list: readonly T[]) => readonly T[];
1594
2144
 
1595
2145
  /**
1596
2146
  * It returns a new array containing only one copy of each element in `list` according to `predicate` function.
1597
2147
  *
1598
2148
  * This predicate should return true, if two elements are equal.
1599
2149
  */
1600
- export function uniqWith<T, U>(predicate: (x: T, y: T) => boolean): (list: readonly T[]) => readonly T[];
2150
+ export function uniqWith<T>(predicate: (x: T, y: T) => boolean): (list: readonly T[]) => readonly T[];
1601
2151
 
1602
2152
  /**
1603
2153
  * The method returns function that will be called with argument `input`.
@@ -1612,7 +2162,7 @@ export function unless<T>(predicate: (x: T) => boolean, whenFalseFn: (x: T) => T
1612
2162
  /**
1613
2163
  * It takes an object and a property name. The method will return a list of objects, where each object is a shallow copy of the input object, but with the property array unwound.
1614
2164
  */
1615
- export function unwind<S extends string>(prop: S): <T>(obj: T) => Omit<T, S> & { readonly [K in S]: T[S][number] };
2165
+ export function unwind<S extends string>(prop: S): <T>(obj: T) => MergeTypes<Omit<T, S> & { readonly [K in S]: T[S][number] }>;
1616
2166
 
1617
2167
  /**
1618
2168
  * It returns a copy of `list` with updated element at `index` with `newValue`.
@@ -1623,8 +2173,9 @@ export function update<T>(index: number, newValue: T): (list: readonly T[]) => r
1623
2173
  * It pass `input` to `predicate` function and if the result is `true`, it will return the result of `whenTrueFn(input)`.
1624
2174
  * If the `predicate` returns `false`, then it will simply return `input`.
1625
2175
  */
1626
- export function when<T>(predicate: (x: T) => boolean, whenTrueFn: (a: T) => T): (input: T) => T;
1627
- export function when<T, U>(predicate: (x: T) => boolean, whenTrueFn: (a: T) => U): (input: T) => T | U;
2176
+ export function when<T, U extends T>(predicate: (x: T) => x is U, whenTrueFn: (x: U) => T): (input: T) => T;
2177
+ export function when<T>(predicate: (x: T) => boolean, whenTrueFn: (x: T) => T): (input: T) => T;
2178
+ export function when<T, U>(predicate: (x: T) => boolean, whenTrueFn: (x: T) => U): (input: T) => T | U;
1628
2179
 
1629
2180
  /**
1630
2181
  * It will return a new array containing tuples of equally positions items from both `x` and `y` lists.