@everyonesoftware/common 1.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +54 -38
- package/package.json +9 -2
- package/sources/asyncIterator.ts +436 -436
- package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +47 -47
- package/sources/asyncResult.ts +95 -95
- package/sources/byteList.ts +201 -201
- package/sources/byteListStream.ts +120 -120
- package/sources/byteReadStream.ts +23 -23
- package/sources/byteWriteStream.ts +15 -15
- package/sources/characterList.ts +194 -194
- package/sources/characterListStream.ts +150 -150
- package/sources/characterReadStream.ts +80 -80
- package/sources/characterReadStreamIterator.ts +127 -127
- package/sources/concatenateIterable.ts +118 -118
- package/sources/concatenateIterator.ts +164 -164
- package/sources/currentProcess.ts +157 -157
- package/sources/dateTime.ts +129 -129
- package/sources/depthFirstSearch.ts +229 -229
- package/sources/flatMapIterable.ts +103 -103
- package/sources/flatMapIterator.ts +151 -151
- package/sources/generator.ts +250 -250
- package/sources/index.ts +1 -1
- package/sources/iterator.ts +480 -480
- package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +123 -123
- package/sources/javascriptSetSet.ts +133 -133
- package/sources/listQueue.ts +61 -61
- package/sources/listStack.ts +61 -61
- package/sources/luxonDateTime.ts +108 -108
- package/sources/mapAsyncIterator.ts +140 -140
- package/sources/mutableMap.ts +291 -291
- package/sources/node.ts +36 -36
- package/sources/promiseAsyncResult.ts +173 -173
- package/sources/queue.ts +48 -48
- package/sources/recreationDotGovClient.ts +258 -258
- package/sources/searchControl.ts +41 -41
- package/sources/set.ts +243 -243
- package/sources/skipAsyncIterator.ts +144 -144
- package/sources/stack.ts +47 -47
- package/sources/syncResult.ts +299 -299
- package/sources/takeAsyncIterator.ts +140 -140
- package/sources/whereAsyncIterator.ts +142 -142
- package/sources/wonderlandTrailClient.ts +1502 -1502
- package/tests/assertTestTests.ts +74 -74
- package/tests/byteListStreamTests.ts +389 -389
- package/tests/byteListTests.ts +26 -26
- package/tests/characterListStreamTests.ts +390 -390
- package/tests/characterListTests.ts +249 -249
- package/tests/dateTimeTests.ts +29 -29
- package/tests/depthFirstSearchTests.ts +105 -105
- package/tests/generatorTests.ts +85 -85
- package/tests/mutableMapTests.ts +153 -153
- package/tests/promiseAsyncResultTests.ts +687 -687
- package/tests/queueTests.ts +28 -28
- package/tests/recreationDotGovClientTests.ts +190 -190
- package/tests/setTests.ts +139 -139
- package/tests/stackTests.ts +65 -65
- package/tests/syncResultTests.ts +1250 -1250
- package/tests/wonderlandTrailClientTests.ts +451 -451
- package/tsconfig.json +3 -0
- package/tsup.config.ts +12 -12
package/sources/set.ts
CHANGED
|
@@ -1,244 +1,244 @@
|
|
|
1
|
-
import { EqualFunctions } from "./equalFunctions";
|
|
2
|
-
import { Iterable } from "./iterable";
|
|
3
|
-
import { Iterator } from "./iterator";
|
|
4
|
-
import { JavascriptIterable, JavascriptIterator } from "./javascript";
|
|
5
|
-
import { JavascriptSetSet } from "./javascriptSetSet";
|
|
6
|
-
import { PreCondition } from "./preCondition";
|
|
7
|
-
import { SyncResult } from "./syncResult";
|
|
8
|
-
import { ToStringFunctions } from "./toStringFunctions";
|
|
9
|
-
import { hasFunction, Type } from "./types";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Get whether the provided value is a {@link Set}.
|
|
13
|
-
* @param value The value to check.
|
|
14
|
-
*/
|
|
15
|
-
export function isSet(value: unknown): value is Set<unknown>
|
|
16
|
-
{
|
|
17
|
-
return value instanceof Set ||
|
|
18
|
-
(
|
|
19
|
-
hasFunction(value, "add", 1) &&
|
|
20
|
-
hasFunction(value, "addAll", 1) &&
|
|
21
|
-
hasFunction(value, "remove", 1)
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export abstract class Set<T> implements Iterable<T>
|
|
26
|
-
{
|
|
27
|
-
public static create<T>(initialValues?: JavascriptIterable<T>): JavascriptSetSet<T>
|
|
28
|
-
{
|
|
29
|
-
return JavascriptSetSet.create(initialValues);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Add the provided value to this {@link Set}.
|
|
34
|
-
* @param value The value to add to this {@link Set}.
|
|
35
|
-
*/
|
|
36
|
-
public abstract add(value: T): this;
|
|
37
|
-
|
|
38
|
-
public addAll(values: JavascriptIterable<T>): this
|
|
39
|
-
{
|
|
40
|
-
return Set.addAll(this, values);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public static addAll<T, TSet extends Set<T>>(set: TSet, values: JavascriptIterable<T>): TSet
|
|
44
|
-
{
|
|
45
|
-
PreCondition.assertNotUndefinedAndNotNull(set, "set");
|
|
46
|
-
PreCondition.assertNotUndefinedAndNotNull(values, "values");
|
|
47
|
-
|
|
48
|
-
for (const value of values)
|
|
49
|
-
{
|
|
50
|
-
set.add(value);
|
|
51
|
-
}
|
|
52
|
-
return set;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Remove the provided value from this {@link Set}. Return a {@link NotFoundError} if the value
|
|
57
|
-
* is not found.
|
|
58
|
-
* @param value The value to remove.
|
|
59
|
-
*/
|
|
60
|
-
public abstract remove(value: T): SyncResult<void>;
|
|
61
|
-
|
|
62
|
-
public abstract iterate(): Iterator<T>;
|
|
63
|
-
|
|
64
|
-
public union(values: JavascriptIterable<T>): Set<T>
|
|
65
|
-
{
|
|
66
|
-
return Set.union(this, values);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public static union<T>(set: Set<T>, values: JavascriptIterable<T>): Set<T>
|
|
70
|
-
{
|
|
71
|
-
PreCondition.assertNotUndefinedAndNotNull(set, "set");
|
|
72
|
-
PreCondition.assertNotUndefinedAndNotNull(values, "values");
|
|
73
|
-
|
|
74
|
-
const result: Set<T> = Set.create();
|
|
75
|
-
result.addAll(set);
|
|
76
|
-
result.addAll(values);
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public toArray(): SyncResult<T[]>
|
|
81
|
-
{
|
|
82
|
-
return Set.toArray(this);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public static toArray<T>(set: Set<T>): SyncResult<T[]>
|
|
86
|
-
{
|
|
87
|
-
return Iterable.toArray(set);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public any(): SyncResult<boolean>
|
|
91
|
-
{
|
|
92
|
-
return Set.any(this);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public static any<T>(set: Set<T>): SyncResult<boolean>
|
|
96
|
-
{
|
|
97
|
-
return SyncResult.create(() =>
|
|
98
|
-
{
|
|
99
|
-
return set.getCount().await() > 0;
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
public getCount(): SyncResult<number>
|
|
104
|
-
{
|
|
105
|
-
return Set.getCount(this);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public static getCount<T>(set: Set<T>): SyncResult<number>
|
|
109
|
-
{
|
|
110
|
-
return Iterable.getCount(set);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
public equals(right: JavascriptIterable<T>, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
114
|
-
{
|
|
115
|
-
return Set.equals(this, right, equalFunctions);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public static equals<T>(left: Set<T>, right: JavascriptIterable<T>, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
119
|
-
{
|
|
120
|
-
return isSet(right)
|
|
121
|
-
? Set.equalSet(left, right, equalFunctions)
|
|
122
|
-
: Iterable.equals(left, right, equalFunctions);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
public static equalSet<T>(left: Set<T>, right: Set<T>, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
126
|
-
{
|
|
127
|
-
return SyncResult.create(() =>
|
|
128
|
-
{
|
|
129
|
-
let result: boolean = left.getCount().await() === right.getCount().await();
|
|
130
|
-
if (result)
|
|
131
|
-
{
|
|
132
|
-
for (const leftValue of left)
|
|
133
|
-
{
|
|
134
|
-
if (!right.contains(leftValue, equalFunctions).await())
|
|
135
|
-
{
|
|
136
|
-
result = false;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return result;
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
public toString(toStringFunctions?: ToStringFunctions): string
|
|
146
|
-
{
|
|
147
|
-
return Set.toString(this, toStringFunctions);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
public static toString<T>(set: Set<T>, toStringFunctions?: ToStringFunctions): string
|
|
151
|
-
{
|
|
152
|
-
return Iterable.toString(set, toStringFunctions);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
public concatenate(...toConcatenate: JavascriptIterable<T>[]): Iterable<T>
|
|
156
|
-
{
|
|
157
|
-
return Set.concatenate(this, ...toConcatenate);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
public static concatenate<T>(set: Set<T>, ...toConcatenate: JavascriptIterable<T>[]): Iterable<T>
|
|
161
|
-
{
|
|
162
|
-
return Iterable.concatenate(set, ...toConcatenate);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
public map<TOutput>(mapping: (value: T) => (TOutput | SyncResult<TOutput>)): Iterable<TOutput>
|
|
166
|
-
{
|
|
167
|
-
return Set.map<T, TOutput>(this, mapping);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
public static map<TInput, TOutput>(set: Set<TInput>, mapping: (value: TInput) => (TOutput | SyncResult<TOutput>)): Iterable<TOutput>
|
|
171
|
-
{
|
|
172
|
-
return Iterable.map<TInput, TOutput>(set, mapping);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
public flatMap<TOutput>(mapping: (value: T) => JavascriptIterable<TOutput>): Iterable<TOutput>
|
|
176
|
-
{
|
|
177
|
-
return Set.flatMap(this, mapping);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
public static flatMap<TInput, TOutput>(set: Set<TInput>, mapping: (value: TInput) => JavascriptIterable<TOutput>): Iterable<TOutput>
|
|
181
|
-
{
|
|
182
|
-
return Iterable.flatMap<TInput, TOutput>(set, mapping);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
public where(condition: (value: T) => (boolean | SyncResult<boolean>)): Iterable<T>
|
|
186
|
-
{
|
|
187
|
-
return Set.where(this, condition);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
public static where<T>(set: Set<T>, condition: (value: T) => (boolean | SyncResult<boolean>)): Iterable<T>
|
|
191
|
-
{
|
|
192
|
-
return Iterable.where(set, condition);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
public instanceOf<TOutput extends T>(typeOrTypeCheck: Type<TOutput> | ((value: T) => value is TOutput)): Iterable<TOutput>
|
|
196
|
-
{
|
|
197
|
-
return Set.instanceOf(this, typeOrTypeCheck);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
public static instanceOf<TInput, TOutput extends TInput>(set: Set<TInput>, typeOrTypeCheck: Type<TOutput> | ((value: TInput) => value is TOutput)): Iterable<TOutput>
|
|
201
|
-
{
|
|
202
|
-
return Iterable.instanceOf(set, typeOrTypeCheck);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
public first(condition?: ((value: T) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<T>
|
|
206
|
-
{
|
|
207
|
-
return Set.first(this, condition);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
public static first<T>(set: Set<T>, condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>
|
|
211
|
-
{
|
|
212
|
-
return Iterable.first(set, condition);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
public last(condition?: ((value: T) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<T>
|
|
216
|
-
{
|
|
217
|
-
return Set.last(this, condition);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
public static last<T>(set: Set<T>, condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>
|
|
221
|
-
{
|
|
222
|
-
return Iterable.last(set, condition);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
public [Symbol.iterator](): JavascriptIterator<T>
|
|
226
|
-
{
|
|
227
|
-
return Set[Symbol.iterator](this);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
public static [Symbol.iterator]<T>(set: Set<T>): JavascriptIterator<T>
|
|
231
|
-
{
|
|
232
|
-
return Iterable[Symbol.iterator](set);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
public contains(value: T, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
236
|
-
{
|
|
237
|
-
return Set.contains(this, value, equalFunctions);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
public static contains<T>(set: Set<T>, value: T, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
241
|
-
{
|
|
242
|
-
return Iterable.contains(set, value, equalFunctions);
|
|
243
|
-
}
|
|
1
|
+
import { EqualFunctions } from "./equalFunctions";
|
|
2
|
+
import { Iterable } from "./iterable";
|
|
3
|
+
import { Iterator } from "./iterator";
|
|
4
|
+
import { JavascriptIterable, JavascriptIterator } from "./javascript";
|
|
5
|
+
import { JavascriptSetSet } from "./javascriptSetSet";
|
|
6
|
+
import { PreCondition } from "./preCondition";
|
|
7
|
+
import { SyncResult } from "./syncResult";
|
|
8
|
+
import { ToStringFunctions } from "./toStringFunctions";
|
|
9
|
+
import { hasFunction, Type } from "./types";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get whether the provided value is a {@link Set}.
|
|
13
|
+
* @param value The value to check.
|
|
14
|
+
*/
|
|
15
|
+
export function isSet(value: unknown): value is Set<unknown>
|
|
16
|
+
{
|
|
17
|
+
return value instanceof Set ||
|
|
18
|
+
(
|
|
19
|
+
hasFunction(value, "add", 1) &&
|
|
20
|
+
hasFunction(value, "addAll", 1) &&
|
|
21
|
+
hasFunction(value, "remove", 1)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export abstract class Set<T> implements Iterable<T>
|
|
26
|
+
{
|
|
27
|
+
public static create<T>(initialValues?: JavascriptIterable<T>): JavascriptSetSet<T>
|
|
28
|
+
{
|
|
29
|
+
return JavascriptSetSet.create(initialValues);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Add the provided value to this {@link Set}.
|
|
34
|
+
* @param value The value to add to this {@link Set}.
|
|
35
|
+
*/
|
|
36
|
+
public abstract add(value: T): this;
|
|
37
|
+
|
|
38
|
+
public addAll(values: JavascriptIterable<T>): this
|
|
39
|
+
{
|
|
40
|
+
return Set.addAll(this, values);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static addAll<T, TSet extends Set<T>>(set: TSet, values: JavascriptIterable<T>): TSet
|
|
44
|
+
{
|
|
45
|
+
PreCondition.assertNotUndefinedAndNotNull(set, "set");
|
|
46
|
+
PreCondition.assertNotUndefinedAndNotNull(values, "values");
|
|
47
|
+
|
|
48
|
+
for (const value of values)
|
|
49
|
+
{
|
|
50
|
+
set.add(value);
|
|
51
|
+
}
|
|
52
|
+
return set;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Remove the provided value from this {@link Set}. Return a {@link NotFoundError} if the value
|
|
57
|
+
* is not found.
|
|
58
|
+
* @param value The value to remove.
|
|
59
|
+
*/
|
|
60
|
+
public abstract remove(value: T): SyncResult<void>;
|
|
61
|
+
|
|
62
|
+
public abstract iterate(): Iterator<T>;
|
|
63
|
+
|
|
64
|
+
public union(values: JavascriptIterable<T>): Set<T>
|
|
65
|
+
{
|
|
66
|
+
return Set.union(this, values);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public static union<T>(set: Set<T>, values: JavascriptIterable<T>): Set<T>
|
|
70
|
+
{
|
|
71
|
+
PreCondition.assertNotUndefinedAndNotNull(set, "set");
|
|
72
|
+
PreCondition.assertNotUndefinedAndNotNull(values, "values");
|
|
73
|
+
|
|
74
|
+
const result: Set<T> = Set.create();
|
|
75
|
+
result.addAll(set);
|
|
76
|
+
result.addAll(values);
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public toArray(): SyncResult<T[]>
|
|
81
|
+
{
|
|
82
|
+
return Set.toArray(this);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public static toArray<T>(set: Set<T>): SyncResult<T[]>
|
|
86
|
+
{
|
|
87
|
+
return Iterable.toArray(set);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public any(): SyncResult<boolean>
|
|
91
|
+
{
|
|
92
|
+
return Set.any(this);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public static any<T>(set: Set<T>): SyncResult<boolean>
|
|
96
|
+
{
|
|
97
|
+
return SyncResult.create(() =>
|
|
98
|
+
{
|
|
99
|
+
return set.getCount().await() > 0;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public getCount(): SyncResult<number>
|
|
104
|
+
{
|
|
105
|
+
return Set.getCount(this);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public static getCount<T>(set: Set<T>): SyncResult<number>
|
|
109
|
+
{
|
|
110
|
+
return Iterable.getCount(set);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public equals(right: JavascriptIterable<T>, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
114
|
+
{
|
|
115
|
+
return Set.equals(this, right, equalFunctions);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public static equals<T>(left: Set<T>, right: JavascriptIterable<T>, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
119
|
+
{
|
|
120
|
+
return isSet(right)
|
|
121
|
+
? Set.equalSet(left, right, equalFunctions)
|
|
122
|
+
: Iterable.equals(left, right, equalFunctions);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public static equalSet<T>(left: Set<T>, right: Set<T>, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
126
|
+
{
|
|
127
|
+
return SyncResult.create(() =>
|
|
128
|
+
{
|
|
129
|
+
let result: boolean = left.getCount().await() === right.getCount().await();
|
|
130
|
+
if (result)
|
|
131
|
+
{
|
|
132
|
+
for (const leftValue of left)
|
|
133
|
+
{
|
|
134
|
+
if (!right.contains(leftValue, equalFunctions).await())
|
|
135
|
+
{
|
|
136
|
+
result = false;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return result;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public toString(toStringFunctions?: ToStringFunctions): string
|
|
146
|
+
{
|
|
147
|
+
return Set.toString(this, toStringFunctions);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
public static toString<T>(set: Set<T>, toStringFunctions?: ToStringFunctions): string
|
|
151
|
+
{
|
|
152
|
+
return Iterable.toString(set, toStringFunctions);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public concatenate(...toConcatenate: JavascriptIterable<T>[]): Iterable<T>
|
|
156
|
+
{
|
|
157
|
+
return Set.concatenate(this, ...toConcatenate);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public static concatenate<T>(set: Set<T>, ...toConcatenate: JavascriptIterable<T>[]): Iterable<T>
|
|
161
|
+
{
|
|
162
|
+
return Iterable.concatenate(set, ...toConcatenate);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public map<TOutput>(mapping: (value: T) => (TOutput | SyncResult<TOutput>)): Iterable<TOutput>
|
|
166
|
+
{
|
|
167
|
+
return Set.map<T, TOutput>(this, mapping);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public static map<TInput, TOutput>(set: Set<TInput>, mapping: (value: TInput) => (TOutput | SyncResult<TOutput>)): Iterable<TOutput>
|
|
171
|
+
{
|
|
172
|
+
return Iterable.map<TInput, TOutput>(set, mapping);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
public flatMap<TOutput>(mapping: (value: T) => JavascriptIterable<TOutput>): Iterable<TOutput>
|
|
176
|
+
{
|
|
177
|
+
return Set.flatMap(this, mapping);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public static flatMap<TInput, TOutput>(set: Set<TInput>, mapping: (value: TInput) => JavascriptIterable<TOutput>): Iterable<TOutput>
|
|
181
|
+
{
|
|
182
|
+
return Iterable.flatMap<TInput, TOutput>(set, mapping);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
public where(condition: (value: T) => (boolean | SyncResult<boolean>)): Iterable<T>
|
|
186
|
+
{
|
|
187
|
+
return Set.where(this, condition);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public static where<T>(set: Set<T>, condition: (value: T) => (boolean | SyncResult<boolean>)): Iterable<T>
|
|
191
|
+
{
|
|
192
|
+
return Iterable.where(set, condition);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
public instanceOf<TOutput extends T>(typeOrTypeCheck: Type<TOutput> | ((value: T) => value is TOutput)): Iterable<TOutput>
|
|
196
|
+
{
|
|
197
|
+
return Set.instanceOf(this, typeOrTypeCheck);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public static instanceOf<TInput, TOutput extends TInput>(set: Set<TInput>, typeOrTypeCheck: Type<TOutput> | ((value: TInput) => value is TOutput)): Iterable<TOutput>
|
|
201
|
+
{
|
|
202
|
+
return Iterable.instanceOf(set, typeOrTypeCheck);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
public first(condition?: ((value: T) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<T>
|
|
206
|
+
{
|
|
207
|
+
return Set.first(this, condition);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
public static first<T>(set: Set<T>, condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>
|
|
211
|
+
{
|
|
212
|
+
return Iterable.first(set, condition);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
public last(condition?: ((value: T) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<T>
|
|
216
|
+
{
|
|
217
|
+
return Set.last(this, condition);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public static last<T>(set: Set<T>, condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>
|
|
221
|
+
{
|
|
222
|
+
return Iterable.last(set, condition);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
public [Symbol.iterator](): JavascriptIterator<T>
|
|
226
|
+
{
|
|
227
|
+
return Set[Symbol.iterator](this);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
public static [Symbol.iterator]<T>(set: Set<T>): JavascriptIterator<T>
|
|
231
|
+
{
|
|
232
|
+
return Iterable[Symbol.iterator](set);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
public contains(value: T, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
236
|
+
{
|
|
237
|
+
return Set.contains(this, value, equalFunctions);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public static contains<T>(set: Set<T>, value: T, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
241
|
+
{
|
|
242
|
+
return Iterable.contains(set, value, equalFunctions);
|
|
243
|
+
}
|
|
244
244
|
}
|