forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
streamjs.d.ts
165 lines (146 loc) · 5.07 KB
/
streamjs.d.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Type definitions for streamjs 1.5.0
// Project: http://winterbe.github.io/streamjs/
// Definitions by: Bence Eros <https://github.com/erosb>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare class Stream<T> {
static from <T> (elems: T[]): Stream<T>;
static from(str: string): Stream<string>;
static of<T>(...elems: T[]): Stream<T>;
static range (startInclusive: number, endExclusive: number): Stream<number>;
static rangeClosed (startInclusive: number, endInclusive: number): Stream<number>;
static generate <T> (supplier: Stream.Supplier<T>): Stream<T>;
static iterate<T>(seed: T, fn: Stream.Function<T, T>): Stream<T>;
anyMatch(predicate: Stream.Predicate<T>): boolean;
anyMatch(regexp: RegExp): boolean;
anyMatch(sample: Stream.Sample): boolean;
allMatch(predicate: Stream.Predicate<T>): boolean;
allMatch(regexp: RegExp): boolean;
allMatch(sample: Stream.Sample): boolean;
average(): number;
average(path: string): number;
avg(): number;
avg(path: string): number;
collect(collector: Stream.Collector<T>): T;
count(): number;
distinct(): Stream<T>;
dropWhile(predicate: Stream.Predicate<T>): Stream<T>;
dropWhile(regexp: RegExp): Stream<string>;
dropWhile(sample: Stream.Sample): Stream<T>;
each(consumer: Stream.Consumer<T>): void;
filter(predicate: Stream.Predicate<T>): Stream<T>;
filter(regexp: RegExp): Stream<string>;
filter(sample: Stream.Sample): Stream<T>;
findAny(): Stream.Optional<T>;
findFirst(): Stream.Optional<T>;
forEach(consumer: Stream.Consumer<T>): void;
groupBy(mapper: Stream.Function<T, string>): Stream.GroupingResult<T>;
groupBy(path: string): Stream.GroupingResult<T>;
groupingBy(mapper: Stream.Function<T, string>): Stream.GroupingResult<T>;
groupingBy(path: string): Stream.GroupingResult<T>;
indexBy(keyMapper: Stream.Function<T, string>, mergeFunction?: Stream.Accumulator<T>): Stream.Map<T>;
map <U> (mapper: Stream.Function<T, U>): Stream<U>;
max(): Stream.Optional<T>;
max(comparator: Stream.Comparator<T>): Stream.Optional<T>;
max(path: string): Stream.Optional<T>;
min(): Stream.Optional<T>;
min(comparator: Stream.Comparator<T>): Stream.Optional<T>;
min(path: string): Stream.Optional<T>;
noneMatch(predicate: (elem: T) => boolean): boolean;
noneMatch(regexp: RegExp): boolean;
flatMap <U> (mapper: Stream.Function<T, U[]>): Stream<U>;
iterator(): Stream.Iterator<T>;
joining(): string;
joining(delimiter: string): string;
joining(options: Stream.JoinOptions): string;
join(): string;
join(delimiter: string): string;
join(options: Stream.JoinOptions): string;
limit(limit: number): Stream<T>;
partitioningBy(predicate: Stream.Predicate<T>): T[][];
partitionBy(predicate: Stream.Predicate<T>): T[][];
partitionBy(sample: Stream.Sample): T[][];
partitioningBy(regexp: RegExp): T[][];
partitionBy(regexp: RegExp): T[][];
partitioningBy(size: number): T[][];
partitionBy(size: number): T[][];
partitioningBy(sample: Stream.Sample): T[][];
peek(consumer: Stream.Consumer<T>): Stream<T>;
reduce(identity: T, accumulator: Stream.Accumulator<T>): T;
reduce(accumulator: Stream.Accumulator<T>): Stream.Optional<T>;
reverse(): Stream<T>;
size(): number;
sorted(): Stream<T>;
sorted(comparator: Stream.Comparator<T>): Stream<T>;
sorted(path: string): Stream<T>;
sort(): Stream<T>;
sort(comparator: Stream.Comparator<T>): Stream<T>;
sort(path: string): Stream<T>;
shuffle(): Stream<T>;
skip(n: number): Stream<T>;
slice(begin: number, end: number): Stream<T>;
sum(): number;
sum(path: string): number;
takeWhile(predicate: Stream.Predicate<T>): Stream<T>;
takeWhile(regexp: RegExp): Stream<string>;
takeWhile(sample: Stream.Sample): Stream<T>;
toArray(): T[];
toList(): T[];
toMap(keyMapper: Stream.Function<T, string>, mergeFunction?: Stream.Accumulator<T>): Stream.Map<T>;
toMap(path: string, mergeFunction?: Stream.Accumulator<T>): Stream.Map<T>;
}
declare module Stream {
export interface Map<T> {
[index: string]: T
}
export interface Sample {
[index: string]: any
}
export interface Accumulator<T> {
(e1: T, e2: T): T;
}
export interface Collector<T> {
supplier: Supplier<T>;
accumulator: Stream.Accumulator<T>;
finisher: Function<T, T>;
}
export interface Comparator<T> {
(e1: T, e2: T): number
}
export interface Consumer<T> {
(elem: T): void;
}
export interface Function<T, U> {
(elem: T): U;
}
export interface GroupingResult<T> {
[index: string]: T
}
export interface Iterator<T> {
next(): T;
done: boolean;
}
export interface JoinOptions {
prefix: string;
delimiter: string;
suffix: string;
}
export interface Predicate<T> {
(elem: T): boolean;
}
export interface Supplier<T> {
(): T
}
export class Optional<T> {
static of<T>(elem: T): Optional<T>;
static ofNullable<T>(elem: T): Optional<T>;
filter(predicate: (elem: T) => boolean): Optional<T>;
map<U>(mapper: (elem: T) => U): Optional<U>;
flatMap<U>(mapper: (elem: T) => Stream.Optional<U>): Optional<U>;
isPresent(): boolean;
get(): T;
ifPresent(consumer: (elem: T) => void): void;
orElse(other: T): T;
orElseGet(supplier: Stream.Supplier<T>): T;
orElseThrow(error: any): T;
}
}