-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathpluck.ts
71 lines (62 loc) · 1.64 KB
/
pluck.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* @license Use of this source code is governed by an MIT-style license that
* can be found in the LICENSE file at https://github.com/cartant/rxjs-etc
*/
import { OperatorFunction } from "rxjs";
import { pluck as untypedPluck } from "rxjs/operators";
export function pluck<T, K1 extends keyof T>(
k1: K1
): OperatorFunction<T, T[K1]>;
export function pluck<T, K1 extends keyof T, K2 extends keyof T[K1]>(
k1: K1,
k2: K2
): OperatorFunction<T, T[K1][K2]>;
export function pluck<
T,
K1 extends keyof T,
K2 extends keyof T[K1],
K3 extends keyof T[K1][K2]
>(k1: K1, k2: K2, k3: K3): OperatorFunction<T, T[K1][K2][K3]>;
export function pluck<
T,
K1 extends keyof T,
K2 extends keyof T[K1],
K3 extends keyof T[K1][K2],
K4 extends keyof T[K1][K2][K3]
>(k1: K1, k2: K2, k3: K3, k4: K4): OperatorFunction<T, T[K1][K2][K3][K4]>;
export function pluck<
T,
K1 extends keyof T,
K2 extends keyof T[K1],
K3 extends keyof T[K1][K2],
K4 extends keyof T[K1][K2][K3],
K5 extends keyof T[K1][K2][K3][K4]
>(
k1: K1,
k2: K2,
k3: K3,
k4: K4,
k5: K5
): OperatorFunction<T, T[K1][K2][K3][K4][K5]>;
export function pluck<
T,
K1 extends keyof T,
K2 extends keyof T[K1],
K3 extends keyof T[K1][K2],
K4 extends keyof T[K1][K2][K3],
K5 extends keyof T[K1][K2][K3][K4],
K6 extends keyof T[K1][K2][K3][K4][K5]
>(
k1: K1,
k2: K2,
k3: K3,
k4: K4,
k5: K5,
k6: K6
): OperatorFunction<T, T[K1][K2][K3][K4][K5][K6]>;
export function pluck<T, R>(
...keys: (string | number)[]
): OperatorFunction<T, R>;
export function pluck<T>(...keys: any[]): OperatorFunction<T, any> {
return (source) => untypedPluck(...keys)(source);
}