rambda 10.0.0-alpha.0 → 10.0.0-beta.1
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/CHANGELOG.md +124 -16
- package/README.md +5526 -1730
- package/dist/{rambda.esm.js → rambda.cjs} +663 -355
- package/dist/rambda.js +545 -456
- package/dist/rambda.umd.js +563 -357
- package/immutable.d.ts +321 -343
- package/index.d.ts +321 -343
- package/package.json +20 -13
- package/rambda.js +16 -1
- package/src/addProp.js +3 -0
- package/src/append.js +5 -5
- package/src/ascend.js +16 -0
- package/src/compact.js +12 -0
- package/src/concat.js +1 -1
- package/src/count.js +7 -7
- package/src/countBy.js +12 -12
- package/src/createObjectFromKeys.js +10 -0
- package/src/descend.js +10 -0
- package/src/dropLast.js +1 -3
- package/src/eqProps.js +1 -2
- package/src/equals.js +2 -2
- package/src/evolve.js +2 -23
- package/src/filter.js +14 -14
- package/src/find.js +10 -10
- package/src/findIndex.js +9 -9
- package/src/findLast.js +8 -8
- package/src/findLastIndex.js +8 -8
- package/src/findNth.js +16 -0
- package/src/groupBy.js +14 -13
- package/src/includes.js +12 -13
- package/src/interpolate.js +29 -0
- package/src/intersection.js +1 -1
- package/src/intersperse.js +12 -12
- package/src/join.js +1 -1
- package/src/mapAsync.js +3 -3
- package/src/mapKeys.js +11 -0
- package/src/mapObjectAsync.js +9 -9
- package/src/mapParallelAsync.js +3 -0
- package/src/match.js +5 -5
- package/src/modifyProp.js +20 -0
- package/src/objectIncludes.js +12 -0
- package/src/partition.js +13 -37
- package/src/partitionObject.js +15 -0
- package/src/permutations.js +40 -0
- package/src/pipeAsync.js +7 -6
- package/src/pluck.js +9 -9
- package/src/prepend.js +1 -1
- package/src/propSatisfies.js +1 -3
- package/src/range.js +35 -12
- package/src/reject.js +1 -1
- package/src/rejectObject.js +13 -0
- package/src/shuffle.js +13 -0
- package/src/sort.js +1 -1
- package/src/sortBy.js +12 -10
- package/src/sortObject.js +15 -0
- package/src/sortWith.js +8 -8
- package/src/split.js +2 -2
- package/src/splitEvery.js +11 -11
- package/src/takeLastWhile.js +18 -18
- package/src/tap.js +4 -4
- package/src/test.js +1 -1
- package/src/uniqBy.js +4 -4
- package/src/uniqWith.js +10 -10
- package/src/modifyPath.js +0 -30
package/index.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> = [T, ...T[]];
|
|
8
|
-
export type ReadonlyNonEmptyArray<T> = readonly [T, ...T[]];
|
|
9
7
|
export type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly [];
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
9
|
export type Mapped<T extends IterableContainer, K> = {
|
|
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> = {[KeyType in keyof T]: T[KeyType]} & {};
|
|
19
|
-
export type
|
|
15
|
+
export type MergeTypesAlternative<T> = T extends infer O ? { [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
|
? [key: `${Key}`, value: Required<T>[Key]]
|
|
@@ -26,16 +22,13 @@ export type Entry<T> = MergeTypes<{ [P in keyof T]-?: EntryForKey<T, P> }[keyof
|
|
|
26
22
|
|
|
27
23
|
export type Ord = number | string | boolean | Date;
|
|
28
24
|
export type Ordering = -1 | 0 | 1;
|
|
29
|
-
type Path = Array<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
|
0: K;
|
|
36
28
|
1: V;
|
|
37
29
|
}
|
|
38
|
-
|
|
30
|
+
|
|
31
|
+
export type Functor<A> = { map: <B>(fn: (x: A) => B) => Functor<B>; [key: string]: any };
|
|
39
32
|
export type DeepModify<Keys extends readonly PropertyKey[], U, T> =
|
|
40
33
|
Keys extends [infer K, ...infer Rest]
|
|
41
34
|
? K extends keyof U
|
|
@@ -52,40 +45,6 @@ export type PickStringToPickPath<T> = T extends `${infer Head},${infer Tail}`
|
|
|
52
45
|
: T extends `${infer Head}` ? [Head]
|
|
53
46
|
: [];
|
|
54
47
|
|
|
55
|
-
|
|
56
|
-
export type Partial<T> = { [P in keyof T]?: T[P]};
|
|
57
|
-
|
|
58
|
-
type Evolvable<E extends Evolver> = {[P in keyof E]?: Evolved<E[P]>};
|
|
59
|
-
|
|
60
|
-
type Evolver<T extends Evolvable<any> = any> = { [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> = { [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 = {[emptyObjectSymbol]?: never};
|
|
91
50
|
type EnumerableStringKeyOf<T> =
|
|
@@ -105,12 +64,38 @@ type MappedValues<T extends object, Value> = MergeTypes<{
|
|
|
105
64
|
-readonly [P in keyof T as `${P extends number | string ? P : never}`]: Value;
|
|
106
65
|
}>;
|
|
107
66
|
|
|
108
|
-
|
|
67
|
+
type SimpleMerge<Destination, Source> = {
|
|
68
|
+
[Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
|
|
69
|
+
} & Source;
|
|
70
|
+
|
|
71
|
+
type OmitIndexSignature<ObjectType> = {
|
|
72
|
+
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
73
|
+
? never
|
|
74
|
+
: KeyType]: ObjectType[KeyType];
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
type PickIndexSignature<ObjectType> = {
|
|
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
|
+
|
|
109
91
|
|
|
110
92
|
/**
|
|
111
|
-
* It adds
|
|
93
|
+
* It adds new key-value pair to the object.
|
|
112
94
|
*/
|
|
113
|
-
export function
|
|
95
|
+
export function addProp<T extends object, P extends PropertyKey, V extends unknown>(
|
|
96
|
+
prop: P,
|
|
97
|
+
value: V
|
|
98
|
+
): (obj: T) => MergeTypes<T & Record<P, V>>;
|
|
114
99
|
|
|
115
100
|
/**
|
|
116
101
|
* It returns `true`, if all members of array `list` returns `true`, when applied as argument to `predicate` function.
|
|
@@ -169,11 +154,27 @@ export function anyPass<F extends (...args: any[]) => boolean>(predicates: reado
|
|
|
169
154
|
export function append<T>(el: T): (list: T[]) => T[];
|
|
170
155
|
export function append<T>(el: T): (list: readonly T[]) => T[];
|
|
171
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Helper function to be used with `R.sort` to sort list in ascending order.
|
|
159
|
+
*/
|
|
160
|
+
export function ascend<T>(fn: (obj: T) => Ord): (a: T, b: T)=> Ordering;
|
|
161
|
+
|
|
172
162
|
/**
|
|
173
163
|
* It returns `true` if all each property in `conditions` returns `true` when applied to corresponding property in `input` object.
|
|
174
164
|
*/
|
|
175
165
|
export function checkObjectWithSpec<T>(spec: T): <U>(testObj: U) => boolean;
|
|
176
166
|
|
|
167
|
+
/**
|
|
168
|
+
* It removes `null` and `undefined` members from list or object input.
|
|
169
|
+
*/
|
|
170
|
+
export function compact<T>(list: T[]): Array<StrictNonNullable<T>>;
|
|
171
|
+
export function compact<T extends object>(record: T): {
|
|
172
|
+
[K in keyof T as Exclude<T[K], null | undefined> extends never
|
|
173
|
+
? never
|
|
174
|
+
: K
|
|
175
|
+
]: Exclude<T[K], null | undefined>
|
|
176
|
+
};
|
|
177
|
+
|
|
177
178
|
/**
|
|
178
179
|
* It returns `inverted` version of `origin` function that accept `input` as argument.
|
|
179
180
|
*
|
|
@@ -195,35 +196,41 @@ export function count<T>(predicate: (x: T) => boolean): (list: T[]) => number;
|
|
|
195
196
|
/**
|
|
196
197
|
* It counts elements in a list after each instance of the input list is passed through `transformFn` function.
|
|
197
198
|
*/
|
|
198
|
-
export function countBy<T>(fn: (
|
|
199
|
+
export function countBy<T>(fn: (x: T) => string | number): (list: T[]) => { [index: string]: number };
|
|
199
200
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
export function
|
|
201
|
+
export function createObjectFromKeys<const K extends readonly PropertyKey[], V>(
|
|
202
|
+
fn: (key: K[number]) => V
|
|
203
|
+
): (keys: K) => { [P in K[number]]: V };
|
|
204
|
+
export function createObjectFromKeys<const K extends readonly PropertyKey[], V>(
|
|
205
|
+
fn: (key: K[number], index: number) => V
|
|
206
|
+
): (keys: K) => { [P in K[number]]: V };
|
|
204
207
|
|
|
205
208
|
/**
|
|
206
209
|
* It returns `defaultValue`, if all of `inputArguments` are `undefined`, `null` or `NaN`.
|
|
207
210
|
*
|
|
208
211
|
* Else, it returns the first truthy `inputArguments` instance(from left to right).
|
|
209
212
|
*/
|
|
210
|
-
export function defaultTo<T>(defaultValue: T
|
|
211
|
-
|
|
213
|
+
export function defaultTo<T>(defaultValue: T): (input: unknown) => T;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Helper function to be used with `R.sort` to sort list in descending order.
|
|
217
|
+
*/
|
|
218
|
+
export function descend<T>(fn: (obj: T) => Ord): (a: T, b: T)=> Ordering;
|
|
212
219
|
|
|
213
220
|
/**
|
|
214
|
-
* It returns `howMany` items dropped from beginning of list
|
|
221
|
+
* It returns `howMany` items dropped from beginning of list.
|
|
215
222
|
*/
|
|
216
223
|
export function drop<T>(howMany: number): (list: T[]) => T[];
|
|
217
224
|
|
|
218
225
|
/**
|
|
219
|
-
* It returns `howMany` items dropped from
|
|
226
|
+
* It returns `howMany` items dropped from the end of list.
|
|
220
227
|
*/
|
|
221
228
|
export function dropLast<T>(howMany: number): (list: T[]) => T[];
|
|
222
229
|
|
|
223
230
|
export function dropLastWhile<T>(predicate: (x: T, index: number) => boolean): (list: T[]) => T[];
|
|
224
231
|
export function dropLastWhile<T>(predicate: (x: T) => boolean): (list: T[]) => T[];
|
|
225
232
|
|
|
226
|
-
export function dropRepeatsBy<T, U>(fn: (
|
|
233
|
+
export function dropRepeatsBy<T, U>(fn: (x: T) => U): (list: T[]) => T[];
|
|
227
234
|
|
|
228
235
|
export function dropRepeatsWith<T>(predicate: (x: T, y: T) => boolean): (list: T[]) => T[];
|
|
229
236
|
|
|
@@ -235,7 +242,7 @@ export function eqBy<T>(fn: (x: T) => unknown, a: T): (b: T) => boolean;
|
|
|
235
242
|
/**
|
|
236
243
|
* It returns `true` if property `prop` in `obj1` is equal to property `prop` in `obj2` according to `R.equals`.
|
|
237
244
|
*/
|
|
238
|
-
export function eqProps<T>(prop:
|
|
245
|
+
export function eqProps<T, K extends keyof T>(prop: K, obj1: T): (obj2: T) => boolean;
|
|
239
246
|
|
|
240
247
|
/**
|
|
241
248
|
* It deeply compares `x` and `y` and returns `true` if they are equal.
|
|
@@ -245,8 +252,11 @@ export function equals<T>(x: T): (y: T) => boolean;
|
|
|
245
252
|
|
|
246
253
|
/**
|
|
247
254
|
* It takes object of functions as set of rules. These `rules` are applied to the `iterable` input to produce the result.
|
|
255
|
+
* It doesn't support nested rules, i.e rules are only one level deep.
|
|
248
256
|
*/
|
|
249
|
-
export function evolve<
|
|
257
|
+
export function evolve<T>(rules: {
|
|
258
|
+
[K in keyof T]?: (x: T[K]) => T[K]
|
|
259
|
+
}): (obj: T) => T;
|
|
250
260
|
|
|
251
261
|
/**
|
|
252
262
|
* Opposite of `R.includes`
|
|
@@ -264,10 +274,10 @@ export function filter<T, S extends T>(
|
|
|
264
274
|
): (list: T[]) => S[];
|
|
265
275
|
export function filter<T>(
|
|
266
276
|
predicate: BooleanConstructor,
|
|
267
|
-
): (list: readonly T[]) =>
|
|
277
|
+
): (list: readonly T[]) => StrictNonNullable<T>[];
|
|
268
278
|
export function filter<T>(
|
|
269
279
|
predicate: BooleanConstructor,
|
|
270
|
-
): (list: T[]) =>
|
|
280
|
+
): (list: T[]) => StrictNonNullable<T>[];
|
|
271
281
|
export function filter<T>(
|
|
272
282
|
predicate: (value: T) => boolean,
|
|
273
283
|
): (list: T[]) => T[];
|
|
@@ -311,6 +321,11 @@ export function findLast<T>(fn: (x: T) => boolean): (list: T[]) => T | undefined
|
|
|
311
321
|
*/
|
|
312
322
|
export function findLastIndex<T>(predicate: (x: T) => boolean): (list: T[]) => number;
|
|
313
323
|
|
|
324
|
+
/**
|
|
325
|
+
* It returns the `nth` element of `list` that satisfy the `predicate` function.
|
|
326
|
+
*/
|
|
327
|
+
export function findNth<T>(predicate: (x: T) => boolean, nth: number): (list: T[]) => T | undefined;
|
|
328
|
+
|
|
314
329
|
/**
|
|
315
330
|
* It maps `fn` over `list` and then flatten the result by one-level.
|
|
316
331
|
*/
|
|
@@ -318,13 +333,14 @@ export function flatMap<T, U extends unknown>(transformFn: (x: T extends any[] ?
|
|
|
318
333
|
|
|
319
334
|
/**
|
|
320
335
|
* It deeply flattens an array.
|
|
336
|
+
* You must pass expected output type as a type argument.
|
|
321
337
|
*/
|
|
322
338
|
export function flatten<T>(list: any[]): T[];
|
|
323
339
|
|
|
324
340
|
/**
|
|
325
341
|
* It splits `list` according to a provided `groupFn` function and returns an object.
|
|
326
342
|
*/
|
|
327
|
-
export function groupBy<T, K extends string = string>(fn: (
|
|
343
|
+
export function groupBy<T, K extends string = string>(fn: (x: T) => K): (list: T[]) => Partial<Record<K, T[]>>;
|
|
328
344
|
|
|
329
345
|
/**
|
|
330
346
|
* It returns the first element of list or string `input`. It returns `undefined` if array has length of 0.
|
|
@@ -338,18 +354,6 @@ export function head<T>(listOrString: T): T extends string ? string :
|
|
|
338
354
|
T extends unknown[] ? T[number] :
|
|
339
355
|
undefined;
|
|
340
356
|
|
|
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 any[], TOnTrueResult, TOnFalseResult>(fn: (...args: TArgs) => boolean, onTrue: (...args: TArgs) => TOnTrueResult, onFalse: (...args: TArgs) => TOnFalseResult): (...args: TArgs) => TOnTrueResult | TOnFalseResult;
|
|
352
|
-
|
|
353
357
|
/**
|
|
354
358
|
* If `input` is string, then this method work as native `String.includes`.
|
|
355
359
|
*
|
|
@@ -377,10 +381,20 @@ export function innerJoin<T1, T2>(
|
|
|
377
381
|
list1: T1[],
|
|
378
382
|
): (list2: T2[]) => T1[];
|
|
379
383
|
|
|
384
|
+
/**
|
|
385
|
+
* It generates a new string from `inputWithTags` by replacing all `{{x}}` occurrences with values provided by `templateArguments`.
|
|
386
|
+
*/
|
|
387
|
+
export function interpolate(inputWithTags: string): (templateArguments: object) => string;
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
// API_MARKER_END
|
|
391
|
+
// ============================================
|
|
392
|
+
|
|
393
|
+
export as namespace R
|
|
394
|
+
|
|
380
395
|
/**
|
|
381
396
|
* It loops through `listA` and `listB` and returns the intersection of the two according to `R.equals`.
|
|
382
397
|
*/
|
|
383
|
-
export function intersection<T>(listA: T[], listB: T[]): T[];
|
|
384
398
|
export function intersection<T>(listA: T[]): (listB: T[]) => T[];
|
|
385
399
|
|
|
386
400
|
/**
|
|
@@ -388,14 +402,9 @@ export function intersection<T>(listA: T[]): (listB: T[]) => T[];
|
|
|
388
402
|
*/
|
|
389
403
|
export function intersperse<T>(separator: T): (list: T[]) => T[];
|
|
390
404
|
|
|
391
|
-
export function isNotEmpty<T>(value: 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
405
|
/**
|
|
396
406
|
* It returns a string of all `list` instances joined with a `glue`.
|
|
397
407
|
*/
|
|
398
|
-
export function join<T>(glue: string, list: T[]): string;
|
|
399
408
|
export function join<T>(glue: string): (list: T[]) => string;
|
|
400
409
|
|
|
401
410
|
/**
|
|
@@ -417,7 +426,6 @@ export function last<T>(listOrString: T): T extends string ? string :
|
|
|
417
426
|
*
|
|
418
427
|
* If there is no such index, then `-1` is returned.
|
|
419
428
|
*/
|
|
420
|
-
export function lastIndexOf<T>(target: T, list: T[]): number;
|
|
421
429
|
export function lastIndexOf<T>(target: T): (list: T[]) => number;
|
|
422
430
|
|
|
423
431
|
/**
|
|
@@ -458,6 +466,11 @@ export function mapAsync<T extends IterableContainer, U>(
|
|
|
458
466
|
data: T
|
|
459
467
|
): Promise<Mapped<T, U>>;
|
|
460
468
|
|
|
469
|
+
/**
|
|
470
|
+
* It returns a copy of `obj` with keys transformed by `fn`.
|
|
471
|
+
*/
|
|
472
|
+
export function mapKeys<T>(fn: (prop: string, value: T) => string): (obj: Record<string, T>) => Record<string, T>;
|
|
473
|
+
|
|
461
474
|
export function mapObject<T extends object, Value>(
|
|
462
475
|
valueMapper: (
|
|
463
476
|
value: EnumerableStringKeyedValueOf<T>,
|
|
@@ -474,57 +487,38 @@ export function mapObjectAsync<T extends object, Value>(
|
|
|
474
487
|
) => Promise<Value>,
|
|
475
488
|
): (data: T) => Promise<MappedValues<T, Value>>;
|
|
476
489
|
|
|
477
|
-
// API_MARKER_END
|
|
478
|
-
// ============================================
|
|
479
|
-
|
|
480
|
-
export as namespace R
|
|
481
|
-
|
|
482
490
|
/**
|
|
483
|
-
*
|
|
491
|
+
* Wrapper around `Promise.all` for asynchronous mapping with `fn` over members of `list`.
|
|
484
492
|
*/
|
|
485
|
-
export function
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
export function
|
|
492
|
-
|
|
493
|
+
export function mapParallelAsync<T extends IterableContainer, U>(
|
|
494
|
+
fn: (value: T[number], index: number) => Promise<U>,
|
|
495
|
+
): (data: T) => Promise<Mapped<T, U>>;
|
|
496
|
+
export function mapParallelAsync<T extends IterableContainer, U>(
|
|
497
|
+
fn: (value: T[number]) => Promise<U>,
|
|
498
|
+
): (data: T) => Promise<Mapped<T, U>>;
|
|
499
|
+
export function mapParallelAsync<T extends IterableContainer, U>(
|
|
500
|
+
fn: (value: T[number], index: number) => Promise<U>,
|
|
501
|
+
data: T
|
|
502
|
+
): Promise<Mapped<T, U>>;
|
|
503
|
+
export function mapParallelAsync<T extends IterableContainer, U>(
|
|
504
|
+
fn: (value: T[number]) => Promise<U>,
|
|
505
|
+
data: T
|
|
506
|
+
): Promise<Mapped<T, U>>;
|
|
493
507
|
|
|
494
508
|
/**
|
|
495
|
-
*
|
|
509
|
+
* Curried version of `String.prototype.match` which returns empty array, when there is no match.
|
|
496
510
|
*/
|
|
497
|
-
export function
|
|
498
|
-
export function max<T extends Ord>(x: T): (y: T) => T;
|
|
511
|
+
export function match(regExpression: RegExp): (str: string) => string[];
|
|
499
512
|
|
|
500
513
|
/**
|
|
501
514
|
* It returns the greater value between `x` and `y` according to `compareFn` function.
|
|
502
515
|
*/
|
|
503
|
-
export function maxBy<T>(compareFn: (input: T) => Ord, x: T, y: T): T;
|
|
504
516
|
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
|
-
|
|
507
|
-
/**
|
|
508
|
-
* It returns the mean value of `list` input.
|
|
509
|
-
*/
|
|
510
|
-
export function mean(list: number[]): number;
|
|
511
517
|
|
|
512
518
|
/**
|
|
513
|
-
* It
|
|
519
|
+
* It creates a copy of `target` object with overwritten `newProps` properties.
|
|
514
520
|
*/
|
|
515
|
-
export function
|
|
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;
|
|
521
|
+
export function merge<Source>(source: Source): <T>(data: T) => Merge<T, Source>;
|
|
528
522
|
|
|
529
523
|
/**
|
|
530
524
|
* Helper to merge all calculated TypeScript definitions into one definition.
|
|
@@ -532,11 +526,6 @@ export function mergeRight<Output>(target: any): (newProps: any) => Output;
|
|
|
532
526
|
*/
|
|
533
527
|
export function mergeTypes<T>(x: T): MergeTypes<T>;
|
|
534
528
|
|
|
535
|
-
/**
|
|
536
|
-
* It returns the lesser value between `x` and `y`.
|
|
537
|
-
*/
|
|
538
|
-
export function min<T extends Ord>(x: T): (y: T) => T;
|
|
539
|
-
|
|
540
529
|
/**
|
|
541
530
|
* It returns the lesser value between `x` and `y` according to `compareFn` function.
|
|
542
531
|
*/
|
|
@@ -545,128 +534,10 @@ export function minBy<T>(compareFn: (input: T) => Ord, x: T): (y: T) => T;
|
|
|
545
534
|
/**
|
|
546
535
|
* It changes a property with the result of transformer function.
|
|
547
536
|
*/
|
|
548
|
-
export function
|
|
537
|
+
export function modifyProp<T, K extends keyof T>(
|
|
549
538
|
prop: K,
|
|
550
|
-
fn: (
|
|
551
|
-
):
|
|
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: [], fn: (value: U) => T): (obj: U) => T;
|
|
557
|
-
export function modifyPath<
|
|
558
|
-
K0 extends keyof U,
|
|
559
|
-
U,
|
|
560
|
-
T
|
|
561
|
-
>(path: [K0], fn: (value: U[K0]) => T): (obj: U) => DeepModify<[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<[K0], U, T>;
|
|
567
|
-
export function modifyPath<
|
|
568
|
-
K0 extends keyof U,
|
|
569
|
-
K1 extends keyof U[K0],
|
|
570
|
-
U,
|
|
571
|
-
T
|
|
572
|
-
>(path: [K0, K1], fn: (value: U[K0][K1]) => T): (obj: U) => DeepModify<[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<[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: [K0, K1, K2], fn: (value: U[K0][K1][K2]) => T): (obj: U) => DeepModify<[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<[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: [K0, K1, K2, K3], fn: (value: U[K0][K1][K2][K3]) => T): (obj: U) => DeepModify<[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<[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: [K0, K1, K2, K3, K4], fn: (value: U[K0][K1][K2][K3][K4]) => T): (obj: U) => DeepModify<[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<[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: [K0, K1, K2, K3, K4, K5], fn: (value: U[K0][K1][K2][K3][K4][K5]) => T): (obj: U) => DeepModify<[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<[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: [K0, K1, K2, K3, K4, K5, K6], fn: (value: U[K0][K1][K2][K3][K4][K5][K6]) => T): (obj: U) => DeepModify<[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<[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;
|
|
539
|
+
fn: (x: T[K]) => T[K],
|
|
540
|
+
): (target: T) => T;
|
|
670
541
|
|
|
671
542
|
/**
|
|
672
543
|
* It returns `true`, if all members of array `list` returns `false`, when applied as argument to `predicate` function.
|
|
@@ -683,7 +554,7 @@ export function objOf<T, K extends PropertyKey>(key: K): (value: T) => { [P in K
|
|
|
683
554
|
*
|
|
684
555
|
* `R.equals` is used to determine equality.
|
|
685
556
|
*/
|
|
686
|
-
export function objectIncludes<T>(specification: T):
|
|
557
|
+
export function objectIncludes<T>(specification: T): (obj: Partial<T>) => boolean;
|
|
687
558
|
|
|
688
559
|
/**
|
|
689
560
|
* It returns a partial copy of an `obj` without `propsToOmit` properties.
|
|
@@ -691,11 +562,17 @@ export function objectIncludes<T>(specification: T): <U>(obj: U) => boolean;
|
|
|
691
562
|
export function omit<
|
|
692
563
|
S extends string,
|
|
693
564
|
Keys extends PickStringToPickPath<S>,
|
|
694
|
-
>(propsToPick: S): <U extends Partial<Record<ElementOf<Keys>, any>>>(
|
|
695
|
-
|
|
565
|
+
>(propsToPick: S): <U extends Partial<Record<ElementOf<Keys>, any>>>(
|
|
566
|
+
obj: ElementOf<Keys> extends keyof U ? U : never
|
|
567
|
+
) => ElementOf<Keys> extends keyof U ? MergeTypes<Omit<U, ElementOf<Keys>>> : never;
|
|
568
|
+
export function omit<const Keys extends PropertyKey[]>(propsToPick: Keys): <
|
|
569
|
+
U extends Partial<Record<ElementOf<Keys>, any>>
|
|
570
|
+
>(
|
|
571
|
+
obj: ElementOf<Keys> extends keyof U ? U : never
|
|
572
|
+
) => ElementOf<Keys> extends keyof U ? MergeTypes<Omit<U, ElementOf<Keys>>> : never;
|
|
696
573
|
|
|
697
574
|
/**
|
|
698
|
-
* It will return array of two
|
|
575
|
+
* 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
576
|
*/
|
|
700
577
|
export function partition<T, S extends T>(
|
|
701
578
|
predicate: (value: T, index: number, data: ReadonlyArray<T>) => value is S,
|
|
@@ -704,27 +581,184 @@ export function partition<T>(
|
|
|
704
581
|
predicate: (value: T, index: number, data: ReadonlyArray<T>) => boolean,
|
|
705
582
|
): (data: ReadonlyArray<T>) => [Array<T>, Array<T>];
|
|
706
583
|
|
|
584
|
+
/**
|
|
585
|
+
* 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.
|
|
586
|
+
*/
|
|
587
|
+
export function partitionObject<T extends unknown, S extends T>(
|
|
588
|
+
predicate: (value: T, prop: string, obj: Record<string, T>) => value is S,
|
|
589
|
+
): (obj: Record<string, T>) => [Record<string, S>, Record<string, Exclude<T, S>>];
|
|
590
|
+
export function partitionObject<T extends unknown>(
|
|
591
|
+
predicate: (value: T, prop: string, obj: Record<string, T>) => boolean,
|
|
592
|
+
): (obj: Record<string, T>) => [Record<string, T>, Record<string, T>];
|
|
593
|
+
|
|
707
594
|
/**
|
|
708
595
|
* If `pathToSearch` is `'a.b'` then it will return `1` if `obj` is `{a:{b:1}}`.
|
|
709
596
|
*
|
|
710
597
|
* It will return `undefined`, if such path is not found.
|
|
711
598
|
*/
|
|
599
|
+
export function path<S, K0 extends string & keyof S>(path: `${K0}`): (obj: S) => S[K0];
|
|
600
|
+
export function path<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(path: `${K0}.${K1}`): (obj: S) => S[K0][K1];
|
|
601
|
+
export function path<
|
|
602
|
+
S,
|
|
603
|
+
K0 extends keyof S,
|
|
604
|
+
K1 extends keyof S[K0],
|
|
605
|
+
K2 extends keyof S[K0][K1]
|
|
606
|
+
>(path: [K0, K1, K2]): (obj: S) => S[K0][K1][K2];
|
|
607
|
+
export function path<
|
|
608
|
+
S,
|
|
609
|
+
K0 extends string & keyof S,
|
|
610
|
+
K1 extends string & keyof S[K0],
|
|
611
|
+
K2 extends string & keyof S[K0][K1]
|
|
612
|
+
>(path: `${K0}.${K1}.${K2}`): (obj: S) => S[K0][K1][K2];
|
|
613
|
+
export function path<
|
|
614
|
+
S,
|
|
615
|
+
K0 extends keyof S,
|
|
616
|
+
K1 extends keyof S[K0],
|
|
617
|
+
K2 extends keyof S[K0][K1],
|
|
618
|
+
K3 extends keyof S[K0][K1][K2]
|
|
619
|
+
>(path: [K0, K1, K2, K3]): (obj: S) => S[K0][K1][K2][K3];
|
|
620
|
+
export function path<
|
|
621
|
+
S,
|
|
622
|
+
K0 extends string & keyof S,
|
|
623
|
+
K1 extends string & keyof S[K0],
|
|
624
|
+
K2 extends string & keyof S[K0][K1],
|
|
625
|
+
K3 extends string & keyof S[K0][K1][K2]
|
|
626
|
+
>(path: `${K0}.${K1}.${K2}.${K3}`): (obj: S) => S[K0][K1][K2][K3];
|
|
627
|
+
export function path<
|
|
628
|
+
S,
|
|
629
|
+
K0 extends keyof S,
|
|
630
|
+
K1 extends keyof S[K0],
|
|
631
|
+
K2 extends keyof S[K0][K1],
|
|
632
|
+
K3 extends keyof S[K0][K1][K2],
|
|
633
|
+
K4 extends keyof S[K0][K1][K2][K3]
|
|
634
|
+
>(path: [K0, K1, K2, K3, K4]): (obj: S) => S[K0][K1][K2][K3][K4];
|
|
635
|
+
export function path<
|
|
636
|
+
S,
|
|
637
|
+
K0 extends string & keyof S,
|
|
638
|
+
K1 extends string & keyof S[K0],
|
|
639
|
+
K2 extends string & keyof S[K0][K1],
|
|
640
|
+
K3 extends string & keyof S[K0][K1][K2],
|
|
641
|
+
K4 extends string & keyof S[K0][K1][K2][K3]
|
|
642
|
+
>(path: `${K0}.${K1}.${K2}.${K3}.${K4}`): (obj: S) => S[K0][K1][K2][K3][K4];
|
|
643
|
+
export function path<
|
|
644
|
+
S,
|
|
645
|
+
K0 extends keyof S,
|
|
646
|
+
K1 extends keyof S[K0],
|
|
647
|
+
K2 extends keyof S[K0][K1],
|
|
648
|
+
K3 extends keyof S[K0][K1][K2],
|
|
649
|
+
K4 extends keyof S[K0][K1][K2][K3]
|
|
650
|
+
>(path: [K0, K1, K2, K3, K4], obj: S): S[K0][K1][K2][K3][K4];
|
|
651
|
+
export function path<
|
|
652
|
+
S,
|
|
653
|
+
K0 extends keyof S,
|
|
654
|
+
K1 extends keyof S[K0],
|
|
655
|
+
K2 extends keyof S[K0][K1],
|
|
656
|
+
K3 extends keyof S[K0][K1][K2],
|
|
657
|
+
K4 extends keyof S[K0][K1][K2][K3],
|
|
658
|
+
K5 extends keyof S[K0][K1][K2][K3][K4]
|
|
659
|
+
>(path: [K0, K1, K2, K3, K4, K5]): (obj: S) => S[K0][K1][K2][K3][K4][K5];
|
|
660
|
+
export function path<
|
|
661
|
+
S,
|
|
662
|
+
K0 extends string & keyof S,
|
|
663
|
+
K1 extends string & keyof S[K0],
|
|
664
|
+
K2 extends string & keyof S[K0][K1],
|
|
665
|
+
K3 extends string & keyof S[K0][K1][K2],
|
|
666
|
+
K4 extends string & keyof S[K0][K1][K2][K3],
|
|
667
|
+
K5 extends string & keyof S[K0][K1][K2][K3][K4]
|
|
668
|
+
>(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}`): (obj: S) => S[K0][K1][K2][K3][K4][K5];
|
|
669
|
+
export function path<
|
|
670
|
+
S,
|
|
671
|
+
K0 extends keyof S,
|
|
672
|
+
K1 extends keyof S[K0],
|
|
673
|
+
K2 extends keyof S[K0][K1],
|
|
674
|
+
K3 extends keyof S[K0][K1][K2],
|
|
675
|
+
K4 extends keyof S[K0][K1][K2][K3],
|
|
676
|
+
K5 extends keyof S[K0][K1][K2][K3][K4]
|
|
677
|
+
>(path: [K0, K1, K2, K3, K4, K5], obj: S): S[K0][K1][K2][K3][K4][K5];
|
|
678
|
+
export function path<
|
|
679
|
+
S,
|
|
680
|
+
K0 extends keyof S,
|
|
681
|
+
K1 extends keyof S[K0],
|
|
682
|
+
K2 extends keyof S[K0][K1],
|
|
683
|
+
K3 extends keyof S[K0][K1][K2],
|
|
684
|
+
K4 extends keyof S[K0][K1][K2][K3],
|
|
685
|
+
K5 extends keyof S[K0][K1][K2][K3][K4],
|
|
686
|
+
K6 extends keyof S[K0][K1][K2][K3][K4][K5]
|
|
687
|
+
>(path: [K0, K1, K2, K3, K4, K5, K6]): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6];
|
|
688
|
+
export function path<
|
|
689
|
+
S,
|
|
690
|
+
K0 extends string & keyof S,
|
|
691
|
+
K1 extends string & keyof S[K0],
|
|
692
|
+
K2 extends string & keyof S[K0][K1],
|
|
693
|
+
K3 extends string & keyof S[K0][K1][K2],
|
|
694
|
+
K4 extends string & keyof S[K0][K1][K2][K3],
|
|
695
|
+
K5 extends string & keyof S[K0][K1][K2][K3][K4],
|
|
696
|
+
K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
|
|
697
|
+
>(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}`): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6];
|
|
698
|
+
export function path<
|
|
699
|
+
S,
|
|
700
|
+
K0 extends keyof S,
|
|
701
|
+
K1 extends keyof S[K0],
|
|
702
|
+
K2 extends keyof S[K0][K1],
|
|
703
|
+
K3 extends keyof S[K0][K1][K2],
|
|
704
|
+
K4 extends keyof S[K0][K1][K2][K3],
|
|
705
|
+
K5 extends keyof S[K0][K1][K2][K3][K4],
|
|
706
|
+
K6 extends keyof S[K0][K1][K2][K3][K4][K5]
|
|
707
|
+
>(path: [K0, K1, K2, K3, K4, K5, K6], obj: S): S[K0][K1][K2][K3][K4][K5][K6];
|
|
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
|
+
K6 extends keyof S[K0][K1][K2][K3][K4][K5],
|
|
717
|
+
K7 extends keyof S[K0][K1][K2][K3][K4][K5][K6]
|
|
718
|
+
>(path: [K0, K1, K2, K3, K4, K5, K6, K7]): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7];
|
|
719
|
+
export function path<
|
|
720
|
+
S,
|
|
721
|
+
K0 extends string & keyof S,
|
|
722
|
+
K1 extends string & keyof S[K0],
|
|
723
|
+
K2 extends string & keyof S[K0][K1],
|
|
724
|
+
K3 extends string & keyof S[K0][K1][K2],
|
|
725
|
+
K4 extends string & keyof S[K0][K1][K2][K3],
|
|
726
|
+
K5 extends string & keyof S[K0][K1][K2][K3][K4],
|
|
727
|
+
K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
|
|
728
|
+
K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
|
|
729
|
+
>(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}`): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7];
|
|
730
|
+
export function path<
|
|
731
|
+
S,
|
|
732
|
+
K0 extends keyof S,
|
|
733
|
+
K1 extends keyof S[K0],
|
|
734
|
+
K2 extends keyof S[K0][K1],
|
|
735
|
+
K3 extends keyof S[K0][K1][K2],
|
|
736
|
+
K4 extends keyof S[K0][K1][K2][K3],
|
|
737
|
+
K5 extends keyof S[K0][K1][K2][K3][K4],
|
|
738
|
+
K6 extends keyof S[K0][K1][K2][K3][K4][K5],
|
|
739
|
+
K7 extends keyof S[K0][K1][K2][K3][K4][K5][K6],
|
|
740
|
+
K8 extends keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
|
|
741
|
+
>(path: [K0, K1, K2, K3, K4, K5, K6, K7, K8]): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7][K8];
|
|
742
|
+
export function path<
|
|
743
|
+
S,
|
|
744
|
+
K0 extends string & keyof S,
|
|
745
|
+
K1 extends string & keyof S[K0],
|
|
746
|
+
K2 extends string & keyof S[K0][K1],
|
|
747
|
+
K3 extends string & keyof S[K0][K1][K2],
|
|
748
|
+
K4 extends string & keyof S[K0][K1][K2][K3],
|
|
749
|
+
K5 extends string & keyof S[K0][K1][K2][K3][K4],
|
|
750
|
+
K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
|
|
751
|
+
K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
|
|
752
|
+
K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
|
|
753
|
+
>(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}.${K8}`): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7][K8];
|
|
712
754
|
export function path<S, K0 extends keyof S>(path: [K0]): (obj: S) => S[K0];
|
|
713
|
-
export function path<S, K0 extends keyof S>(path: `${K0}`): (obj: S) => S[K0];
|
|
714
755
|
export function path<S, K0 extends keyof S, K1 extends keyof S[K0]>(path: [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
756
|
export function path<
|
|
717
757
|
S,
|
|
718
758
|
K0 extends keyof S,
|
|
719
759
|
K1 extends keyof S[K0],
|
|
720
760
|
K2 extends keyof S[K0][K1]
|
|
721
761
|
>(path: [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
762
|
export function path<
|
|
729
763
|
S,
|
|
730
764
|
K0 extends keyof S,
|
|
@@ -732,13 +766,6 @@ export function path<
|
|
|
732
766
|
K2 extends keyof S[K0][K1],
|
|
733
767
|
K3 extends keyof S[K0][K1][K2]
|
|
734
768
|
>(path: [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
769
|
export function path<
|
|
743
770
|
S,
|
|
744
771
|
K0 extends keyof S,
|
|
@@ -747,14 +774,6 @@ export function path<
|
|
|
747
774
|
K3 extends keyof S[K0][K1][K2],
|
|
748
775
|
K4 extends keyof S[K0][K1][K2][K3]
|
|
749
776
|
>(path: [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
777
|
export function path<
|
|
759
778
|
S,
|
|
760
779
|
K0 extends keyof S,
|
|
@@ -772,15 +791,6 @@ export function path<
|
|
|
772
791
|
K4 extends keyof S[K0][K1][K2][K3],
|
|
773
792
|
K5 extends keyof S[K0][K1][K2][K3][K4]
|
|
774
793
|
>(path: [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
794
|
export function path<
|
|
785
795
|
S,
|
|
786
796
|
K0 extends keyof S,
|
|
@@ -800,16 +810,6 @@ export function path<
|
|
|
800
810
|
K5 extends keyof S[K0][K1][K2][K3][K4],
|
|
801
811
|
K6 extends keyof S[K0][K1][K2][K3][K4][K5]
|
|
802
812
|
>(path: [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
813
|
export function path<
|
|
814
814
|
S,
|
|
815
815
|
K0 extends keyof S,
|
|
@@ -831,17 +831,6 @@ export function path<
|
|
|
831
831
|
K6 extends keyof S[K0][K1][K2][K3][K4][K5],
|
|
832
832
|
K7 extends keyof S[K0][K1][K2][K3][K4][K5][K6]
|
|
833
833
|
>(path: [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
834
|
export function path<
|
|
846
835
|
S,
|
|
847
836
|
K0 extends keyof S,
|
|
@@ -854,18 +843,8 @@ export function path<
|
|
|
854
843
|
K7 extends keyof S[K0][K1][K2][K3][K4][K5][K6],
|
|
855
844
|
K8 extends keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
|
|
856
845
|
>(path: [K0, K1, K2, K3, K4, K5, K6, K7, K8]): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7][K8];
|
|
857
|
-
|
|
858
|
-
|
|
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];
|
|
846
|
+
|
|
847
|
+
export function permutations<T>(list: T[]): T[][];
|
|
869
848
|
|
|
870
849
|
/**
|
|
871
850
|
* It returns a partial copy of an `input` containing only `propsToPick` properties.
|
|
@@ -1418,6 +1397,9 @@ export function propEq<T>(val: T): {
|
|
|
1418
1397
|
export function propEq<T, K extends PropertyKey>(val: T, name: K): (obj: Record<K, T>) => boolean;
|
|
1419
1398
|
export function propEq<K extends keyof U, U>(val: U[K], name: K, obj: U): boolean;
|
|
1420
1399
|
|
|
1400
|
+
/**
|
|
1401
|
+
* It returns either `defaultValue` or the value of `property` in `obj`.
|
|
1402
|
+
*/
|
|
1421
1403
|
export function propOr<T, P extends string>(defaultValue: T, property: P): (obj: Partial<Record<P, T>>) => T;
|
|
1422
1404
|
|
|
1423
1405
|
/**
|
|
@@ -1426,10 +1408,15 @@ export function propOr<T, P extends string>(defaultValue: T, property: P): (obj:
|
|
|
1426
1408
|
export function propSatisfies<T>(predicate: (x: T) => boolean, property: string): (obj: Record<PropertyKey, T>) => boolean;
|
|
1427
1409
|
|
|
1428
1410
|
/**
|
|
1429
|
-
* It returns list of numbers between `startInclusive` to `
|
|
1411
|
+
* It returns list of numbers between `startInclusive` to `endInclusive` markers.
|
|
1430
1412
|
*/
|
|
1431
1413
|
export function range(startInclusive: number): (endExclusive: number) => number[];
|
|
1432
1414
|
|
|
1415
|
+
/**
|
|
1416
|
+
* Same as `R.range` but in descending order.
|
|
1417
|
+
*/
|
|
1418
|
+
export function rangeDescending(startInclusive: number): (endExclusive: number) => number[];
|
|
1419
|
+
|
|
1433
1420
|
export function reduce<T, TResult>(reducer: (prev: TResult, current: T, i: number) => TResult, initialValue: TResult): (list: T[]) => TResult;
|
|
1434
1421
|
|
|
1435
1422
|
/**
|
|
@@ -1470,17 +1457,26 @@ export function replace(strOrRegex: RegExp | string, replacer: RegExp | string):
|
|
|
1470
1457
|
*/
|
|
1471
1458
|
export function replaceItemAtIndex<T>(index: number, replaceFn: (x: T) => T): (list: T[]) => T[];
|
|
1472
1459
|
|
|
1460
|
+
/**
|
|
1461
|
+
* It returns a randomized copy of array.
|
|
1462
|
+
*/
|
|
1463
|
+
export function shuffle<T>(list: T[]): T[];
|
|
1464
|
+
|
|
1473
1465
|
/**
|
|
1474
1466
|
* It returns copy of `list` sorted by `sortFn` function, where `sortFn` needs to return only `-1`, `0` or `1`.
|
|
1475
1467
|
*/
|
|
1476
|
-
export function sort<T>(sortFn: (a: T, b: T) => number, list: T[]): T[];
|
|
1477
1468
|
export function sort<T>(sortFn: (a: T, b: T) => number): (list: T[]) => T[];
|
|
1478
1469
|
|
|
1479
1470
|
/**
|
|
1480
1471
|
* 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
1472
|
*/
|
|
1482
|
-
export function sortBy<T>(sortFn: (
|
|
1483
|
-
|
|
1473
|
+
export function sortBy<T>(sortFn: (x: T) => Ord): (list: T[]) => T[];
|
|
1474
|
+
|
|
1475
|
+
/**
|
|
1476
|
+
* It returns a sorted version of `input` object.
|
|
1477
|
+
*/
|
|
1478
|
+
export function sortObject<T, K extends string & keyof T>(predicate: (aProp: string, bProp: string, aValue: T[K], bValue: T[K]) => number): (obj: T) => T;
|
|
1479
|
+
export function sortObject<T>(predicate: (aProp: string, bProp: string) => number): (obj: T) => T;
|
|
1484
1480
|
|
|
1485
1481
|
export function sortWith<T>(fns: Array<(a: T, b: T) => number>): (list: T[]) => T[];
|
|
1486
1482
|
|
|
@@ -1491,14 +1487,6 @@ export function split(separator: string | RegExp): (str: string) => string[];
|
|
|
1491
1487
|
*/
|
|
1492
1488
|
export function splitEvery<T>(sliceLength: number): (input: T[]) => (T[])[];
|
|
1493
1489
|
|
|
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: number[]): number;
|
|
1501
|
-
|
|
1502
1490
|
/**
|
|
1503
1491
|
* It returns a merged list of `x` and `y` with all equal elements removed.
|
|
1504
1492
|
*
|
|
@@ -1541,25 +1529,15 @@ export function takeWhile<T>(predicate: (x: T) => boolean): (input: T[]) => T[];
|
|
|
1541
1529
|
*
|
|
1542
1530
|
* One use case is debugging in the middle of `R.pipe` chain.
|
|
1543
1531
|
*/
|
|
1544
|
-
export function tap<T>(fn: (x: T) => void, input: T): T;
|
|
1545
1532
|
export function tap<T>(fn: (x: T) => void): (input: T) => T;
|
|
1546
1533
|
|
|
1547
1534
|
/**
|
|
1548
1535
|
* It determines whether `str` matches `regExpression`.
|
|
1549
1536
|
*/
|
|
1550
1537
|
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): T[];
|
|
1559
|
-
export function times<T>(fn: (i: number) => T): (howMany: number) => T[];
|
|
1560
1538
|
|
|
1561
1539
|
/**
|
|
1562
|
-
* It returns function that runs `fn` in `try/catch` block. If there was an error, then `fallback` is used to return the result.
|
|
1540
|
+
* It returns function that runs `fn` in `try/catch` block. If there was an error, then `fallback` is used to return the result.
|
|
1563
1541
|
*/
|
|
1564
1542
|
export function tryCatch<T, U>(
|
|
1565
1543
|
fn: (input: T) => U,
|
|
@@ -1590,14 +1568,14 @@ export function uniq<T>(list: T[]): T[];
|
|
|
1590
1568
|
*
|
|
1591
1569
|
* `R.equals` is used to determine equality.
|
|
1592
1570
|
*/
|
|
1593
|
-
export function uniqBy<T, U>(fn: (
|
|
1571
|
+
export function uniqBy<T, U>(fn: (x: T) => U): (list: T[]) => T[];
|
|
1594
1572
|
|
|
1595
1573
|
/**
|
|
1596
1574
|
* It returns a new array containing only one copy of each element in `list` according to `predicate` function.
|
|
1597
1575
|
*
|
|
1598
1576
|
* This predicate should return true, if two elements are equal.
|
|
1599
1577
|
*/
|
|
1600
|
-
export function uniqWith<T
|
|
1578
|
+
export function uniqWith<T>(predicate: (x: T, y: T) => boolean): (list: T[]) => T[];
|
|
1601
1579
|
|
|
1602
1580
|
/**
|
|
1603
1581
|
* The method returns function that will be called with argument `input`.
|
|
@@ -1623,8 +1601,8 @@ export function update<T>(index: number, newValue: T): (list: T[]) => T[];
|
|
|
1623
1601
|
* It pass `input` to `predicate` function and if the result is `true`, it will return the result of `whenTrueFn(input)`.
|
|
1624
1602
|
* If the `predicate` returns `false`, then it will simply return `input`.
|
|
1625
1603
|
*/
|
|
1626
|
-
export function when<T>(predicate: (x: T) => boolean, whenTrueFn: (
|
|
1627
|
-
export function when<T, U>(predicate: (x: T) => boolean, whenTrueFn: (
|
|
1604
|
+
export function when<T>(predicate: (x: T) => boolean, whenTrueFn: (x: T) => T): (input: T) => T;
|
|
1605
|
+
export function when<T, U>(predicate: (x: T) => boolean, whenTrueFn: (x: T) => U): (input: T) => T | U;
|
|
1628
1606
|
|
|
1629
1607
|
/**
|
|
1630
1608
|
* It will return a new array containing tuples of equally positions items from both `x` and `y` lists.
|