@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
|
@@ -1,104 +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 { PreCondition } from "./preCondition";
|
|
6
|
-
import { SyncResult } from "./syncResult";
|
|
7
|
-
import { ToStringFunctions } from "./toStringFunctions";
|
|
8
|
-
import { Type } from "./types";
|
|
9
|
-
|
|
10
|
-
export class FlatMapIterable<TInput,TOutput> implements Iterable<TOutput>
|
|
11
|
-
{
|
|
12
|
-
private readonly innerIterable: Iterable<TInput>;
|
|
13
|
-
private readonly mapping: (value: TInput) => JavascriptIterable<TOutput>;
|
|
14
|
-
|
|
15
|
-
private constructor(innerIterable: Iterable<TInput>, mapping: (value: TInput) => JavascriptIterable<TOutput>)
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
PreCondition.assertNotUndefinedAndNotNull(innerIterable, "innerIterable");
|
|
19
|
-
PreCondition.assertNotUndefinedAndNotNull(mapping, "mapping");
|
|
20
|
-
|
|
21
|
-
this.innerIterable = innerIterable;
|
|
22
|
-
this.mapping = mapping;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public static create<TInput,TOutput>(innerIterable: Iterable<TInput>, mapping: (value: TInput) => JavascriptIterable<TOutput>): FlatMapIterable<TInput,TOutput>
|
|
26
|
-
{
|
|
27
|
-
return new FlatMapIterable(innerIterable, mapping);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public iterate(): Iterator<TOutput>
|
|
31
|
-
{
|
|
32
|
-
return this.innerIterable.iterate().flatMap(this.mapping);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public toArray(): SyncResult<TOutput[]>
|
|
36
|
-
{
|
|
37
|
-
return Iterable.toArray<TOutput>(this);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public any(): SyncResult<boolean>
|
|
41
|
-
{
|
|
42
|
-
return Iterable.any(this);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public getCount(): SyncResult<number>
|
|
46
|
-
{
|
|
47
|
-
return Iterable.getCount(this);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public equals(right: JavascriptIterable<TOutput>, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
51
|
-
{
|
|
52
|
-
return Iterable.equals(this, right, equalFunctions);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public toString(toStringFunctions?: ToStringFunctions): string
|
|
56
|
-
{
|
|
57
|
-
return Iterable.toString(this, toStringFunctions);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public concatenate(...toConcatenate: JavascriptIterable<TOutput>[]): Iterable<TOutput>
|
|
61
|
-
{
|
|
62
|
-
return Iterable.concatenate<TOutput>(this, ...toConcatenate);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public map<TOutput2>(mapping: (value: TOutput) => TOutput2 | SyncResult<TOutput2>): Iterable<TOutput2>
|
|
66
|
-
{
|
|
67
|
-
return Iterable.map(this, mapping);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public flatMap<TOutput2>(mapping: (value: TOutput) => JavascriptIterable<TOutput2>): Iterable<TOutput2>
|
|
71
|
-
{
|
|
72
|
-
return Iterable.flatMap(this, mapping);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public where(condition: (value: TOutput) => (boolean | SyncResult<boolean>)): Iterable<TOutput>
|
|
76
|
-
{
|
|
77
|
-
return Iterable.where(this, condition);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public instanceOf<TOutput2 extends TOutput>(typeOrTypeCheck: Type<TOutput2> | ((value: TOutput2) => value is TOutput2)): Iterable<TOutput2>
|
|
81
|
-
{
|
|
82
|
-
return Iterable.instanceOf<TOutput,TOutput2>(this, typeOrTypeCheck);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public first(condition?: ((value: TOutput) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<TOutput>
|
|
86
|
-
{
|
|
87
|
-
return Iterable.first(this, condition);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public last(condition?: ((value: TOutput) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<TOutput>
|
|
91
|
-
{
|
|
92
|
-
return Iterable.last(this, condition);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public contains(value: TOutput, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
96
|
-
{
|
|
97
|
-
return Iterable.contains(this, value, equalFunctions);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public [Symbol.iterator](): JavascriptIterator<TOutput>
|
|
101
|
-
{
|
|
102
|
-
return Iterable[Symbol.iterator](this);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { JavascriptIterable, JavascriptIterator } from "./javascript";
|
|
2
|
-
import { PreCondition } from "./preCondition";
|
|
3
|
-
import { Iterator } from "./iterator";
|
|
4
|
-
import { SyncResult } from "./syncResult";
|
|
5
|
-
import { Type } from "./types";
|
|
6
|
-
|
|
7
|
-
export class FlatMapIterator<TInput,TOutput> implements Iterator<TOutput>
|
|
8
|
-
{
|
|
9
|
-
private readonly innerIterator: Iterator<TInput>;
|
|
10
|
-
private readonly mapping: (value: TInput) => JavascriptIterable<TOutput>;
|
|
11
|
-
private mappingIterator: Iterator<TOutput> | undefined;
|
|
12
|
-
private started: boolean;
|
|
13
|
-
|
|
14
|
-
private constructor(innerIterator: Iterator<TInput>, mapping: (value: TInput) => JavascriptIterable<TOutput>)
|
|
15
|
-
{
|
|
16
|
-
PreCondition.assertNotUndefinedAndNotNull(innerIterator, "innerIterator");
|
|
17
|
-
PreCondition.assertNotUndefinedAndNotNull(mapping, "mapping");
|
|
18
|
-
|
|
19
|
-
this.innerIterator = innerIterator;
|
|
20
|
-
this.mapping = mapping;
|
|
21
|
-
this.started = false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public static create<TInput,TOutput>(innerIterator: Iterator<TInput>, mapping: (value: TInput) => JavascriptIterable<TOutput>): FlatMapIterator<TInput,TOutput>
|
|
25
|
-
{
|
|
26
|
-
return new FlatMapIterator(innerIterator, mapping);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public next(): SyncResult<boolean>
|
|
30
|
-
{
|
|
31
|
-
return SyncResult.create(() =>
|
|
32
|
-
{
|
|
33
|
-
this.innerIterator.start().await();
|
|
34
|
-
|
|
35
|
-
while (this.innerIterator.hasCurrent())
|
|
36
|
-
{
|
|
37
|
-
if (this.mappingIterator === undefined)
|
|
38
|
-
{
|
|
39
|
-
this.mappingIterator = Iterator.create(this.mapping(this.innerIterator.getCurrent()));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (this.mappingIterator.next().await())
|
|
43
|
-
{
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
else if (this.innerIterator.next().await())
|
|
47
|
-
{
|
|
48
|
-
this.mappingIterator = undefined;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return this.hasCurrent();
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public hasStarted(): boolean
|
|
57
|
-
{
|
|
58
|
-
return this.started;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
public hasCurrent(): boolean
|
|
62
|
-
{
|
|
63
|
-
return this.mappingIterator?.hasCurrent() ?? false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public getCurrent(): TOutput
|
|
67
|
-
{
|
|
68
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
69
|
-
|
|
70
|
-
return this.mappingIterator!.getCurrent();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public start(): SyncResult<this>
|
|
74
|
-
{
|
|
75
|
-
return Iterator.start<TOutput,this>(this);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public takeCurrent(): SyncResult<TOutput>
|
|
79
|
-
{
|
|
80
|
-
return Iterator.takeCurrent(this);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public any(): SyncResult<boolean>
|
|
84
|
-
{
|
|
85
|
-
return Iterator.any(this);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
public getCount(): SyncResult<number>
|
|
89
|
-
{
|
|
90
|
-
return Iterator.getCount(this);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public toArray(): SyncResult<TOutput[]>
|
|
94
|
-
{
|
|
95
|
-
return Iterator.toArray(this);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
public concatenate(...toConcatenate: JavascriptIterable<TOutput>[]): Iterator<TOutput>
|
|
99
|
-
{
|
|
100
|
-
return Iterator.concatenate(this, ...toConcatenate);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
public where(condition: (value: TOutput) => (boolean | SyncResult<boolean>)): Iterator<TOutput>
|
|
104
|
-
{
|
|
105
|
-
return Iterator.where(this, condition);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public map<TOutput2>(mapping: (value: TOutput) => (TOutput2 | SyncResult<TOutput2>)): Iterator<TOutput2>
|
|
109
|
-
{
|
|
110
|
-
return Iterator.map(this, mapping);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
public flatMap<TOutput2>(mapping: (value: TOutput) => JavascriptIterable<TOutput2>): Iterator<TOutput2>
|
|
114
|
-
{
|
|
115
|
-
return Iterator.flatMap(this, mapping);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public whereInstanceOf<U extends TOutput>(typeCheck: (value: TOutput) => value is U): Iterator<U>
|
|
119
|
-
{
|
|
120
|
-
return Iterator.whereInstanceOf(this, typeCheck);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
public whereInstanceOfType<U extends TOutput>(type: Type<U>): Iterator<U>
|
|
124
|
-
{
|
|
125
|
-
return Iterator.whereInstanceOfType(this, type);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
public first(condition?: ((value: TOutput) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<TOutput>
|
|
129
|
-
{
|
|
130
|
-
return Iterator.first(this, condition);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
public last(condition?: ((value: TOutput) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<TOutput>
|
|
134
|
-
{
|
|
135
|
-
return Iterator.last(this, condition);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
public take(maximumToTake: number): Iterator<TOutput>
|
|
139
|
-
{
|
|
140
|
-
return Iterator.take(this, maximumToTake);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
public skip(maximumToSkip: number): Iterator<TOutput>
|
|
144
|
-
{
|
|
145
|
-
return Iterator.skip(this, maximumToSkip);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public [Symbol.iterator](): JavascriptIterator<TOutput>
|
|
149
|
-
{
|
|
150
|
-
return Iterator[Symbol.iterator](this);
|
|
151
|
-
}
|
|
152
|
-
}
|
package/sources/generator.ts
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import { Iterator } from "./iterator";
|
|
2
|
-
import { JavascriptIterable, JavascriptIterator } from "./javascript";
|
|
3
|
-
import { List } from "./list";
|
|
4
|
-
import { PreCondition } from "./preCondition";
|
|
5
|
-
import { SyncResult } from "./syncResult";
|
|
6
|
-
import { Type } from "./types";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A control that can be used to interact with a {@link Generator} while it is generating values.
|
|
10
|
-
*/
|
|
11
|
-
export interface GeneratorControl<T>
|
|
12
|
-
{
|
|
13
|
-
/**
|
|
14
|
-
* Add the provided value to the list of values that the {@link Generator} will return.
|
|
15
|
-
* @param value The value to add to the {@link Generator}'s list of values.
|
|
16
|
-
*/
|
|
17
|
-
addValue(value: T): void;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Add the provided values to the list of values that the {@link Generator} will return.
|
|
21
|
-
* @param returnValues The values to add to the {@link Generator}'s list of values.
|
|
22
|
-
*/
|
|
23
|
-
addValues(returnValues: JavascriptIterable<T>): void;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get whether the {@link Generator} currently has a value.
|
|
27
|
-
*/
|
|
28
|
-
hasCurrent(): boolean;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Get the current value of the {@link Generator}.
|
|
32
|
-
*/
|
|
33
|
-
getCurrent(): T;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
class InnerGeneratorControl<T> implements GeneratorControl<T>
|
|
37
|
-
{
|
|
38
|
-
private readonly returnValues: List<T>;
|
|
39
|
-
private done: boolean;
|
|
40
|
-
|
|
41
|
-
private constructor()
|
|
42
|
-
{
|
|
43
|
-
this.returnValues = List.create();
|
|
44
|
-
this.done = false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public static create<T>(): InnerGeneratorControl<T>
|
|
48
|
-
{
|
|
49
|
-
return new InnerGeneratorControl<T>();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public addValue(returnValue: T): void
|
|
53
|
-
{
|
|
54
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
55
|
-
|
|
56
|
-
this.returnValues.add(returnValue);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public addValues(returnValues: JavascriptIterable<T>): void
|
|
60
|
-
{
|
|
61
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
62
|
-
|
|
63
|
-
this.returnValues.addAll(returnValues);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public hasCurrent(): boolean
|
|
67
|
-
{
|
|
68
|
-
return this.returnValues.any().await();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public getCurrent(): T
|
|
72
|
-
{
|
|
73
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
74
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
75
|
-
|
|
76
|
-
return this.returnValues.first().await();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public removeCurrent(): void
|
|
80
|
-
{
|
|
81
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
82
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
83
|
-
|
|
84
|
-
this.returnValues.removeFirst().await();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
public setDone(): void
|
|
88
|
-
{
|
|
89
|
-
PreCondition.assertFalse(this.hasCurrent(), "this.hasCurrent()");
|
|
90
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
91
|
-
|
|
92
|
-
this.done = true;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public isDone(): boolean
|
|
96
|
-
{
|
|
97
|
-
return this.done;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export class Generator<T> implements Iterator<T>
|
|
102
|
-
{
|
|
103
|
-
private readonly control: InnerGeneratorControl<T>;
|
|
104
|
-
private readonly generatorAction: (control: GeneratorControl<T>) => (void | T);
|
|
105
|
-
private started: boolean;
|
|
106
|
-
|
|
107
|
-
private constructor(generatorAction: (control: GeneratorControl<T>) => (void | T))
|
|
108
|
-
{
|
|
109
|
-
PreCondition.assertNotUndefinedAndNotNull(generatorAction, "generatorAction");
|
|
110
|
-
|
|
111
|
-
this.control = InnerGeneratorControl.create();
|
|
112
|
-
this.generatorAction = generatorAction;
|
|
113
|
-
this.started = false;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
public static create<T>(generatorAction: (control: GeneratorControl<T>) => (void | T)): Generator<T>
|
|
117
|
-
{
|
|
118
|
-
return new Generator<T>(generatorAction);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public next(): SyncResult<boolean>
|
|
122
|
-
{
|
|
123
|
-
return SyncResult.create(() =>
|
|
124
|
-
{
|
|
125
|
-
if (!this.control.isDone())
|
|
126
|
-
{
|
|
127
|
-
if (!this.hasStarted())
|
|
128
|
-
{
|
|
129
|
-
this.started = true;
|
|
130
|
-
}
|
|
131
|
-
else
|
|
132
|
-
{
|
|
133
|
-
this.control.removeCurrent();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (!this.control.hasCurrent())
|
|
137
|
-
{
|
|
138
|
-
const actionResult: void | T = this.generatorAction(this.control);
|
|
139
|
-
if (actionResult !== undefined)
|
|
140
|
-
{
|
|
141
|
-
this.control.addValue(actionResult);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (!this.control.hasCurrent())
|
|
145
|
-
{
|
|
146
|
-
this.control.setDone();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return this.hasCurrent();
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
public hasStarted(): boolean
|
|
156
|
-
{
|
|
157
|
-
return this.started;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
public hasCurrent(): boolean
|
|
161
|
-
{
|
|
162
|
-
return this.control.hasCurrent();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
public getCurrent(): T
|
|
166
|
-
{
|
|
167
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
168
|
-
|
|
169
|
-
return this.control.getCurrent();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public start(): SyncResult<this>
|
|
173
|
-
{
|
|
174
|
-
return Iterator.start<T, this>(this);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
public takeCurrent(): SyncResult<T>
|
|
178
|
-
{
|
|
179
|
-
return Iterator.takeCurrent(this);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
public any(): SyncResult<boolean>
|
|
183
|
-
{
|
|
184
|
-
return Iterator.any(this);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
public getCount(): SyncResult<number>
|
|
188
|
-
{
|
|
189
|
-
return Iterator.getCount(this);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
public toArray(): SyncResult<T[]>
|
|
193
|
-
{
|
|
194
|
-
return Iterator.toArray(this);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
public concatenate(...toConcatenate: JavascriptIterable<T>[]): Iterator<T>
|
|
198
|
-
{
|
|
199
|
-
return Iterator.concatenate(this, ...toConcatenate);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
public where(condition: (value: T) => (boolean | SyncResult<boolean>)): Iterator<T>
|
|
203
|
-
{
|
|
204
|
-
return Iterator.where(this, condition);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
public map<TOutput>(mapping: (value: T) => TOutput | SyncResult<TOutput>): Iterator<TOutput>
|
|
208
|
-
{
|
|
209
|
-
return Iterator.map(this, mapping);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
public flatMap<TOutput>(mapping: (value: T) => JavascriptIterable<TOutput>): Iterator<TOutput>
|
|
213
|
-
{
|
|
214
|
-
return Iterator.flatMap(this, mapping);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
public whereInstanceOf<U extends T>(typeCheck: (value: T) => value is U): Iterator<U>
|
|
218
|
-
{
|
|
219
|
-
return Iterator.whereInstanceOf(this, typeCheck);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
public whereInstanceOfType<U extends T>(type: Type<U>): Iterator<U>
|
|
223
|
-
{
|
|
224
|
-
return Iterator.whereInstanceOfType(this, type);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
public first(condition?: ((value: T) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<T>
|
|
228
|
-
{
|
|
229
|
-
return Iterator.first(this, condition);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public last(condition?: ((value: T) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<T>
|
|
233
|
-
{
|
|
234
|
-
return Iterator.last(this, condition);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
public take(maximumToTake: number): Iterator<T>
|
|
238
|
-
{
|
|
239
|
-
return Iterator.take(this, maximumToTake);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
public skip(maximumToSkip: number): Iterator<T>
|
|
243
|
-
{
|
|
244
|
-
return Iterator.skip(this, maximumToSkip);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
public [Symbol.iterator](): JavascriptIterator<T>
|
|
248
|
-
{
|
|
249
|
-
return Iterator[Symbol.iterator](this);
|
|
250
|
-
}
|
|
251
|
-
}
|
package/sources/httpClient.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { FetchHttpClient } from "./fetchHttpClient";
|
|
2
|
-
import { HttpOutgoingRequest } from "./httpOutgoingRequest";
|
|
3
|
-
import { HttpIncomingResponse } from "./httpIncomingResponse";
|
|
4
|
-
import { HttpMethod } from "./httpMethod";
|
|
5
|
-
import { AsyncResult } from "./asyncResult";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* An object that can make HTTP network requests.
|
|
9
|
-
*/
|
|
10
|
-
export abstract class HttpClient
|
|
11
|
-
{
|
|
12
|
-
public static create(): HttpClient
|
|
13
|
-
{
|
|
14
|
-
return FetchHttpClient.create();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Send the provided {@link HttpOutgoingRequest}.
|
|
19
|
-
* @param request The {@link HttpOutgoingRequest} to send.
|
|
20
|
-
*/
|
|
21
|
-
public abstract sendRequest(request: HttpOutgoingRequest): AsyncResult<HttpIncomingResponse>;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Send a GET {@link HttpOutgoingRequest} to the provided URL.
|
|
25
|
-
* @param url The URL to send the GET {@link HttpOutgoingRequest} to.
|
|
26
|
-
*/
|
|
27
|
-
public sendGetRequest(url: string): AsyncResult<HttpIncomingResponse>
|
|
28
|
-
{
|
|
29
|
-
return HttpClient.sendGetRequest(this, url);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public static sendGetRequest(httpClient: HttpClient, url: string): AsyncResult<HttpIncomingResponse>
|
|
33
|
-
{
|
|
34
|
-
return httpClient.sendRequest(HttpOutgoingRequest.create(HttpMethod.GET, url));
|
|
35
|
-
}
|
|
36
|
-
}
|
package/sources/httpHeader.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { PreCondition } from "./preCondition";
|
|
2
|
-
import { escapeAndQuote } from "./strings";
|
|
3
|
-
|
|
4
|
-
export class HttpHeader
|
|
5
|
-
{
|
|
6
|
-
private readonly name: string;
|
|
7
|
-
private readonly value: string;
|
|
8
|
-
|
|
9
|
-
private constructor(name: string, value: string)
|
|
10
|
-
{
|
|
11
|
-
PreCondition.assertNotEmpty(name, "name");
|
|
12
|
-
PreCondition.assertNotUndefinedAndNotNull(value, "value");
|
|
13
|
-
|
|
14
|
-
this.name = name;
|
|
15
|
-
this.value = value;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public static create(name: string, value: string): HttpHeader
|
|
19
|
-
{
|
|
20
|
-
return new HttpHeader(name, value);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public getName(): string
|
|
24
|
-
{
|
|
25
|
-
return this.name;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public getValue(): string
|
|
29
|
-
{
|
|
30
|
-
return this.value;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public toString(): string
|
|
34
|
-
{
|
|
35
|
-
return `${escapeAndQuote(this.name)}:${escapeAndQuote(this.value)}`;
|
|
36
|
-
}
|
|
37
|
-
}
|