@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/condition.ts
DELETED
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
import { Bytes } from "./bytes";
|
|
2
|
-
import { JavascriptIterable } from "./javascript";
|
|
3
|
-
import { MutableCondition } from "./mutableCondition";
|
|
4
|
-
import { Type } from "./types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A collection of condition methods that can be used to assert the state of an application.
|
|
8
|
-
*/
|
|
9
|
-
export abstract class Condition
|
|
10
|
-
{
|
|
11
|
-
protected constructor()
|
|
12
|
-
{
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Create a new {@link MutableCondition} object.
|
|
17
|
-
*/
|
|
18
|
-
public static create(): MutableCondition
|
|
19
|
-
{
|
|
20
|
-
return MutableCondition.create();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Assert that the provided value is undefined.
|
|
25
|
-
* @param value The value to check.
|
|
26
|
-
* @param expression The name of the expression that produced the value.
|
|
27
|
-
* @param message An additional message that will be included with the error.
|
|
28
|
-
*/
|
|
29
|
-
public assertUndefined(value: unknown, expression?: string, message?: string): asserts value is undefined
|
|
30
|
-
{
|
|
31
|
-
Condition.assertUndefined(this, value, expression, message);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Assert that the provided value is undefined.
|
|
36
|
-
* @param value The value to check.
|
|
37
|
-
* @param expression The name of the expression that produced the value.
|
|
38
|
-
* @param message An additional message that will be included with the error.
|
|
39
|
-
*/
|
|
40
|
-
public static assertUndefined(condition: Condition, value: unknown, expression?: string, message?: string): asserts value is undefined
|
|
41
|
-
{
|
|
42
|
-
condition.assertSame(undefined, value, expression, message);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Assert that the provided value is not undefined and not null.
|
|
47
|
-
* @param value The value to check.
|
|
48
|
-
* @param expression The name of the expression that produced the value.
|
|
49
|
-
* @param message An additional message that will be included with the error.
|
|
50
|
-
*/
|
|
51
|
-
public assertNotUndefined<T>(value: T, expression?: string, message?: string): asserts value is NonNullable<T>
|
|
52
|
-
{
|
|
53
|
-
Condition.assertNotUndefined(this, value, expression, message);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Assert that the provided value is not undefined and not null.
|
|
58
|
-
* @param value The value to check.
|
|
59
|
-
* @param expression The name of the expression that produced the value.
|
|
60
|
-
* @param message An additional message that will be included with the error.
|
|
61
|
-
*/
|
|
62
|
-
public static assertNotUndefined<T>(condition: Condition, value: T, expression?: string, message?: string): asserts value is NonNullable<T>
|
|
63
|
-
{
|
|
64
|
-
condition.assertNotSame(undefined, value, expression, message);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Assert that the provided value is not undefined and not null.
|
|
69
|
-
* @param value The value to check.
|
|
70
|
-
* @param expression The name of the expression that produced the value.
|
|
71
|
-
* @param message An additional message that will be included with the error.
|
|
72
|
-
*/
|
|
73
|
-
public assertNotUndefinedAndNotNull<T>(value: T, expression?: string, message?: string): asserts value is NonNullable<T>
|
|
74
|
-
{
|
|
75
|
-
Condition.assertNotUndefinedAndNotNull(this, value, expression, message);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Assert that the provided value is not undefined and not null.
|
|
80
|
-
* @param value The value to check.
|
|
81
|
-
* @param expression The name of the expression that produced the value.
|
|
82
|
-
* @param message An additional message that will be included with the error.
|
|
83
|
-
*/
|
|
84
|
-
public static assertNotUndefinedAndNotNull<T>(condition: Condition, value: T, expression?: string, message?: string): asserts value is NonNullable<T>
|
|
85
|
-
{
|
|
86
|
-
condition.assertNotSame(undefined, value, expression, message);
|
|
87
|
-
condition.assertNotSame(null, value, expression, message);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Assert that the provided value is true.
|
|
92
|
-
* @param value The value to check.
|
|
93
|
-
* @param expression The name of the expression that produced the value.
|
|
94
|
-
* @param message An additional message that will be included with the error.
|
|
95
|
-
*/
|
|
96
|
-
public assertTrue(value: boolean, expression?: string, message?: string): asserts value is true
|
|
97
|
-
{
|
|
98
|
-
Condition.assertTrue(this, value, expression, message);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Assert that the provided value is true.
|
|
103
|
-
* @param value The value to check.
|
|
104
|
-
* @param expression The name of the expression that produced the value.
|
|
105
|
-
* @param message An additional message that will be included with the error.
|
|
106
|
-
*/
|
|
107
|
-
public static assertTrue(condition: Condition, value: boolean, expression?: string, message?: string): asserts value is true
|
|
108
|
-
{
|
|
109
|
-
condition.assertSame(true, value, expression, message);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Assert that the provided value is false.
|
|
114
|
-
* @param value The value to check.
|
|
115
|
-
* @param expression The name of the expression that produced the value.
|
|
116
|
-
* @param message An additional message that will be included with the error.
|
|
117
|
-
*/
|
|
118
|
-
public assertFalse(value: boolean, expression?: string, message?: string): asserts value is false
|
|
119
|
-
{
|
|
120
|
-
Condition.assertFalse(this, value, expression, message);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Assert that the provided value is false.
|
|
125
|
-
* @param value The value to check.
|
|
126
|
-
* @param expression The name of the expression that produced the value.
|
|
127
|
-
* @param message An additional message that will be included with the error.
|
|
128
|
-
*/
|
|
129
|
-
public static assertFalse(condition: Condition, value: boolean, expression?: string, message?: string): asserts value is false
|
|
130
|
-
{
|
|
131
|
-
condition.assertSame(false, value, expression, message);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Assert that the provided actual value is the same as the provided expected value.
|
|
136
|
-
* @param expected The expected value.
|
|
137
|
-
* @param actual The actual value.
|
|
138
|
-
* @param expression The expression that produced the actual value.
|
|
139
|
-
* @param message An optional message that describes the scenario.
|
|
140
|
-
*/
|
|
141
|
-
public abstract assertSame<T>(expected: T, actual: T, expression?: string, message?: string): void;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Assert that the provided actual value is not the same as the provided expected value.
|
|
145
|
-
* @param expected The expected value.
|
|
146
|
-
* @param actual The actual value.
|
|
147
|
-
* @param expression The expression that produced the actual value.
|
|
148
|
-
* @param message An optional message that describes the scenario.
|
|
149
|
-
*/
|
|
150
|
-
public abstract assertNotSame<T>(expected: T, actual: T, expression?: string, message?: string): void;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Assert that the provided actual value is equal to the provided expected value.
|
|
154
|
-
* @param expected The expected value.
|
|
155
|
-
* @param actual The actual value.
|
|
156
|
-
* @param expression The expression that produced the actual value.
|
|
157
|
-
* @param message An optional message that describes the scenario.
|
|
158
|
-
*/
|
|
159
|
-
public abstract assertEqual<T>(expected: T, actual: T, expression?: string, message?: string): void;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Assert that the provided actual value is not equal to the provided expected value.
|
|
163
|
-
* @param notExpected The not expected value.
|
|
164
|
-
* @param actual The actual value.
|
|
165
|
-
* @param expression The expression that produced the actual value.
|
|
166
|
-
* @param message An optional message that describes the scenario.
|
|
167
|
-
*/
|
|
168
|
-
public abstract assertNotEqual<T>(notExpected: T, actual: T, expression?: string, message?: string): void;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Assert that the provided value is not empty.
|
|
172
|
-
* @param value The value to check.
|
|
173
|
-
* @param expression The expression that produced the actual value.
|
|
174
|
-
* @param message An optional message that describes the scenario.
|
|
175
|
-
*/
|
|
176
|
-
public abstract assertNotEmpty(value: JavascriptIterable<unknown> | string | undefined | null, expression?: string, message?: string): void;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Assert that the provided value is less than the provided upperBound.
|
|
180
|
-
* @param value The value to check.
|
|
181
|
-
* @param upperBound The upperBound that the value must be less than.
|
|
182
|
-
* @param expression The expression that produced the actual value.
|
|
183
|
-
* @param message An optional message that describes the scenario.
|
|
184
|
-
*/
|
|
185
|
-
public abstract assertLessThan(value: number, upperBound: number, expression?: string, message?: string): void;
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Assert that the provided value is less than or equal to the provided upperBound.
|
|
189
|
-
* @param value The value to check.
|
|
190
|
-
* @param upperBound The upperBound that the value must be less than.
|
|
191
|
-
* @param expression The expression that produced the actual value.
|
|
192
|
-
* @param message An optional message that describes the scenario.
|
|
193
|
-
*/
|
|
194
|
-
public abstract assertLessThanOrEqualTo(value: number, upperBound: number, expression?: string, message?: string): void;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Assert that the provided value is greater than or equal to the provided lowerBound.
|
|
198
|
-
* @param value The value to check.
|
|
199
|
-
* @param lowerBound The lowerBound that the value must be greater than or equal to.
|
|
200
|
-
* @param expression The expression that produced the actual value.
|
|
201
|
-
* @param message An optional message that describes the scenario.
|
|
202
|
-
*/
|
|
203
|
-
public abstract assertGreaterThanOrEqualTo(value: number, lowerBound: number, expression?: string, message?: string): void;
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Assert that the provided value is greater than the provided lowerBound.
|
|
207
|
-
* @param value The value to check.
|
|
208
|
-
* @param lowerBound The lowerBound that the value must be greater than.
|
|
209
|
-
* @param expression The expression that produced the actual value.
|
|
210
|
-
* @param message An optional message that describes the scenario.
|
|
211
|
-
*/
|
|
212
|
-
public abstract assertGreaterThan(value: number, lowerBound: number, expression?: string, message?: string): void;
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Assert that the value is greater than or equal to the lowerBound and less than or equal to
|
|
216
|
-
* the upperBound.
|
|
217
|
-
* @param lowerBound The lowerBound that the value must be greater than or equal to.
|
|
218
|
-
* @param value The value to check.
|
|
219
|
-
* @param upperBound The upperBound that the value must be less than or equal to.
|
|
220
|
-
* @param expression The expression that produced the actual value.
|
|
221
|
-
* @param message An optional message that describes the scenario.
|
|
222
|
-
*/
|
|
223
|
-
public abstract assertBetween(lowerBound: number, value: number, upperBound: number, expression?: string, message?: string): void;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Assert that the index is within the access bounds of an indexable with the provided count.
|
|
227
|
-
* @param index The index to check.
|
|
228
|
-
* @param count The number of elements in the indexable.
|
|
229
|
-
* @param expression The expression that produced the actual value.
|
|
230
|
-
* @param message An optional message that describes the scenario.
|
|
231
|
-
*/
|
|
232
|
-
public assertAccessIndex(index: number, count: number, expression?: string, message?: string): void
|
|
233
|
-
{
|
|
234
|
-
Condition.assertAccessIndex(this, index, count, expression, message);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Assert that the index is within the access bounds of an indexable with the provided count.
|
|
239
|
-
* @param index The index to check.
|
|
240
|
-
* @param count The number of elements in the indexable.
|
|
241
|
-
* @param expression The expression that produced the actual value.
|
|
242
|
-
* @param message An optional message that describes the scenario.
|
|
243
|
-
*/
|
|
244
|
-
public static assertAccessIndex(condition: Condition, index: number, count: number, expression?: string, message?: string): void
|
|
245
|
-
{
|
|
246
|
-
condition.assertBetween(0, index, count - 1, expression, message);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Assert that the index is within the insertion bounds of a {@link List} with the provided count.
|
|
251
|
-
* @param index The index to check.
|
|
252
|
-
* @param count The number of elements in the indexable.
|
|
253
|
-
* @param expression The expression that produced the actual value.
|
|
254
|
-
* @param message An optional message that describes the scenario.
|
|
255
|
-
*/
|
|
256
|
-
public assertInsertIndex(index: number, count: number, expression?: string, message?: string): void
|
|
257
|
-
{
|
|
258
|
-
Condition.assertInsertIndex(this, index, count, expression, message);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Assert that the index is within the insertion bounds of a {@link List} with the provided count.
|
|
263
|
-
* @param index The index to check.
|
|
264
|
-
* @param count The number of elements in the indexable.
|
|
265
|
-
* @param expression The expression that produced the actual value.
|
|
266
|
-
* @param message An optional message that describes the scenario.
|
|
267
|
-
*/
|
|
268
|
-
public static assertInsertIndex(condition: Condition, index: number, count: number, expression?: string, message?: string): void
|
|
269
|
-
{
|
|
270
|
-
condition.assertBetween(0, index, count, expression, message);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Assert that the value is one of the possibilities.
|
|
275
|
-
* @param possibilities The possible values that the value can be.
|
|
276
|
-
* @param value The value to check.
|
|
277
|
-
* @param expression The expression that produced the value.
|
|
278
|
-
* @param message An optional error message.
|
|
279
|
-
*/
|
|
280
|
-
public abstract assertOneOf<T>(possibilities: JavascriptIterable<T>, value: T, expression?: string, message?: string): void;
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Assert that the value is within the bounds of a byte.
|
|
284
|
-
* @param value The value to check.
|
|
285
|
-
* @param expression The expression that produced the value.
|
|
286
|
-
* @param message An optional error message.
|
|
287
|
-
*/
|
|
288
|
-
public assertByte(value: number, expression?: string, message?: string): void
|
|
289
|
-
{
|
|
290
|
-
Condition.assertByte(this, value, expression, message);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Assert that the value is within the bounds of a byte.
|
|
295
|
-
* @param value The value to check.
|
|
296
|
-
* @param expression The expression that produced the value.
|
|
297
|
-
* @param message An optional error message.
|
|
298
|
-
*/
|
|
299
|
-
public static assertByte(condition: Condition, value: number, expression?: string, message?: string): void
|
|
300
|
-
{
|
|
301
|
-
condition.assertBetween(Bytes.minimumValue, value, Bytes.maximumValue, expression, message);
|
|
302
|
-
condition.assertInteger(value, expression, message);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Assert that the value is an integer.
|
|
307
|
-
* @param value The value to check.
|
|
308
|
-
* @param expression The expression that produced the value.
|
|
309
|
-
* @param message An optional error message.
|
|
310
|
-
*/
|
|
311
|
-
public abstract assertInteger(value: number, expression?: string, message?: string): void;
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Assert that the provided value is an instance of the provided {@link Type}.
|
|
315
|
-
* @param value The value to check.
|
|
316
|
-
* @param type The {@link Type} to check.
|
|
317
|
-
* @param expression The expression that produced the value.
|
|
318
|
-
* @param message An optional error message.
|
|
319
|
-
*/
|
|
320
|
-
public abstract assertInstanceOf<T>(value: unknown, type: Type<T>, typeCheck?: (value: unknown) => value is T, expression?: string, message?: string): asserts value is T;
|
|
321
|
-
/**
|
|
322
|
-
* Assert that the provided value is an instance of the provided {@link Type}.
|
|
323
|
-
* @param value The value to check.
|
|
324
|
-
* @param type The {@link Type} to check.
|
|
325
|
-
* @param expression The expression that produced the value.
|
|
326
|
-
* @param message An optional error message.
|
|
327
|
-
*/
|
|
328
|
-
public abstract assertInstanceOf<T>(parameters: { value: unknown, type: Type<T>, typeCheck?: (value: unknown) => value is T, expression?: string, message?: string }): void;
|
|
329
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { CharacterWriteStream } from "./characterWriteStream";
|
|
2
|
-
import { CommandLineParameters } from "./commandLineParameters";
|
|
3
|
-
import { JavascriptIterable } from "./javascript";
|
|
4
|
-
import { Network } from "./network";
|
|
5
|
-
import { NodeJSCharacterWriteStream } from "./nodeJSCharacterWriteStream";
|
|
6
|
-
import { PreCondition } from "./preCondition";
|
|
7
|
-
import { Property } from "./property";
|
|
8
|
-
import { RealNetwork } from "./realNetwork";
|
|
9
|
-
import { isNumber } from "./types";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* An object that provides all of the resources that are available to the current process.
|
|
13
|
-
*/
|
|
14
|
-
export class CurrentProcess
|
|
15
|
-
{
|
|
16
|
-
private args: JavascriptIterable<string> | undefined
|
|
17
|
-
private parameters: CommandLineParameters | undefined;
|
|
18
|
-
private outputWriteStream: CharacterWriteStream | undefined;
|
|
19
|
-
private exitCodeProperty: Property<number> | undefined;
|
|
20
|
-
private network: Network | undefined;
|
|
21
|
-
|
|
22
|
-
private constructor()
|
|
23
|
-
{
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public static create(): CurrentProcess
|
|
27
|
-
{
|
|
28
|
-
return new CurrentProcess();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public static async run(action: (currentProcess: CurrentProcess) => void | number | Promise<void | number>): Promise<void>
|
|
32
|
-
{
|
|
33
|
-
PreCondition.assertNotUndefinedAndNotNull(action, "action");
|
|
34
|
-
|
|
35
|
-
const currentProcess: CurrentProcess = CurrentProcess.create();
|
|
36
|
-
try
|
|
37
|
-
{
|
|
38
|
-
const result: void | number = await action(currentProcess);
|
|
39
|
-
if (isNumber(result))
|
|
40
|
-
{
|
|
41
|
-
currentProcess.setExitCode(result);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch (error)
|
|
45
|
-
{
|
|
46
|
-
currentProcess.setExitCode(-1);
|
|
47
|
-
const writeStream: CharacterWriteStream = currentProcess.getOutputWriteStream();
|
|
48
|
-
if (error instanceof Error && error.stack)
|
|
49
|
-
{
|
|
50
|
-
writeStream.writeLine(error.stack);
|
|
51
|
-
}
|
|
52
|
-
else
|
|
53
|
-
{
|
|
54
|
-
writeStream.writeLine(`${error}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public getArguments(): JavascriptIterable<string>
|
|
60
|
-
{
|
|
61
|
-
if (!this.args)
|
|
62
|
-
{
|
|
63
|
-
this.args = process.argv;
|
|
64
|
-
}
|
|
65
|
-
return this.args;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public setArguments(args: JavascriptIterable<string>): this
|
|
69
|
-
{
|
|
70
|
-
PreCondition.assertNotUndefinedAndNotNull(args, "args");
|
|
71
|
-
PreCondition.assertUndefined(this.parameters, "this.parameters");
|
|
72
|
-
|
|
73
|
-
this.args = args;
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public getParameters(): CommandLineParameters
|
|
78
|
-
{
|
|
79
|
-
if (!this.parameters)
|
|
80
|
-
{
|
|
81
|
-
this.parameters = CommandLineParameters.create(this.getArguments());
|
|
82
|
-
}
|
|
83
|
-
return this.parameters;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public getOutputWriteStream(): CharacterWriteStream
|
|
87
|
-
{
|
|
88
|
-
if (!this.outputWriteStream)
|
|
89
|
-
{
|
|
90
|
-
this.outputWriteStream = NodeJSCharacterWriteStream.create(process.stdout);
|
|
91
|
-
}
|
|
92
|
-
return this.outputWriteStream;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public setOutputWriteStream(outputWriteStream: CharacterWriteStream): this
|
|
96
|
-
{
|
|
97
|
-
PreCondition.assertNotUndefinedAndNotNull(outputWriteStream, "outputWriteStream");
|
|
98
|
-
|
|
99
|
-
this.outputWriteStream = outputWriteStream;
|
|
100
|
-
|
|
101
|
-
return this;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public getExitCode(): number
|
|
105
|
-
{
|
|
106
|
-
return this.getExitCodeProperty().getValue();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
public setExitCode(exitCode: number): this
|
|
110
|
-
{
|
|
111
|
-
PreCondition.assertNotUndefinedAndNotNull(exitCode, "exitCode");
|
|
112
|
-
|
|
113
|
-
this.getExitCodeProperty().setValue(exitCode);
|
|
114
|
-
|
|
115
|
-
return this;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public getExitCodeProperty(): Property<number>
|
|
119
|
-
{
|
|
120
|
-
if (!this.exitCodeProperty)
|
|
121
|
-
{
|
|
122
|
-
this.exitCodeProperty = Property.create({
|
|
123
|
-
getter: () => process.exitCode as number,
|
|
124
|
-
setter: (value: number) => { process.exitCode = value; },
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
return this.exitCodeProperty;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
public setExitCodeProperty(exitCodeProperty: Property<number>): this
|
|
131
|
-
{
|
|
132
|
-
PreCondition.assertNotUndefinedAndNotNull(exitCodeProperty, "exitCodeProperty");
|
|
133
|
-
|
|
134
|
-
this.exitCodeProperty = exitCodeProperty;
|
|
135
|
-
|
|
136
|
-
return this;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
public getNetwork(): Network
|
|
140
|
-
{
|
|
141
|
-
if (!this.network)
|
|
142
|
-
{
|
|
143
|
-
this.network = RealNetwork.create();
|
|
144
|
-
}
|
|
145
|
-
return this.network;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public setNetwork(network: Network): this
|
|
149
|
-
{
|
|
150
|
-
PreCondition.assertUndefined(this.network, "this.network");
|
|
151
|
-
PreCondition.assertNotUndefinedAndNotNull(network, "network");
|
|
152
|
-
|
|
153
|
-
this.network = network;
|
|
154
|
-
|
|
155
|
-
return this;
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
}
|
package/sources/dateTime.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { LuxonDateTime } from "./luxonDateTime";
|
|
2
|
-
|
|
3
|
-
export abstract class DateTime
|
|
4
|
-
{
|
|
5
|
-
public static parse(text: string): DateTime
|
|
6
|
-
{
|
|
7
|
-
return LuxonDateTime.parse(text);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public static now(): DateTime
|
|
11
|
-
{
|
|
12
|
-
return LuxonDateTime.now();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public abstract getYear(): number;
|
|
16
|
-
|
|
17
|
-
public abstract getMonth(): number;
|
|
18
|
-
|
|
19
|
-
public abstract getDay(): number;
|
|
20
|
-
|
|
21
|
-
public abstract getHour(): number;
|
|
22
|
-
|
|
23
|
-
public abstract getMinute(): number;
|
|
24
|
-
|
|
25
|
-
public abstract getSecond(): number;
|
|
26
|
-
|
|
27
|
-
public abstract addDays(days: number): DateTime;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Compare this {@link DateTime} to the provided {@link DateTime}. If this {@link DateTime} is
|
|
31
|
-
* less than the provided {@link DateTime}, then a negative number will be returned, 0 if
|
|
32
|
-
* they're equal, or a positive number if this {@link DateTime} is greater than the provided
|
|
33
|
-
* {@link DateTime}.
|
|
34
|
-
* @param dateTime The {@link DateTime} to compare to this {@link DateTime}.
|
|
35
|
-
*/
|
|
36
|
-
public compareTo(dateTime: DateTime, compareTimes: boolean): number
|
|
37
|
-
{
|
|
38
|
-
return DateTime.compareTo(this, dateTime, compareTimes);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public static compareTo(left: DateTime, right: DateTime, compareTimes: boolean): number
|
|
42
|
-
{
|
|
43
|
-
let result: number = left.getYear() - right.getYear();
|
|
44
|
-
if (result === 0)
|
|
45
|
-
{
|
|
46
|
-
result = left.getMonth() - right.getMonth();
|
|
47
|
-
if (result === 0)
|
|
48
|
-
{
|
|
49
|
-
result = left.getDay() - right.getDay();
|
|
50
|
-
if (compareTimes && result === 0)
|
|
51
|
-
{
|
|
52
|
-
result = left.getHour() - right.getHour();
|
|
53
|
-
if (result === 0)
|
|
54
|
-
{
|
|
55
|
-
result = left.getMinute() - right.getMinute();
|
|
56
|
-
if (result === 0)
|
|
57
|
-
{
|
|
58
|
-
result = left.getSecond(); - right.getSecond();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return result;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
public lessThan(dateTime: DateTime, compareTimes: boolean): boolean
|
|
68
|
-
{
|
|
69
|
-
return DateTime.lessThan(this, dateTime, compareTimes);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public static lessThan(left: DateTime, right: DateTime, compareTimes: boolean): boolean
|
|
73
|
-
{
|
|
74
|
-
return left.compareTo(right, compareTimes) < 0;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public lessThanOrEqualTo(dateTime: DateTime, compareTimes: boolean): boolean
|
|
78
|
-
{
|
|
79
|
-
return DateTime.lessThanOrEqualTo(this, dateTime, compareTimes);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
public static lessThanOrEqualTo(left: DateTime, right: DateTime, compareTimes: boolean): boolean
|
|
83
|
-
{
|
|
84
|
-
return left.compareTo(right, compareTimes) <= 0;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
public equals(dateTime: DateTime, compareTimes: boolean): boolean
|
|
88
|
-
{
|
|
89
|
-
return DateTime.equals(this, dateTime, compareTimes);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
public static equals(left: DateTime, right: DateTime, compareTimes: boolean): boolean
|
|
93
|
-
{
|
|
94
|
-
return left.compareTo(right, compareTimes) === 0;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
public greaterThanOrEqualTo(dateTime: DateTime, compareTimes: boolean): boolean
|
|
98
|
-
{
|
|
99
|
-
return DateTime.greaterThanOrEqualTo(this, dateTime, compareTimes);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
public static greaterThanOrEqualTo(left: DateTime, right: DateTime, compareTimes: boolean): boolean
|
|
103
|
-
{
|
|
104
|
-
return left.compareTo(right, compareTimes) >= 0;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public greaterThan(dateTime: DateTime, compareTimes: boolean): boolean
|
|
108
|
-
{
|
|
109
|
-
return DateTime.greaterThan(this, dateTime, compareTimes);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
public static greaterThan(left: DateTime, right: DateTime, compareTimes: boolean): boolean
|
|
113
|
-
{
|
|
114
|
-
return left.compareTo(right, compareTimes) > 0;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
public get debug(): string
|
|
118
|
-
{
|
|
119
|
-
return DateTime.debug(this);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public static debug(dateTime: DateTime): string
|
|
123
|
-
{
|
|
124
|
-
return dateTime.toString();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public abstract toString(): string;
|
|
128
|
-
|
|
129
|
-
public abstract toDateString(): string;
|
|
130
|
-
}
|