@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/postCondition.ts
DELETED
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { JavascriptIterable } from "./javascript";
|
|
2
|
-
import { MutableCondition } from "./mutableCondition";
|
|
3
|
-
import { PostConditionError } from "./postConditionError";
|
|
4
|
-
import { Type } from "./types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A type that encapsulates conditions that should exist before an operation takes place.
|
|
8
|
-
*/
|
|
9
|
-
export abstract class PostCondition
|
|
10
|
-
{
|
|
11
|
-
private static condition: MutableCondition | undefined;
|
|
12
|
-
|
|
13
|
-
private static getCondition(): MutableCondition
|
|
14
|
-
{
|
|
15
|
-
if (PostCondition.condition === undefined)
|
|
16
|
-
{
|
|
17
|
-
PostCondition.condition = MutableCondition.create()
|
|
18
|
-
.setCreateErrorFunction((message: string) =>
|
|
19
|
-
{
|
|
20
|
-
return new PostConditionError(message);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return PostCondition.condition;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Assert that the provided value is undefined.
|
|
28
|
-
* @param value The value to check.
|
|
29
|
-
* @param expression The name of the expression that produced the value.
|
|
30
|
-
* @param message An additional message that will be included with the error.
|
|
31
|
-
*/
|
|
32
|
-
public static assertUndefined(value: unknown, expression?: string, message?: string): asserts value is undefined
|
|
33
|
-
{
|
|
34
|
-
return PostCondition.getCondition().assertUndefined(value, expression, message);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Assert that the provided value is not undefined and not null.
|
|
39
|
-
* @param value The value to check.
|
|
40
|
-
* @param expression The name of the expression that produced the value.
|
|
41
|
-
* @param message An additional message that will be included with the error.
|
|
42
|
-
*/
|
|
43
|
-
public static assertNotUndefined<T>(value: T, expression?: string, message?: string): asserts value is NonNullable<T>
|
|
44
|
-
{
|
|
45
|
-
return PostCondition.getCondition().assertNotUndefined(value, expression, message);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Assert that the provided value is not undefined and not null.
|
|
50
|
-
* @param value The value to check.
|
|
51
|
-
* @param expression The name of the expression that produced the value.
|
|
52
|
-
* @param message An additional message that will be included with the error.
|
|
53
|
-
*/
|
|
54
|
-
public static assertNotUndefinedAndNotNull<T>(value: T, expression?: string, message?: string): asserts value is NonNullable<T>
|
|
55
|
-
{
|
|
56
|
-
return PostCondition.getCondition().assertNotUndefinedAndNotNull(value, expression, message);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Assert that the provided value is true.
|
|
61
|
-
* @param value The value to check.
|
|
62
|
-
* @param expression The name of the expression that produced the value.
|
|
63
|
-
* @param message An additional message that will be included with the error.
|
|
64
|
-
*/
|
|
65
|
-
public static assertTrue(value: boolean, expression?: string, message?: string): asserts value is true
|
|
66
|
-
{
|
|
67
|
-
return PostCondition.getCondition().assertTrue(value, expression, message);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Assert that the provided value is false.
|
|
72
|
-
* @param value The value to check.
|
|
73
|
-
* @param expression The name of the expression that produced the value.
|
|
74
|
-
* @param message An additional message that will be included with the error.
|
|
75
|
-
*/
|
|
76
|
-
public static assertFalse(value: boolean, expression?: string, message?: string): asserts value is false
|
|
77
|
-
{
|
|
78
|
-
return PostCondition.getCondition().assertFalse(value, expression, message);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Assert that the provided actual value is the same as the provided expected value.
|
|
83
|
-
* @param expected The expected value.
|
|
84
|
-
* @param actual The actual value.
|
|
85
|
-
* @param expression The expression that produced the actual value.
|
|
86
|
-
* @param message An optional message that describes the scenario.
|
|
87
|
-
*/
|
|
88
|
-
public static assertSame<T>(expected: T, actual: T, expression?: string, message?: string): void
|
|
89
|
-
{
|
|
90
|
-
return PostCondition.getCondition().assertSame(expected, actual, expression, message);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Assert that the provided actual value is not the same as the provided expected value.
|
|
95
|
-
* @param expected The expected value.
|
|
96
|
-
* @param actual The actual value.
|
|
97
|
-
* @param expression The expression that produced the actual value.
|
|
98
|
-
* @param message An optional message that describes the scenario.
|
|
99
|
-
*/
|
|
100
|
-
public static assertNotSame<T>(expected: T, actual: T, expression?: string, message?: string): void
|
|
101
|
-
{
|
|
102
|
-
return PostCondition.getCondition().assertNotSame(expected, actual, expression, message);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Assert that the provided actual value is equal to the provided expected value.
|
|
107
|
-
* @param expected The expected value.
|
|
108
|
-
* @param actual The actual value.
|
|
109
|
-
* @param expression The expression that produced the actual value.
|
|
110
|
-
* @param message An optional message that describes the scenario.
|
|
111
|
-
*/
|
|
112
|
-
public static assertEqual<T>(expected: T, actual: T, expression?: string, message?: string): void
|
|
113
|
-
{
|
|
114
|
-
return PostCondition.getCondition().assertEqual(expected, actual, expression, message);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Assert that the provided actual value is not equal to the provided expected value.
|
|
119
|
-
* @param notExpected The not expected value.
|
|
120
|
-
* @param actual The actual value.
|
|
121
|
-
* @param expression The expression that produced the actual value.
|
|
122
|
-
* @param message An optional message that describes the scenario.
|
|
123
|
-
*/
|
|
124
|
-
public static assertNotEqual<T>(notExpected: T, actual: T, expression?: string, message?: string): void
|
|
125
|
-
{
|
|
126
|
-
return PostCondition.getCondition().assertNotEqual(notExpected, actual, expression, message);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Assert that the provided value is not empty.
|
|
131
|
-
* @param value The value to check.
|
|
132
|
-
* @param expression The expression that produced the actual value.
|
|
133
|
-
* @param message An optional message that describes the scenario.
|
|
134
|
-
*/
|
|
135
|
-
public static assertNotEmpty(value: JavascriptIterable<unknown> | string | undefined | null, expression?: string, message?: string): void
|
|
136
|
-
{
|
|
137
|
-
return PostCondition.getCondition().assertNotEmpty(value, expression, message);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Assert that the provided value is less than the provided upperBound.
|
|
142
|
-
* @param value The value to check.
|
|
143
|
-
* @param upperBound The upperBound that the value must be less than.
|
|
144
|
-
* @param expression The expression that produced the actual value.
|
|
145
|
-
* @param message An optional message that describes the scenario.
|
|
146
|
-
*/
|
|
147
|
-
public static assertLessThan(value: number, upperBound: number, expression?: string, message?: string): void
|
|
148
|
-
{
|
|
149
|
-
return PostCondition.getCondition().assertLessThan(value, upperBound, expression, message);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Assert that the provided value is less than or equal to the provided upperBound.
|
|
154
|
-
* @param value The value to check.
|
|
155
|
-
* @param upperBound The upperBound that the value must be less than.
|
|
156
|
-
* @param expression The expression that produced the actual value.
|
|
157
|
-
* @param message An optional message that describes the scenario.
|
|
158
|
-
*/
|
|
159
|
-
public static assertLessThanOrEqualTo(value: number, upperBound: number, expression?: string, message?: string): void
|
|
160
|
-
{
|
|
161
|
-
return PostCondition.getCondition().assertLessThanOrEqualTo(value, upperBound, expression, message);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Assert that the provided value is greater than or equal to the provided lowerBound.
|
|
166
|
-
* @param value The value to check.
|
|
167
|
-
* @param lowerBound The lowerBound that the value must be greater than or equal to.
|
|
168
|
-
* @param expression The expression that produced the actual value.
|
|
169
|
-
* @param message An optional message that describes the scenario.
|
|
170
|
-
*/
|
|
171
|
-
public static assertGreaterThanOrEqualTo(value: number, lowerBound: number, expression?: string, message?: string): void
|
|
172
|
-
{
|
|
173
|
-
return PostCondition.getCondition().assertGreaterThanOrEqualTo(value, lowerBound, expression, message);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Assert that the provided value is greater than the provided lowerBound.
|
|
178
|
-
* @param value The value to check.
|
|
179
|
-
* @param lowerBound The lowerBound that the value must be greater than.
|
|
180
|
-
* @param expression The expression that produced the actual value.
|
|
181
|
-
* @param message An optional message that describes the scenario.
|
|
182
|
-
*/
|
|
183
|
-
public static assertGreaterThan(value: number, lowerBound: number, expression?: string, message?: string): void
|
|
184
|
-
{
|
|
185
|
-
return PostCondition.getCondition().assertGreaterThan(value, lowerBound, expression, message);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Assert that the value is greater than or equal to the lowerBound and less than or equal to
|
|
190
|
-
* the upperBound.
|
|
191
|
-
* @param lowerBound The lowerBound that the value must be greater than or equal to.
|
|
192
|
-
* @param value The value to check.
|
|
193
|
-
* @param upperBound The upperBound that the value must be less than or equal to.
|
|
194
|
-
* @param expression The expression that produced the actual value.
|
|
195
|
-
* @param message An optional message that describes the scenario.
|
|
196
|
-
*/
|
|
197
|
-
public static assertBetween(lowerBound: number, value: number, upperBound: number, expression?: string, message?: string): void
|
|
198
|
-
{
|
|
199
|
-
return PostCondition.getCondition().assertBetween(lowerBound, value, upperBound, expression, message);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Assert that the index is within the access bounds of an indexable with the provided count.
|
|
204
|
-
* @param index The index to check.
|
|
205
|
-
* @param count The number of elements in the indexable.
|
|
206
|
-
* @param expression The expression that produced the actual value.
|
|
207
|
-
* @param message An optional message that describes the scenario.
|
|
208
|
-
*/
|
|
209
|
-
public static assertAccessIndex(index: number, count: number, expression?: string, message?: string): void
|
|
210
|
-
{
|
|
211
|
-
return PostCondition.getCondition().assertAccessIndex(index, count, expression, message);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Assert that the index is within the insertion bounds of a {@link List} with the provided count.
|
|
216
|
-
* @param index The index to check.
|
|
217
|
-
* @param count The number of elements in the indexable.
|
|
218
|
-
* @param expression The expression that produced the actual value.
|
|
219
|
-
* @param message An optional message that describes the scenario.
|
|
220
|
-
*/
|
|
221
|
-
public static assertInsertIndex(index: number, count: number, expression?: string, message?: string): void
|
|
222
|
-
{
|
|
223
|
-
return PostCondition.getCondition().assertInsertIndex(index, count, expression, message);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Assert that the value is one of the possibilities.
|
|
228
|
-
* @param possibilities The possible values that the value can be.
|
|
229
|
-
* @param value The value to check.
|
|
230
|
-
* @param expression The expression that produced the value.
|
|
231
|
-
* @param message An optional error message.
|
|
232
|
-
*/
|
|
233
|
-
public static assertOneOf<T>(possibilities: JavascriptIterable<T>, value: T, expression?: string, message?: string): void
|
|
234
|
-
{
|
|
235
|
-
return PostCondition.getCondition().assertOneOf(possibilities, value, expression, message);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Assert that the value is within the bounds of a byte.
|
|
240
|
-
* @param value The value to check.
|
|
241
|
-
* @param expression The expression that produced the value.
|
|
242
|
-
* @param message An optional error message.
|
|
243
|
-
*/
|
|
244
|
-
public static assertByte(value: number, expression?: string, message?: string): void
|
|
245
|
-
{
|
|
246
|
-
return PostCondition.getCondition().assertByte(value, expression, message);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Assert that the value is an integer.
|
|
251
|
-
* @param value The value to check.
|
|
252
|
-
* @param expression The expression that produced the value.
|
|
253
|
-
* @param message An optional error message.
|
|
254
|
-
*/
|
|
255
|
-
public static assertInteger(value: number, expression?: string, message?: string): void
|
|
256
|
-
{
|
|
257
|
-
return PostCondition.getCondition().assertInteger(value, expression, message);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Assert that the value is a characer (single character string).
|
|
262
|
-
* @param value The value to check.
|
|
263
|
-
* @param expression The expression that produced the value.
|
|
264
|
-
* @param message An optional error message.
|
|
265
|
-
*/
|
|
266
|
-
public static assertCharacter(value: string, expression?: string, message?: string): void
|
|
267
|
-
{
|
|
268
|
-
return PostCondition.getCondition().assertCharacter(value, expression, message);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Assert that the provided value is an instance of the provided {@link Type}.
|
|
273
|
-
* @param value The value to check.
|
|
274
|
-
* @param type The {@link Type} to check.
|
|
275
|
-
* @param expression The expression that produced the value.
|
|
276
|
-
* @param message An optional error message.
|
|
277
|
-
*/
|
|
278
|
-
public assertInstanceOf<T>(value: unknown, type: Type<T>, typeCheck?: (value: unknown) => value is T, expression?: string, message?: string): asserts value is T;
|
|
279
|
-
public assertInstanceOf<T>(parameters: { value: unknown, type: Type<T>, typeCheck?: (value: unknown) => value is T, expression?: string, message?: string }): void;
|
|
280
|
-
assertInstanceOf<T>(parametersOrValue: unknown | { value: unknown, type: Type<T>, typeCheck?: (value: unknown) => value is T, expression?: string, message?: string }, type?: Type<T>, typeCheck?: (value: unknown) => value is T, expression?: string, message?: string): void
|
|
281
|
-
{
|
|
282
|
-
return PostCondition.getCondition().assertInstanceOf(parametersOrValue, type, typeCheck, expression, message);
|
|
283
|
-
}
|
|
284
|
-
}
|
package/sources/preCondition.ts
DELETED
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { JavascriptIterable } from "./javascript";
|
|
2
|
-
import { MutableCondition } from "./mutableCondition";
|
|
3
|
-
import { PreConditionError } from "./preConditionError";
|
|
4
|
-
import { Type } from "./types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A type that encapsulates conditions that should exist before an operation takes place.
|
|
8
|
-
*/
|
|
9
|
-
export abstract class PreCondition
|
|
10
|
-
{
|
|
11
|
-
private static condition: MutableCondition | undefined;
|
|
12
|
-
|
|
13
|
-
private static getCondition(): MutableCondition
|
|
14
|
-
{
|
|
15
|
-
if (PreCondition.condition === undefined)
|
|
16
|
-
{
|
|
17
|
-
PreCondition.condition = MutableCondition.create()
|
|
18
|
-
.setCreateErrorFunction((message: string) =>
|
|
19
|
-
{
|
|
20
|
-
return new PreConditionError(message);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return PreCondition.condition;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Assert that the provided value is undefined.
|
|
28
|
-
* @param value The value to check.
|
|
29
|
-
* @param expression The name of the expression that produced the value.
|
|
30
|
-
* @param message An additional message that will be included with the error.
|
|
31
|
-
*/
|
|
32
|
-
public static assertUndefined(value: unknown, expression?: string, message?: string): asserts value is undefined
|
|
33
|
-
{
|
|
34
|
-
return PreCondition.getCondition().assertUndefined(value, expression, message);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Assert that the provided value is not undefined and not null.
|
|
39
|
-
* @param value The value to check.
|
|
40
|
-
* @param expression The name of the expression that produced the value.
|
|
41
|
-
* @param message An additional message that will be included with the error.
|
|
42
|
-
*/
|
|
43
|
-
public static assertNotUndefined<T>(value: T, expression?: string, message?: string): asserts value is NonNullable<T>
|
|
44
|
-
{
|
|
45
|
-
return PreCondition.getCondition().assertNotUndefined(value, expression, message);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Assert that the provided value is not undefined and not null.
|
|
50
|
-
* @param value The value to check.
|
|
51
|
-
* @param expression The name of the expression that produced the value.
|
|
52
|
-
* @param message An additional message that will be included with the error.
|
|
53
|
-
*/
|
|
54
|
-
public static assertNotUndefinedAndNotNull<T>(value: T, expression?: string, message?: string): asserts value is NonNullable<T>
|
|
55
|
-
{
|
|
56
|
-
return PreCondition.getCondition().assertNotUndefinedAndNotNull(value, expression, message);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Assert that the provided value is true.
|
|
61
|
-
* @param value The value to check.
|
|
62
|
-
* @param expression The name of the expression that produced the value.
|
|
63
|
-
* @param message An additional message that will be included with the error.
|
|
64
|
-
*/
|
|
65
|
-
public static assertTrue(value: boolean, expression?: string, message?: string): asserts value is true
|
|
66
|
-
{
|
|
67
|
-
return PreCondition.getCondition().assertTrue(value, expression, message);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Assert that the provided value is false.
|
|
72
|
-
* @param value The value to check.
|
|
73
|
-
* @param expression The name of the expression that produced the value.
|
|
74
|
-
* @param message An additional message that will be included with the error.
|
|
75
|
-
*/
|
|
76
|
-
public static assertFalse(value: boolean, expression?: string, message?: string): asserts value is false
|
|
77
|
-
{
|
|
78
|
-
return PreCondition.getCondition().assertFalse(value, expression, message);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Assert that the provided actual value is the same as the provided expected value.
|
|
83
|
-
* @param expected The expected value.
|
|
84
|
-
* @param actual The actual value.
|
|
85
|
-
* @param expression The expression that produced the actual value.
|
|
86
|
-
* @param message An optional message that describes the scenario.
|
|
87
|
-
*/
|
|
88
|
-
public static assertSame<T>(expected: T, actual: T, expression?: string, message?: string): void
|
|
89
|
-
{
|
|
90
|
-
return PreCondition.getCondition().assertSame(expected, actual, expression, message);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Assert that the provided actual value is not the same as the provided expected value.
|
|
95
|
-
* @param expected The expected value.
|
|
96
|
-
* @param actual The actual value.
|
|
97
|
-
* @param expression The expression that produced the actual value.
|
|
98
|
-
* @param message An optional message that describes the scenario.
|
|
99
|
-
*/
|
|
100
|
-
public static assertNotSame<T>(expected: T, actual: T, expression?: string, message?: string): void
|
|
101
|
-
{
|
|
102
|
-
return PreCondition.getCondition().assertNotSame(expected, actual, expression, message);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Assert that the provided actual value is equal to the provided expected value.
|
|
107
|
-
* @param expected The expected value.
|
|
108
|
-
* @param actual The actual value.
|
|
109
|
-
* @param expression The expression that produced the actual value.
|
|
110
|
-
* @param message An optional message that describes the scenario.
|
|
111
|
-
*/
|
|
112
|
-
public static assertEqual<T>(expected: T, actual: T, expression?: string, message?: string): void
|
|
113
|
-
{
|
|
114
|
-
return PreCondition.getCondition().assertEqual(expected, actual, expression, message);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Assert that the provided actual value is not equal to the provided expected value.
|
|
119
|
-
* @param notExpected The not expected value.
|
|
120
|
-
* @param actual The actual value.
|
|
121
|
-
* @param expression The expression that produced the actual value.
|
|
122
|
-
* @param message An optional message that describes the scenario.
|
|
123
|
-
*/
|
|
124
|
-
public static assertNotEqual<T>(notExpected: T, actual: T, expression?: string, message?: string): void
|
|
125
|
-
{
|
|
126
|
-
return PreCondition.getCondition().assertNotEqual(notExpected, actual, expression, message);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Assert that the provided value is not empty.
|
|
131
|
-
* @param value The value to check.
|
|
132
|
-
* @param expression The expression that produced the actual value.
|
|
133
|
-
* @param message An optional message that describes the scenario.
|
|
134
|
-
*/
|
|
135
|
-
public static assertNotEmpty(value: JavascriptIterable<unknown> | string | undefined | null, expression?: string, message?: string): void
|
|
136
|
-
{
|
|
137
|
-
return PreCondition.getCondition().assertNotEmpty(value, expression, message);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Assert that the provided value is less than the provided upperBound.
|
|
142
|
-
* @param value The value to check.
|
|
143
|
-
* @param upperBound The upperBound that the value must be less than.
|
|
144
|
-
* @param expression The expression that produced the actual value.
|
|
145
|
-
* @param message An optional message that describes the scenario.
|
|
146
|
-
*/
|
|
147
|
-
public static assertLessThan(value: number, upperBound: number, expression?: string, message?: string): void
|
|
148
|
-
{
|
|
149
|
-
return PreCondition.getCondition().assertLessThan(value, upperBound, expression, message);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Assert that the provided value is less than or equal to the provided upperBound.
|
|
154
|
-
* @param value The value to check.
|
|
155
|
-
* @param upperBound The upperBound that the value must be less than.
|
|
156
|
-
* @param expression The expression that produced the actual value.
|
|
157
|
-
* @param message An optional message that describes the scenario.
|
|
158
|
-
*/
|
|
159
|
-
public static assertLessThanOrEqualTo(value: number, upperBound: number, expression?: string, message?: string): void
|
|
160
|
-
{
|
|
161
|
-
return PreCondition.getCondition().assertLessThanOrEqualTo(value, upperBound, expression, message);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Assert that the provided value is greater than or equal to the provided lowerBound.
|
|
166
|
-
* @param value The value to check.
|
|
167
|
-
* @param lowerBound The lowerBound that the value must be greater than or equal to.
|
|
168
|
-
* @param expression The expression that produced the actual value.
|
|
169
|
-
* @param message An optional message that describes the scenario.
|
|
170
|
-
*/
|
|
171
|
-
public static assertGreaterThanOrEqualTo(value: number, lowerBound: number, expression?: string, message?: string): void
|
|
172
|
-
{
|
|
173
|
-
return PreCondition.getCondition().assertGreaterThanOrEqualTo(value, lowerBound, expression, message);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Assert that the provided value is greater than the provided lowerBound.
|
|
178
|
-
* @param value The value to check.
|
|
179
|
-
* @param lowerBound The lowerBound that the value must be greater than.
|
|
180
|
-
* @param expression The expression that produced the actual value.
|
|
181
|
-
* @param message An optional message that describes the scenario.
|
|
182
|
-
*/
|
|
183
|
-
public static assertGreaterThan(value: number, lowerBound: number, expression?: string, message?: string): void
|
|
184
|
-
{
|
|
185
|
-
return PreCondition.getCondition().assertGreaterThan(value, lowerBound, expression, message);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Assert that the value is greater than or equal to the lowerBound and less than or equal to
|
|
190
|
-
* the upperBound.
|
|
191
|
-
* @param lowerBound The lowerBound that the value must be greater than or equal to.
|
|
192
|
-
* @param value The value to check.
|
|
193
|
-
* @param upperBound The upperBound that the value must be less than or equal to.
|
|
194
|
-
* @param expression The expression that produced the actual value.
|
|
195
|
-
* @param message An optional message that describes the scenario.
|
|
196
|
-
*/
|
|
197
|
-
public static assertBetween(lowerBound: number, value: number, upperBound: number, expression?: string, message?: string): void
|
|
198
|
-
{
|
|
199
|
-
return PreCondition.getCondition().assertBetween(lowerBound, value, upperBound, expression, message);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Assert that the index is within the access bounds of an indexable with the provided count.
|
|
204
|
-
* @param index The index to check.
|
|
205
|
-
* @param count The number of elements in the indexable.
|
|
206
|
-
* @param expression The expression that produced the actual value.
|
|
207
|
-
* @param message An optional message that describes the scenario.
|
|
208
|
-
*/
|
|
209
|
-
public static assertAccessIndex(index: number, count: number, expression?: string, message?: string): void
|
|
210
|
-
{
|
|
211
|
-
return PreCondition.getCondition().assertAccessIndex(index, count, expression, message);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Assert that the index is within the insertion bounds of a {@link List} with the provided count.
|
|
216
|
-
* @param index The index to check.
|
|
217
|
-
* @param count The number of elements in the indexable.
|
|
218
|
-
* @param expression The expression that produced the actual value.
|
|
219
|
-
* @param message An optional message that describes the scenario.
|
|
220
|
-
*/
|
|
221
|
-
public static assertInsertIndex(index: number, count: number, expression?: string, message?: string): void
|
|
222
|
-
{
|
|
223
|
-
return PreCondition.getCondition().assertInsertIndex(index, count, expression, message);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Assert that the value is one of the possibilities.
|
|
228
|
-
* @param possibilities The possible values that the value can be.
|
|
229
|
-
* @param value The value to check.
|
|
230
|
-
* @param expression The expression that produced the value.
|
|
231
|
-
* @param message An optional error message.
|
|
232
|
-
*/
|
|
233
|
-
public static assertOneOf<T>(possibilities: JavascriptIterable<T>, value: T, expression?: string, message?: string): void
|
|
234
|
-
{
|
|
235
|
-
return PreCondition.getCondition().assertOneOf(possibilities, value, expression, message);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Assert that the value is within the bounds of a byte.
|
|
240
|
-
* @param value The value to check.
|
|
241
|
-
* @param expression The expression that produced the value.
|
|
242
|
-
* @param message An optional error message.
|
|
243
|
-
*/
|
|
244
|
-
public static assertByte(value: number, expression?: string, message?: string): void
|
|
245
|
-
{
|
|
246
|
-
return PreCondition.getCondition().assertByte(value, expression, message);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Assert that the value is an integer.
|
|
251
|
-
* @param value The value to check.
|
|
252
|
-
* @param expression The expression that produced the value.
|
|
253
|
-
* @param message An optional error message.
|
|
254
|
-
*/
|
|
255
|
-
public static assertInteger(value: number, expression?: string, message?: string): void
|
|
256
|
-
{
|
|
257
|
-
return PreCondition.getCondition().assertInteger(value, expression, message);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Assert that the value is a characer (single character string).
|
|
262
|
-
* @param value The value to check.
|
|
263
|
-
* @param expression The expression that produced the value.
|
|
264
|
-
* @param message An optional error message.
|
|
265
|
-
*/
|
|
266
|
-
public static assertCharacter(value: string, expression?: string, message?: string): void
|
|
267
|
-
{
|
|
268
|
-
return PreCondition.getCondition().assertCharacter(value, expression, message);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Assert that the provided value is an instance of the provided {@link Type}.
|
|
273
|
-
* @param value The value to check.
|
|
274
|
-
* @param type The {@link Type} to check.
|
|
275
|
-
* @param expression The expression that produced the value.
|
|
276
|
-
* @param message An optional error message.
|
|
277
|
-
*/
|
|
278
|
-
public assertInstanceOf<T>(value: unknown, type: Type<T>, typeCheck?: (value: unknown) => value is T, expression?: string, message?: string): asserts value is T;
|
|
279
|
-
public assertInstanceOf<T>(parameters: { value: unknown, type: Type<T>, typeCheck?: (value: unknown) => value is T, expression?: string, message?: string }): void;
|
|
280
|
-
assertInstanceOf<T>(parametersOrValue: unknown | { value: unknown, type: Type<T>, typeCheck?: (value: unknown) => value is T, expression?: string, message?: string }, type?: Type<T>, typeCheck?: (value: unknown) => value is T, expression?: string, message?: string): void
|
|
281
|
-
{
|
|
282
|
-
return PreCondition.getCondition().assertInstanceOf(parametersOrValue, type, typeCheck, expression, message);
|
|
283
|
-
}
|
|
284
|
-
}
|