@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,404 +0,0 @@
1
- import { PromiseAsyncResult } from "../sources/promiseAsyncResult";
2
- import { CharacterWriteStream } from "../sources/characterWriteStream";
3
- import { CurrentProcess } from "../sources/currentProcess";
4
- import { Iterable } from "../sources/iterable";
5
- import { JavascriptIterable } from "../sources/javascript";
6
- import { List } from "../sources/list";
7
- import { NodeJSCharacterWriteStream } from "../sources/nodeJSCharacterWriteStream";
8
- import { PreCondition } from "../sources/preCondition";
9
- import { join } from "../sources/strings";
10
- import { isFunction, isJavascriptIterable, isPromise } from "../sources/types";
11
- import { AssertTest } from "./assertTest";
12
- import { FailedTest } from "./failedTest";
13
- import { SkippedTest } from "./skippedTest";
14
- import { Test } from "./test";
15
- import { TestAction } from "./testAction";
16
- import { TestRunner } from "./testRunner";
17
- import { TestSkip } from "./testSkip";
18
-
19
- export type ConsoleTestFunction = (runner: ConsoleTestRunner) => (void | Promise<void>);
20
- export type ConsoleTestFunctionContainer = { test: ConsoleTestFunction };
21
-
22
- export class ConsoleTestRunner extends TestRunner
23
- {
24
- private writeStream: CharacterWriteStream;
25
-
26
- private readonly pendingActions: List<TestAction>;
27
- private pendingActionsInsertIndex: number;
28
- private currentTestAction: TestAction | undefined;
29
- private currentTest: Test | undefined;
30
-
31
- private passedTestCount: number;
32
- private readonly skippedTests: List<SkippedTest>;
33
- private readonly testFailures: List<FailedTest>;
34
-
35
- public constructor()
36
- {
37
- super();
38
-
39
- this.writeStream = NodeJSCharacterWriteStream.create(process.stdout);
40
-
41
- this.pendingActions = List.create();
42
- this.pendingActionsInsertIndex = 0;
43
-
44
- this.passedTestCount = 0;
45
- this.skippedTests = List.create();
46
- this.testFailures = List.create();
47
- }
48
-
49
- public static create(): ConsoleTestRunner
50
- {
51
- return new ConsoleTestRunner();
52
- }
53
-
54
- public static run(testFunction: ConsoleTestFunction | ConsoleTestFunctionContainer): Promise<void>;
55
- public static run(testFunctions: JavascriptIterable<ConsoleTestFunction | ConsoleTestFunctionContainer>): Promise<void>;
56
- static run(testFunctionOrTestFunctions: ConsoleTestFunction | ConsoleTestFunctionContainer | JavascriptIterable<ConsoleTestFunction | ConsoleTestFunctionContainer>): Promise<void>
57
- {
58
- let testFunction: ConsoleTestFunction;
59
- if (isFunction(testFunctionOrTestFunctions))
60
- {
61
- testFunction = testFunctionOrTestFunctions;
62
- }
63
- else if (!isJavascriptIterable(testFunctionOrTestFunctions))
64
- {
65
- testFunction = testFunctionOrTestFunctions.test;
66
- }
67
- else
68
- {
69
- const testFunctions: JavascriptIterable<ConsoleTestFunction | ConsoleTestFunctionContainer> = testFunctionOrTestFunctions;
70
- testFunction = async (runner: ConsoleTestRunner) =>
71
- {
72
- for (const testFunction of testFunctions)
73
- {
74
- if (isFunction(testFunction))
75
- {
76
- await testFunction(runner);
77
- }
78
- else
79
- {
80
- await testFunction.test(runner);
81
- }
82
- }
83
- };
84
- }
85
-
86
- return CurrentProcess.run(async (currentProcess: CurrentProcess) =>
87
- {
88
- const runner: ConsoleTestRunner = ConsoleTestRunner.create()
89
- .setWriteStream(currentProcess.getOutputWriteStream());
90
-
91
- await testFunction(runner);
92
-
93
- await runner.runAsync();
94
-
95
- await runner.printSummary();
96
- });
97
- }
98
-
99
- public setWriteStream(writeStream: CharacterWriteStream): this
100
- {
101
- PreCondition.assertNotUndefinedAndNotNull(writeStream, "writeStream");
102
-
103
- this.writeStream = writeStream;
104
-
105
- return this;
106
- }
107
-
108
- /**
109
- * Get the number of {@link TestAction}s that have yet to be executed.
110
- */
111
- public getPendingTestActionsCount(): number
112
- {
113
- return this.pendingActions.getCount().await();
114
- }
115
-
116
- /**
117
- * Get the index in the pending-{@link TestAction} stack that new {@link TestAction}s will be
118
- * inserted at.
119
- */
120
- public getPendingTestActionsInsertIndex(): number
121
- {
122
- return this.pendingActionsInsertIndex;
123
- }
124
-
125
- /**
126
- * Get the number of tests that have been skipped.
127
- */
128
- public getSkippedTestCount(): number
129
- {
130
- return this.skippedTests.getCount().await();
131
- }
132
-
133
- public getSkippedTests(): Iterable<SkippedTest>
134
- {
135
- return this.skippedTests;
136
- }
137
-
138
- /**
139
- * Get the number of tests that have passed.
140
- */
141
- public getPassedTestCount(): number
142
- {
143
- return this.passedTestCount;
144
- }
145
-
146
- public getFailedTestCount(): number
147
- {
148
- return this.testFailures.getCount().await();
149
- }
150
-
151
- public getFailedTests(): Iterable<FailedTest>
152
- {
153
- return this.testFailures;
154
- }
155
-
156
- /**
157
- * Get the {@link TestAction} that is currently executing or undefined if no {@link TestAction}
158
- * is executing.
159
- */
160
- public getCurrentTestAction(): TestAction | undefined
161
- {
162
- return this.currentTestAction;
163
- }
164
-
165
- public getCurrentTest(): Test | undefined
166
- {
167
- return this.currentTest;
168
- }
169
-
170
- private assertNoCurrentTest(): void
171
- {
172
- if (this.currentTest !== undefined)
173
- {
174
- this.currentTest.fail("Can't start a new test group or a new test while running a test.");
175
- }
176
- }
177
-
178
- public beforeTest(fullTestNameParts: JavascriptIterable<string>): PromiseAsyncResult<void>
179
- {
180
- return PromiseAsyncResult.create(async () =>
181
- {
182
- await this.writeStream.writeString(join(" ", fullTestNameParts));
183
- });
184
- }
185
-
186
- public afterPassedTest(): PromiseAsyncResult<void>
187
- {
188
- return PromiseAsyncResult.create(async () =>
189
- {
190
- await this.writeStream.writeLine(" - Passed");
191
- this.passedTestCount++;
192
- });
193
- }
194
-
195
- public afterSkippedTest(fullTestNameParts: JavascriptIterable<string>, skip: TestSkip | undefined): PromiseAsyncResult<void>
196
- {
197
- PreCondition.assertNotEmpty(fullTestNameParts, "fullTestNameParts");
198
- PreCondition.assertNotUndefinedAndNotNull(skip, "skip");
199
-
200
- return PromiseAsyncResult.create(async () =>
201
- {
202
- this.skippedTests.add(SkippedTest.create(skip, fullTestNameParts));
203
- await this.writeStream.writeLine(" - Skipped");
204
- });
205
- }
206
-
207
- public afterFailedTest(fullTestNameParts: JavascriptIterable<string>, error: unknown): PromiseAsyncResult<void>
208
- {
209
- PreCondition.assertNotEmpty(fullTestNameParts, "fullTestNameParts");
210
- PreCondition.assertNotUndefinedAndNotNull(error, "error");
211
-
212
- return PromiseAsyncResult.create(async () =>
213
- {
214
- this.testFailures.add(FailedTest.create(fullTestNameParts, error));
215
- await this.writeStream.writeLine(" - Failed");
216
- });
217
- }
218
-
219
- public testGroup(testGroupName: string, testAction: () => (void | Promise<void>)): void;
220
- public testGroup(testGroupName: string, skip: TestSkip | undefined, testAction: () => (void | Promise<void>)): void;
221
- testGroup(testGroupName: string, skipOrTestAction: TestSkip | undefined | (() => (void | Promise<void>)), testAction?: () => (void | Promise<void>)): void
222
- {
223
- PreCondition.assertNotUndefinedAndNotNull(testGroupName, "testGroupName");
224
- PreCondition.assertNotEmpty(testGroupName, "testGroupName");
225
- let skip: TestSkip | undefined;
226
- if (isFunction(skipOrTestAction))
227
- {
228
- PreCondition.assertUndefined(testAction, "testAction");
229
-
230
- skip = undefined;
231
- testAction = skipOrTestAction;
232
- }
233
- else
234
- {
235
- skip = skipOrTestAction;
236
- }
237
- PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
238
-
239
- this.assertNoCurrentTest();
240
-
241
- this.pendingActions.insert(
242
- this.pendingActionsInsertIndex,
243
- TestAction.create(
244
- this.getCurrentTestAction(),
245
- testGroupName,
246
- skip,
247
- async () =>
248
- {
249
- const previousTestActionInsertIndex: number = this.pendingActionsInsertIndex;
250
- this.pendingActionsInsertIndex = this.pendingActions.getCount().await();
251
- const currentTestAction: TestAction = this.getCurrentTestAction()!;
252
- try
253
- {
254
- await testAction();
255
- }
256
- catch (error)
257
- {
258
- await this.afterFailedTest(currentTestAction.getFullNameParts(), error);
259
- }
260
- finally
261
- {
262
- this.pendingActionsInsertIndex = previousTestActionInsertIndex;
263
- }
264
- },
265
- ),
266
- );
267
- }
268
-
269
- public test(testName: string, testAction: (test: Test) => (void | Promise<void>)): void;
270
- public test(testName: string, skip: TestSkip | undefined, testAction: (test: Test) => (void | Promise<void>)): void;
271
- test(testName: string, skipOrTestAction: TestSkip | undefined | ((test: Test) => (void | Promise<void>)), testAction?: (test: Test) => (void | Promise<void>)): void
272
- {
273
- PreCondition.assertNotUndefinedAndNotNull(testName, "testName");
274
- PreCondition.assertNotEmpty(testName, "testName");
275
- let skip: TestSkip | undefined;
276
- if (isFunction(skipOrTestAction))
277
- {
278
- PreCondition.assertUndefined(testAction, "testAction");
279
-
280
- skip = undefined;
281
- testAction = skipOrTestAction;
282
- }
283
- else
284
- {
285
- skip = skipOrTestAction;
286
- }
287
- PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
288
-
289
- this.assertNoCurrentTest();
290
-
291
- this.pendingActions.insert(
292
- this.pendingActionsInsertIndex,
293
- TestAction.create(
294
- this.getCurrentTestAction(),
295
- testName,
296
- skip,
297
- async () =>
298
- {
299
- const currentTestAction: TestAction = this.getCurrentTestAction()!;
300
- try
301
- {
302
- await this.beforeTest(currentTestAction.getFullNameParts());
303
- if (currentTestAction.shouldSkip())
304
- {
305
- await this.afterSkippedTest(currentTestAction.getFullNameParts(), currentTestAction.getSkip());
306
- }
307
- else
308
- {
309
- this.currentTest = AssertTest.create(testName);
310
- try
311
- {
312
- await testAction(this.currentTest);
313
- await this.afterPassedTest();
314
- }
315
- finally
316
- {
317
- this.currentTest = undefined;
318
- }
319
- }
320
- }
321
- catch (error)
322
- {
323
- await this.afterFailedTest(currentTestAction.getFullNameParts(), error);
324
- }
325
- },
326
- ),
327
- );
328
- }
329
-
330
- public async runAsync(): Promise<void>
331
- {
332
- while (this.pendingActions.any().await())
333
- {
334
- this.currentTestAction = this.pendingActions.removeLast().await();
335
- try
336
- {
337
- const result: void | Promise<void> = this.currentTestAction.runAsync();
338
- if (isPromise(result))
339
- {
340
- await result;
341
- }
342
- }
343
- finally
344
- {
345
- this.currentTestAction = undefined;
346
- }
347
- }
348
- }
349
-
350
- public printSummary(): PromiseAsyncResult<void>
351
- {
352
- return PromiseAsyncResult.create(async () =>
353
- {
354
- await this.writeStream.writeLine();
355
-
356
- const skippedTests: Iterable<SkippedTest> = this.getSkippedTests();
357
- if (await skippedTests.any())
358
- {
359
- await this.writeStream.writeLine(`Skipped Tests:`);
360
- let counter: number = 0;
361
- for (const skippedTest of skippedTests)
362
- {
363
- await this.writeStream.writeLine(`${++counter}) ${skippedTest.getFullTestName()}`);
364
- const skipMessage: string = skippedTest.getSkipMessage();
365
- if (skipMessage)
366
- {
367
- await this.writeStream.writeLine(` ${skipMessage}`);
368
- }
369
- }
370
- await this.writeStream.writeLine();
371
- }
372
-
373
- const failedTests: Iterable<FailedTest> = this.getFailedTests();
374
- if (await failedTests.any())
375
- {
376
- await this.writeStream.writeLine("Failed Tests:");
377
-
378
- let counter: number = 0;
379
- for (const failedTest of failedTests)
380
- {
381
- await this.writeStream.writeLine(`${++counter}) ${failedTest.getFullTestName()}`);
382
- await this.writeStream.writeLine(` ${failedTest.getErrorMessage()}`);
383
- await this.writeStream.writeLine();
384
- }
385
- }
386
-
387
- const passedTestCount: number = this.getPassedTestCount();
388
- if (passedTestCount > 0)
389
- {
390
- await this.writeStream.writeLine(`Passed: ${passedTestCount}`);
391
- }
392
-
393
- if (await skippedTests.any())
394
- {
395
- await this.writeStream.writeLine(`Skipped: ${skippedTests.getCount().await()}`);
396
- }
397
-
398
- if (await failedTests.any())
399
- {
400
- await this.writeStream.writeLine(`Failed: ${failedTests.getCount().await()}`);
401
- }
402
- });
403
- }
404
- }