@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.
Files changed (176) hide show
  1. package/outputs/chunk-AY3YWKOM.js +7741 -0
  2. package/outputs/chunk-AY3YWKOM.js.map +1 -0
  3. package/outputs/sources.cjs +9007 -0
  4. package/outputs/sources.cjs.map +1 -0
  5. package/outputs/sources.d.cts +4082 -0
  6. package/outputs/sources.d.ts +4082 -0
  7. package/outputs/sources.js +1370 -0
  8. package/outputs/sources.js.map +1 -0
  9. package/outputs/tests.cjs +17208 -0
  10. package/outputs/tests.cjs.map +1 -0
  11. package/outputs/tests.d.cts +3 -0
  12. package/outputs/tests.d.ts +3 -0
  13. package/outputs/tests.js +9798 -0
  14. package/outputs/tests.js.map +1 -0
  15. package/package.json +11 -2
  16. package/.c8rc.json +0 -12
  17. package/.github/workflows/publish.yml +0 -36
  18. package/.mocharc.json +0 -9
  19. package/sources/assertMessageParameters.ts +0 -22
  20. package/sources/asyncIterator.ts +0 -437
  21. package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +0 -48
  22. package/sources/asyncResult.ts +0 -95
  23. package/sources/basicDisposable.ts +0 -57
  24. package/sources/byteList.ts +0 -202
  25. package/sources/byteListStream.ts +0 -121
  26. package/sources/byteReadStream.ts +0 -24
  27. package/sources/byteWriteStream.ts +0 -16
  28. package/sources/bytes.ts +0 -25
  29. package/sources/characterList.ts +0 -195
  30. package/sources/characterListStream.ts +0 -151
  31. package/sources/characterReadStream.ts +0 -81
  32. package/sources/characterReadStreamIterator.ts +0 -128
  33. package/sources/characterWriteStream.ts +0 -45
  34. package/sources/commandLineParameter.ts +0 -45
  35. package/sources/commandLineParameters.ts +0 -21
  36. package/sources/comparable.ts +0 -144
  37. package/sources/comparer.ts +0 -133
  38. package/sources/comparison.ts +0 -20
  39. package/sources/concatenateIterable.ts +0 -119
  40. package/sources/concatenateIterator.ts +0 -165
  41. package/sources/condition.ts +0 -329
  42. package/sources/currentProcess.ts +0 -158
  43. package/sources/dateTime.ts +0 -130
  44. package/sources/depthFirstSearch.ts +0 -230
  45. package/sources/disposable.ts +0 -31
  46. package/sources/emptyError.ts +0 -10
  47. package/sources/english.ts +0 -45
  48. package/sources/equalFunctions.ts +0 -123
  49. package/sources/fetchHttpClient.ts +0 -89
  50. package/sources/fetchHttpResponse.ts +0 -106
  51. package/sources/flatMapIterable.ts +0 -104
  52. package/sources/flatMapIterator.ts +0 -152
  53. package/sources/generator.ts +0 -251
  54. package/sources/httpClient.ts +0 -36
  55. package/sources/httpHeader.ts +0 -37
  56. package/sources/httpHeaders.ts +0 -216
  57. package/sources/httpIncomingRequest.ts +0 -30
  58. package/sources/httpIncomingResponse.ts +0 -19
  59. package/sources/httpMethod.ts +0 -164
  60. package/sources/httpOutgoingRequest.ts +0 -119
  61. package/sources/httpOutgoingResponse.ts +0 -113
  62. package/sources/httpServer.ts +0 -34
  63. package/sources/inMemoryCharacterWriteStream.ts +0 -78
  64. package/sources/index.ts +0 -101
  65. package/sources/iterable.ts +0 -345
  66. package/sources/iterator.ts +0 -481
  67. package/sources/iteratorToJavascriptIteratorAdapter.ts +0 -48
  68. package/sources/javascript.ts +0 -59
  69. package/sources/javascriptArrayList.ts +0 -175
  70. package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +0 -124
  71. package/sources/javascriptIteratorToIteratorAdapter.ts +0 -133
  72. package/sources/javascriptMapMap.ts +0 -143
  73. package/sources/javascriptSetSet.ts +0 -134
  74. package/sources/list.ts +0 -330
  75. package/sources/listQueue.ts +0 -62
  76. package/sources/listStack.ts +0 -62
  77. package/sources/luxonDateTime.ts +0 -109
  78. package/sources/map.ts +0 -302
  79. package/sources/mapAsyncIterator.ts +0 -141
  80. package/sources/mapIterable.ts +0 -105
  81. package/sources/mapIterator.ts +0 -145
  82. package/sources/mutableCondition.ts +0 -451
  83. package/sources/mutableHttpHeaders.ts +0 -204
  84. package/sources/mutableMap.ts +0 -292
  85. package/sources/network.ts +0 -18
  86. package/sources/node.ts +0 -37
  87. package/sources/nodeJSCharacterWriteStream.ts +0 -42
  88. package/sources/nodeJSHttpIncomingRequest.ts +0 -132
  89. package/sources/nodeJSHttpServer.ts +0 -134
  90. package/sources/notFoundError.ts +0 -12
  91. package/sources/postCondition.ts +0 -284
  92. package/sources/postConditionError.ts +0 -12
  93. package/sources/preCondition.ts +0 -284
  94. package/sources/preConditionError.ts +0 -12
  95. package/sources/promiseAsyncResult.ts +0 -174
  96. package/sources/property.ts +0 -63
  97. package/sources/queue.ts +0 -49
  98. package/sources/realNetwork.ts +0 -28
  99. package/sources/recreationDotGovClient.ts +0 -259
  100. package/sources/searchControl.ts +0 -42
  101. package/sources/set.ts +0 -244
  102. package/sources/skipAsyncIterator.ts +0 -145
  103. package/sources/skipIterator.ts +0 -155
  104. package/sources/stack.ts +0 -48
  105. package/sources/stringComparer.ts +0 -33
  106. package/sources/stringIterator.ts +0 -149
  107. package/sources/strings.ts +0 -322
  108. package/sources/syncResult.ts +0 -300
  109. package/sources/takeAsyncIterator.ts +0 -141
  110. package/sources/takeIterator.ts +0 -151
  111. package/sources/toStringFunctions.ts +0 -185
  112. package/sources/types.ts +0 -371
  113. package/sources/whereAsyncIterator.ts +0 -143
  114. package/sources/whereIterable.ts +0 -108
  115. package/sources/whereIterator.ts +0 -157
  116. package/sources/wonderlandTrailClient.ts +0 -1503
  117. package/tests/assertTest.ts +0 -113
  118. package/tests/assertTestTests.ts +0 -75
  119. package/tests/basicTestSkip.ts +0 -51
  120. package/tests/byteListStreamTests.ts +0 -390
  121. package/tests/byteListTests.ts +0 -27
  122. package/tests/bytesTests.ts +0 -43
  123. package/tests/characterListStreamTests.ts +0 -391
  124. package/tests/characterListTests.ts +0 -250
  125. package/tests/characterWriteStreamTests.ts +0 -12
  126. package/tests/comparerTests.ts +0 -92
  127. package/tests/conditionTests.ts +0 -877
  128. package/tests/consoleTestRunner.ts +0 -404
  129. package/tests/consoleTestRunnerTests.ts +0 -651
  130. package/tests/dateTimeTests.ts +0 -30
  131. package/tests/depthFirstSearchTests.ts +0 -106
  132. package/tests/disposableTests.ts +0 -121
  133. package/tests/englishTests.ts +0 -103
  134. package/tests/equalFunctionsTests.ts +0 -223
  135. package/tests/failedTest.ts +0 -43
  136. package/tests/fetchHttpClientTests.ts +0 -33
  137. package/tests/generatorTests.ts +0 -86
  138. package/tests/httpClientTests.ts +0 -18
  139. package/tests/inMemoryCharacterWriteStreamTests.ts +0 -117
  140. package/tests/iterableTests.ts +0 -141
  141. package/tests/iteratorTests.ts +0 -1086
  142. package/tests/javascriptMapMapTests.ts +0 -21
  143. package/tests/listTests.ts +0 -338
  144. package/tests/mapIteratorTests.ts +0 -55
  145. package/tests/mapTests.ts +0 -104
  146. package/tests/mutableConditionTests.ts +0 -273
  147. package/tests/mutableMapTests.ts +0 -154
  148. package/tests/nodeJSHttpServerTests.ts +0 -75
  149. package/tests/notFoundErrorTests.ts +0 -24
  150. package/tests/postConditionErrorTests.ts +0 -24
  151. package/tests/preConditionErrorTests.ts +0 -24
  152. package/tests/promiseAsyncResultTests.ts +0 -688
  153. package/tests/propertyTests.ts +0 -63
  154. package/tests/queueTests.ts +0 -29
  155. package/tests/recreationDotGovClientTests.ts +0 -191
  156. package/tests/setTests.ts +0 -140
  157. package/tests/skippedTest.ts +0 -39
  158. package/tests/stackTests.ts +0 -66
  159. package/tests/stringComparerTests.ts +0 -60
  160. package/tests/stringIteratorTests.ts +0 -156
  161. package/tests/stringsTests.ts +0 -516
  162. package/tests/syncResultTests.ts +0 -1251
  163. package/tests/test.ts +0 -228
  164. package/tests/testAction.ts +0 -75
  165. package/tests/testActionTests.ts +0 -93
  166. package/tests/testFailureTests.ts +0 -12
  167. package/tests/testRunner.ts +0 -267
  168. package/tests/testRunnerTests.ts +0 -895
  169. package/tests/testSkip.ts +0 -34
  170. package/tests/tests.ts +0 -103
  171. package/tests/toStringFunctionsTests.ts +0 -55
  172. package/tests/typesTests.ts +0 -257
  173. package/tests/whereIteratorTests.ts +0 -77
  174. package/tests/wonderlandTrailClientTests.ts +0 -452
  175. package/tsconfig.json +0 -20
  176. package/tsup.config.ts +0 -13
@@ -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
- }
@@ -1,12 +0,0 @@
1
- import { join } from "./strings";
2
-
3
- /**
4
- * An {@link Error} that is thrown when a post-condition fails.
5
- */
6
- export class PostConditionError extends Error
7
- {
8
- public constructor(...message: string[])
9
- {
10
- super(join("\n", message));
11
- }
12
- }
@@ -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
- }
@@ -1,12 +0,0 @@
1
- import { join } from "./strings";
2
-
3
- /**
4
- * An {@link Error} that is thrown when a pre-condition fails.
5
- */
6
- export class PreConditionError extends Error
7
- {
8
- public constructor(...message: string[])
9
- {
10
- super(join("\n", message));
11
- }
12
- }