@everyonesoftware/common 2.0.0 → 4.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/outputs/chunk-AY3YWKOM.js +7741 -0
- package/outputs/chunk-AY3YWKOM.js.map +1 -0
- package/outputs/sources.cjs +9007 -0
- package/outputs/sources.cjs.map +1 -0
- package/outputs/sources.d.cts +4082 -0
- package/outputs/sources.d.ts +4082 -0
- package/outputs/sources.js +1370 -0
- package/outputs/sources.js.map +1 -0
- package/outputs/tests.cjs +17208 -0
- package/outputs/tests.cjs.map +1 -0
- package/outputs/tests.d.cts +3 -0
- package/outputs/tests.d.ts +3 -0
- package/outputs/tests.js +9798 -0
- package/outputs/tests.js.map +1 -0
- package/package.json +11 -2
- package/.c8rc.json +0 -12
- package/.github/workflows/publish.yml +0 -36
- package/.mocharc.json +0 -9
- package/sources/assertMessageParameters.ts +0 -22
- package/sources/asyncIterator.ts +0 -437
- package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +0 -48
- package/sources/asyncResult.ts +0 -95
- package/sources/basicDisposable.ts +0 -57
- package/sources/byteList.ts +0 -202
- package/sources/byteListStream.ts +0 -121
- package/sources/byteReadStream.ts +0 -24
- package/sources/byteWriteStream.ts +0 -16
- package/sources/bytes.ts +0 -25
- package/sources/characterList.ts +0 -195
- package/sources/characterListStream.ts +0 -151
- package/sources/characterReadStream.ts +0 -81
- package/sources/characterReadStreamIterator.ts +0 -128
- package/sources/characterWriteStream.ts +0 -45
- package/sources/commandLineParameter.ts +0 -45
- package/sources/commandLineParameters.ts +0 -21
- package/sources/comparable.ts +0 -144
- package/sources/comparer.ts +0 -133
- package/sources/comparison.ts +0 -20
- package/sources/concatenateIterable.ts +0 -119
- package/sources/concatenateIterator.ts +0 -165
- package/sources/condition.ts +0 -329
- package/sources/currentProcess.ts +0 -158
- package/sources/dateTime.ts +0 -130
- package/sources/depthFirstSearch.ts +0 -230
- package/sources/disposable.ts +0 -31
- package/sources/emptyError.ts +0 -10
- package/sources/english.ts +0 -45
- package/sources/equalFunctions.ts +0 -123
- package/sources/fetchHttpClient.ts +0 -89
- package/sources/fetchHttpResponse.ts +0 -106
- package/sources/flatMapIterable.ts +0 -104
- package/sources/flatMapIterator.ts +0 -152
- package/sources/generator.ts +0 -251
- package/sources/httpClient.ts +0 -36
- package/sources/httpHeader.ts +0 -37
- package/sources/httpHeaders.ts +0 -216
- package/sources/httpIncomingRequest.ts +0 -30
- package/sources/httpIncomingResponse.ts +0 -19
- package/sources/httpMethod.ts +0 -164
- package/sources/httpOutgoingRequest.ts +0 -119
- package/sources/httpOutgoingResponse.ts +0 -113
- package/sources/httpServer.ts +0 -34
- package/sources/inMemoryCharacterWriteStream.ts +0 -78
- package/sources/index.ts +0 -101
- package/sources/iterable.ts +0 -345
- package/sources/iterator.ts +0 -481
- package/sources/iteratorToJavascriptIteratorAdapter.ts +0 -48
- package/sources/javascript.ts +0 -59
- package/sources/javascriptArrayList.ts +0 -175
- package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +0 -124
- package/sources/javascriptIteratorToIteratorAdapter.ts +0 -133
- package/sources/javascriptMapMap.ts +0 -143
- package/sources/javascriptSetSet.ts +0 -134
- package/sources/list.ts +0 -330
- package/sources/listQueue.ts +0 -62
- package/sources/listStack.ts +0 -62
- package/sources/luxonDateTime.ts +0 -109
- package/sources/map.ts +0 -302
- package/sources/mapAsyncIterator.ts +0 -141
- package/sources/mapIterable.ts +0 -105
- package/sources/mapIterator.ts +0 -145
- package/sources/mutableCondition.ts +0 -451
- package/sources/mutableHttpHeaders.ts +0 -204
- package/sources/mutableMap.ts +0 -292
- package/sources/network.ts +0 -18
- package/sources/node.ts +0 -37
- package/sources/nodeJSCharacterWriteStream.ts +0 -42
- package/sources/nodeJSHttpIncomingRequest.ts +0 -132
- package/sources/nodeJSHttpServer.ts +0 -134
- package/sources/notFoundError.ts +0 -12
- package/sources/postCondition.ts +0 -284
- package/sources/postConditionError.ts +0 -12
- package/sources/preCondition.ts +0 -284
- package/sources/preConditionError.ts +0 -12
- package/sources/promiseAsyncResult.ts +0 -174
- package/sources/property.ts +0 -63
- package/sources/queue.ts +0 -49
- package/sources/realNetwork.ts +0 -28
- package/sources/recreationDotGovClient.ts +0 -259
- package/sources/searchControl.ts +0 -42
- package/sources/set.ts +0 -244
- package/sources/skipAsyncIterator.ts +0 -145
- package/sources/skipIterator.ts +0 -155
- package/sources/stack.ts +0 -48
- package/sources/stringComparer.ts +0 -33
- package/sources/stringIterator.ts +0 -149
- package/sources/strings.ts +0 -322
- package/sources/syncResult.ts +0 -300
- package/sources/takeAsyncIterator.ts +0 -141
- package/sources/takeIterator.ts +0 -151
- package/sources/toStringFunctions.ts +0 -185
- package/sources/types.ts +0 -371
- package/sources/whereAsyncIterator.ts +0 -143
- package/sources/whereIterable.ts +0 -108
- package/sources/whereIterator.ts +0 -157
- package/sources/wonderlandTrailClient.ts +0 -1503
- package/tests/assertTest.ts +0 -113
- package/tests/assertTestTests.ts +0 -75
- package/tests/basicTestSkip.ts +0 -51
- package/tests/byteListStreamTests.ts +0 -390
- package/tests/byteListTests.ts +0 -27
- package/tests/bytesTests.ts +0 -43
- package/tests/characterListStreamTests.ts +0 -391
- package/tests/characterListTests.ts +0 -250
- package/tests/characterWriteStreamTests.ts +0 -12
- package/tests/comparerTests.ts +0 -92
- package/tests/conditionTests.ts +0 -877
- package/tests/consoleTestRunner.ts +0 -404
- package/tests/consoleTestRunnerTests.ts +0 -651
- package/tests/dateTimeTests.ts +0 -30
- package/tests/depthFirstSearchTests.ts +0 -106
- package/tests/disposableTests.ts +0 -121
- package/tests/englishTests.ts +0 -103
- package/tests/equalFunctionsTests.ts +0 -223
- package/tests/failedTest.ts +0 -43
- package/tests/fetchHttpClientTests.ts +0 -33
- package/tests/generatorTests.ts +0 -86
- package/tests/httpClientTests.ts +0 -18
- package/tests/inMemoryCharacterWriteStreamTests.ts +0 -117
- package/tests/iterableTests.ts +0 -141
- package/tests/iteratorTests.ts +0 -1086
- package/tests/javascriptMapMapTests.ts +0 -21
- package/tests/listTests.ts +0 -338
- package/tests/mapIteratorTests.ts +0 -55
- package/tests/mapTests.ts +0 -104
- package/tests/mutableConditionTests.ts +0 -273
- package/tests/mutableMapTests.ts +0 -154
- package/tests/nodeJSHttpServerTests.ts +0 -75
- package/tests/notFoundErrorTests.ts +0 -24
- package/tests/postConditionErrorTests.ts +0 -24
- package/tests/preConditionErrorTests.ts +0 -24
- package/tests/promiseAsyncResultTests.ts +0 -688
- package/tests/propertyTests.ts +0 -63
- package/tests/queueTests.ts +0 -29
- package/tests/recreationDotGovClientTests.ts +0 -191
- package/tests/setTests.ts +0 -140
- package/tests/skippedTest.ts +0 -39
- package/tests/stackTests.ts +0 -66
- package/tests/stringComparerTests.ts +0 -60
- package/tests/stringIteratorTests.ts +0 -156
- package/tests/stringsTests.ts +0 -516
- package/tests/syncResultTests.ts +0 -1251
- package/tests/test.ts +0 -228
- package/tests/testAction.ts +0 -75
- package/tests/testActionTests.ts +0 -93
- package/tests/testFailureTests.ts +0 -12
- package/tests/testRunner.ts +0 -267
- package/tests/testRunnerTests.ts +0 -895
- package/tests/testSkip.ts +0 -34
- package/tests/tests.ts +0 -103
- package/tests/toStringFunctionsTests.ts +0 -55
- package/tests/typesTests.ts +0 -257
- package/tests/whereIteratorTests.ts +0 -77
- package/tests/wonderlandTrailClientTests.ts +0 -452
- package/tsconfig.json +0 -20
- package/tsup.config.ts +0 -13
package/sources/set.ts
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { PromiseAsyncResult } from "./promiseAsyncResult";
|
|
2
|
-
import { AsyncIterator } from "./asyncIterator";
|
|
3
|
-
import { JavascriptAsyncIterator } from "./javascript";
|
|
4
|
-
import { PreCondition } from "./preCondition";
|
|
5
|
-
import { Type } from "./types";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* An {@link AsyncIterator} that skips the first maximum number of values from an inner
|
|
9
|
-
* {@link AsyncIterator} before beginning to return values.
|
|
10
|
-
*/
|
|
11
|
-
export class SkipAsyncIterator<T> implements AsyncIterator<T>
|
|
12
|
-
{
|
|
13
|
-
private readonly innerIterator: AsyncIterator<T>;
|
|
14
|
-
private started: boolean;
|
|
15
|
-
private readonly maximumToSkip: number;
|
|
16
|
-
|
|
17
|
-
private constructor(innerIterator: AsyncIterator<T>, maximumToSkip: number)
|
|
18
|
-
{
|
|
19
|
-
PreCondition.assertNotUndefinedAndNotNull(innerIterator, "innerIterator");
|
|
20
|
-
PreCondition.assertNotUndefinedAndNotNull(maximumToSkip, "maximumToSkip");
|
|
21
|
-
PreCondition.assertInteger(maximumToSkip, "maximumToSkip");
|
|
22
|
-
PreCondition.assertGreaterThanOrEqualTo(maximumToSkip, 0, "maximumToSkip");
|
|
23
|
-
|
|
24
|
-
this.innerIterator = innerIterator;
|
|
25
|
-
this.started = false;
|
|
26
|
-
this.maximumToSkip = maximumToSkip;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public static create<T>(innerIterator: AsyncIterator<T>, maximumToSkip: number): SkipAsyncIterator<T>
|
|
30
|
-
{
|
|
31
|
-
return new SkipAsyncIterator(innerIterator, maximumToSkip);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public next(): PromiseAsyncResult<boolean>
|
|
35
|
-
{
|
|
36
|
-
return PromiseAsyncResult.create(async () =>
|
|
37
|
-
{
|
|
38
|
-
if (!this.hasStarted())
|
|
39
|
-
{
|
|
40
|
-
this.started = true;
|
|
41
|
-
await this.innerIterator.start();
|
|
42
|
-
|
|
43
|
-
for (let i = 0; i < this.maximumToSkip; i++)
|
|
44
|
-
{
|
|
45
|
-
if (!await this.innerIterator.next())
|
|
46
|
-
{
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else
|
|
52
|
-
{
|
|
53
|
-
await this.innerIterator.next();
|
|
54
|
-
}
|
|
55
|
-
return this.hasCurrent();
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public hasStarted(): boolean
|
|
60
|
-
{
|
|
61
|
-
return this.started;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public hasCurrent(): boolean
|
|
65
|
-
{
|
|
66
|
-
return this.hasStarted() && this.innerIterator.hasCurrent();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public getCurrent(): T
|
|
70
|
-
{
|
|
71
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
72
|
-
|
|
73
|
-
return this.innerIterator.getCurrent();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public start(): PromiseAsyncResult<this>
|
|
77
|
-
{
|
|
78
|
-
return AsyncIterator.start<T, this>(this);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
public takeCurrent(): PromiseAsyncResult<T>
|
|
82
|
-
{
|
|
83
|
-
return AsyncIterator.takeCurrent(this);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public any(): PromiseAsyncResult<boolean>
|
|
87
|
-
{
|
|
88
|
-
return AsyncIterator.any(this);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public getCount(): PromiseAsyncResult<number>
|
|
92
|
-
{
|
|
93
|
-
return AsyncIterator.getCount(this);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
public toArray(): PromiseAsyncResult<T[]>
|
|
97
|
-
{
|
|
98
|
-
return AsyncIterator.toArray(this);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
public where(condition: (value: T) => (boolean | PromiseLike<boolean>)): AsyncIterator<T>
|
|
102
|
-
{
|
|
103
|
-
return AsyncIterator.where(this, condition);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
public whereInstanceOf<U extends T>(typeCheck: (value: T) => value is U): AsyncIterator<U>
|
|
107
|
-
{
|
|
108
|
-
return AsyncIterator.whereInstanceOf(this, typeCheck);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
public whereInstanceOfType<U extends T>(type: Type<U>): AsyncIterator<U>
|
|
112
|
-
{
|
|
113
|
-
return AsyncIterator.whereInstanceOfType(this, type);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
public map<TOutput>(mapping: (value: T) => (TOutput | PromiseLike<TOutput>)): AsyncIterator<TOutput>
|
|
117
|
-
{
|
|
118
|
-
return AsyncIterator.map(this, mapping);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public first(condition?: (value: T) => (boolean | PromiseLike<boolean>)): PromiseAsyncResult<T>
|
|
122
|
-
{
|
|
123
|
-
return AsyncIterator.first(this, condition);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
public last(condition?: (value: T) => (boolean | PromiseLike<boolean>)): PromiseAsyncResult<T>
|
|
127
|
-
{
|
|
128
|
-
return AsyncIterator.last(this, condition);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
public [Symbol.asyncIterator](): JavascriptAsyncIterator<T>
|
|
132
|
-
{
|
|
133
|
-
return AsyncIterator[Symbol.asyncIterator](this);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public take(maximumToTake: number): AsyncIterator<T>
|
|
137
|
-
{
|
|
138
|
-
return AsyncIterator.take(this, maximumToTake);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
public skip(maximumToSkip: number): AsyncIterator<T>
|
|
142
|
-
{
|
|
143
|
-
return AsyncIterator.skip(this, maximumToSkip);
|
|
144
|
-
}
|
|
145
|
-
}
|
package/sources/skipIterator.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { Iterator } from "./iterator";
|
|
2
|
-
import { JavascriptIterable, JavascriptIterator } from "./javascript";
|
|
3
|
-
import { PreCondition } from "./preCondition";
|
|
4
|
-
import { SyncResult } from "./syncResult";
|
|
5
|
-
import { Type } from "./types";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* An {@link Iterator} that skips the first maximum number of values from an inner {@link Iterator}
|
|
9
|
-
* before beginning to return values.
|
|
10
|
-
*/
|
|
11
|
-
export class SkipIterator<T> implements Iterator<T>
|
|
12
|
-
{
|
|
13
|
-
private readonly innerIterator: Iterator<T>;
|
|
14
|
-
private started: boolean;
|
|
15
|
-
private readonly maximumToSkip: number;
|
|
16
|
-
|
|
17
|
-
private constructor(innerIterator: Iterator<T>, maximumToSkip: number)
|
|
18
|
-
{
|
|
19
|
-
PreCondition.assertNotUndefinedAndNotNull(innerIterator, "innerIterator");
|
|
20
|
-
PreCondition.assertNotUndefinedAndNotNull(maximumToSkip, "maximumToSkip");
|
|
21
|
-
PreCondition.assertInteger(maximumToSkip, "maximumToSkip");
|
|
22
|
-
PreCondition.assertGreaterThanOrEqualTo(maximumToSkip, 0, "maximumToSkip");
|
|
23
|
-
|
|
24
|
-
this.innerIterator = innerIterator;
|
|
25
|
-
this.started = false;
|
|
26
|
-
this.maximumToSkip = maximumToSkip;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public static create<T>(innerIterator: Iterator<T>, maximumToSkip: number)
|
|
30
|
-
{
|
|
31
|
-
return new SkipIterator(innerIterator, maximumToSkip);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public next(): SyncResult<boolean>
|
|
35
|
-
{
|
|
36
|
-
return SyncResult.create(() =>
|
|
37
|
-
{
|
|
38
|
-
if (!this.hasStarted())
|
|
39
|
-
{
|
|
40
|
-
this.started = true;
|
|
41
|
-
this.innerIterator.start().await();
|
|
42
|
-
|
|
43
|
-
for (let i = 0; i < this.maximumToSkip; i++)
|
|
44
|
-
{
|
|
45
|
-
if (!this.innerIterator.next().await())
|
|
46
|
-
{
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else
|
|
52
|
-
{
|
|
53
|
-
this.innerIterator.next().await();
|
|
54
|
-
}
|
|
55
|
-
return this.hasCurrent();
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public hasStarted(): boolean
|
|
60
|
-
{
|
|
61
|
-
return this.started;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public hasCurrent(): boolean
|
|
65
|
-
{
|
|
66
|
-
return this.hasStarted() && this.innerIterator.hasCurrent();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public getCurrent(): T
|
|
70
|
-
{
|
|
71
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
72
|
-
|
|
73
|
-
return this.innerIterator.getCurrent();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public start(): SyncResult<this>
|
|
77
|
-
{
|
|
78
|
-
return Iterator.start<T, this>(this);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
public takeCurrent(): SyncResult<T>
|
|
82
|
-
{
|
|
83
|
-
return Iterator.takeCurrent(this);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public any(): SyncResult<boolean>
|
|
87
|
-
{
|
|
88
|
-
return Iterator.any(this);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public getCount(): SyncResult<number>
|
|
92
|
-
{
|
|
93
|
-
return Iterator.getCount(this);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
public toArray(): SyncResult<T[]>
|
|
97
|
-
{
|
|
98
|
-
return Iterator.toArray(this);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
public concatenate(...toConcatenate: JavascriptIterable<T>[]): Iterator<T>
|
|
102
|
-
{
|
|
103
|
-
return Iterator.concatenate(this, ...toConcatenate);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
public where(condition: (value: T) => boolean): Iterator<T>
|
|
107
|
-
{
|
|
108
|
-
return Iterator.where(this, condition);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
public whereInstanceOf<U extends T>(typeCheck: (value: T) => value is U): Iterator<U>
|
|
112
|
-
{
|
|
113
|
-
return Iterator.whereInstanceOf(this, typeCheck);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
public whereInstanceOfType<U extends T>(type: Type<U>): Iterator<U>
|
|
117
|
-
{
|
|
118
|
-
return Iterator.whereInstanceOfType(this, type);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public map<TOutput>(mapping: (value: T) => (TOutput | SyncResult<TOutput>)): Iterator<TOutput>
|
|
122
|
-
{
|
|
123
|
-
return Iterator.map(this, mapping);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
public flatMap<TOutput>(mapping: (value: T) => JavascriptIterable<TOutput>): Iterator<TOutput>
|
|
127
|
-
{
|
|
128
|
-
return Iterator.flatMap(this, mapping);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
public first(condition?: (value: T) => boolean): SyncResult<T>
|
|
132
|
-
{
|
|
133
|
-
return Iterator.first(this, condition);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public last(condition?: (value: T) => boolean): SyncResult<T>
|
|
137
|
-
{
|
|
138
|
-
return Iterator.last(this, condition);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
public [Symbol.iterator](): JavascriptIterator<T>
|
|
142
|
-
{
|
|
143
|
-
return Iterator[Symbol.iterator](this);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
public take(maximumToTake: number): Iterator<T>
|
|
147
|
-
{
|
|
148
|
-
return Iterator.take(this, maximumToTake);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
public skip(maximumToSkip: number): Iterator<T>
|
|
152
|
-
{
|
|
153
|
-
return Iterator.skip(this, maximumToSkip);
|
|
154
|
-
}
|
|
155
|
-
}
|
package/sources/stack.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { EqualFunctions } from "./equalFunctions";
|
|
2
|
-
import { JavascriptIterable } from "./javascript";
|
|
3
|
-
import { ListStack } from "./listStack";
|
|
4
|
-
import { AsyncResult } from "./asyncResult";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A data structure that stores values in a first-in-last-out order.
|
|
8
|
-
*/
|
|
9
|
-
export abstract class Stack<T>
|
|
10
|
-
{
|
|
11
|
-
/**
|
|
12
|
-
* Create an instance of the default {@link Stack} implementation.
|
|
13
|
-
* @returns A new {@link Stack} object.
|
|
14
|
-
*/
|
|
15
|
-
public static create<T>(): ListStack<T>
|
|
16
|
-
{
|
|
17
|
-
return ListStack.create();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Get whether there are any values in this {@link Stack}.
|
|
22
|
-
*/
|
|
23
|
-
public abstract any(): AsyncResult<boolean>;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Push the provided value onto the top of this {@link Stack}.
|
|
27
|
-
* @param value The value to push on the top of this {@link Stack}.
|
|
28
|
-
*/
|
|
29
|
-
public abstract add(value: T): AsyncResult<void>;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Push the provided values onto the top of this {@link Stack}.
|
|
33
|
-
* @param values The values to push onto this {@link Stack}.
|
|
34
|
-
*/
|
|
35
|
-
public abstract addAll(values: JavascriptIterable<T>): AsyncResult<void>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Remove the top value off of this {@link Stack}.
|
|
39
|
-
*/
|
|
40
|
-
public abstract remove(): AsyncResult<T>;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Get whether this {@link Stack} contains the provided value.
|
|
44
|
-
* @param value The value to look for.
|
|
45
|
-
* @param equalFunctions The functions to use to compare values.
|
|
46
|
-
*/
|
|
47
|
-
public abstract contains(value: T, equalFunctions?: EqualFunctions): AsyncResult<boolean>;
|
|
48
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Comparer } from "./comparer";
|
|
2
|
-
import { Comparison } from "./comparison";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A {@link Comparer} that performs {@link string} comparisons.
|
|
6
|
-
*/
|
|
7
|
-
export class StringComparer extends Comparer<string>
|
|
8
|
-
{
|
|
9
|
-
protected constructor()
|
|
10
|
-
{
|
|
11
|
-
super();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public static create(): StringComparer
|
|
15
|
-
{
|
|
16
|
-
return new StringComparer();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public override compare(left: string, right: string): Comparison
|
|
20
|
-
{
|
|
21
|
-
return StringComparer.compare(left, right);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public static compare(left: string, right: string): Comparison
|
|
25
|
-
{
|
|
26
|
-
let result: Comparison | undefined = Comparer.compareSameUndefinedNull(left, right);
|
|
27
|
-
if (result === undefined)
|
|
28
|
-
{
|
|
29
|
-
result = (left < right ? Comparison.LessThan : Comparison.GreaterThan);
|
|
30
|
-
}
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
}
|