@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,151 +0,0 @@
1
- import { CharacterList } from "./characterList";
2
- import { CharacterReadStream } from "./characterReadStream";
3
- import { CharacterWriteStream } from "./characterWriteStream";
4
- import { EmptyError } from "./emptyError";
5
- import { JavascriptIterable } from "./javascript";
6
- import { PreCondition } from "./preCondition";
7
- import { AsyncResult } from "./asyncResult";
8
- import { join } from "./strings";
9
- import { SyncResult } from "./syncResult";
10
- import { isNumber, isString, isUndefinedOrNull } from "./types";
11
-
12
- /**
13
- * A {@link CharacterReadStream} and {@link CharacterWriteStream} implementation that is implemented using a
14
- * {@link CharacterList}.
15
- */
16
- export class CharacterListStream implements CharacterReadStream, CharacterWriteStream
17
- {
18
- private readonly list: CharacterList;
19
-
20
- private constructor()
21
- {
22
- this.list = CharacterList.create();
23
- }
24
-
25
- public static create(initialValues?: JavascriptIterable<string>): CharacterListStream
26
- {
27
- const result: CharacterListStream = new CharacterListStream();
28
- if (initialValues)
29
- {
30
- result.writeCharacters(initialValues).await();
31
- }
32
- return result;
33
- }
34
-
35
- public writeCharacters(characters: JavascriptIterable<string>, startIndex?: number, length?: number): SyncResult<number>
36
- {
37
- PreCondition.assertNotUndefinedAndNotNull(characters, "characters");
38
-
39
- const characterString: string = isString(characters) ? characters : join("", characters);
40
- if (isUndefinedOrNull(startIndex))
41
- {
42
- startIndex = 0;
43
- }
44
- if (isUndefinedOrNull(length))
45
- {
46
- length = characterString.length - startIndex;
47
- }
48
-
49
- PreCondition.assertInsertIndex(startIndex, characterString.length, "startIndex");
50
- PreCondition.assertBetween(0, length, characterString.length - startIndex, "length");
51
-
52
- this.list.addAll(characterString.slice(startIndex, length + startIndex));
53
-
54
- return SyncResult.value(length);
55
- }
56
-
57
-
58
- public writeString(text: string): AsyncResult<number>
59
- {
60
- this.list.addAll(text);
61
-
62
- return SyncResult.value(text.length);
63
- }
64
-
65
- public writeLine(text?: string): AsyncResult<number>
66
- {
67
- return CharacterWriteStream.writeLine(this, text);
68
- }
69
-
70
- /**
71
- * Get the number of characters that are available to be read.
72
- */
73
- public getAvailableCharacterCount(): number
74
- {
75
- return this.list.getCount().await();
76
- }
77
-
78
- public readCharacter(): AsyncResult<string>
79
- {
80
- return !this.list.any().await()
81
- ? SyncResult.error(new EmptyError())
82
- : SyncResult.value(this.list.removeFirst().await());
83
- }
84
-
85
- public readCharacters(count: number): SyncResult<string>;
86
- public readCharacters(output: string[], startIndex?: number, count?: number): SyncResult<number>;
87
- readCharacters(countOrOutput: number | string[], startIndex?: number, count?: number): SyncResult<number> | SyncResult<string>
88
- {
89
- let result: SyncResult<number> | SyncResult<string>;
90
- if (isNumber(countOrOutput))
91
- {
92
- PreCondition.assertGreaterThanOrEqualTo(countOrOutput, 0, "count");
93
-
94
- if (!this.list.any().await())
95
- {
96
- result = SyncResult.error<string>(new EmptyError());
97
- }
98
- else
99
- {
100
- const bytesReadCount: number = Math.min(countOrOutput, this.list.getCount().await());
101
- let output: string = "";
102
- for (let i = 0; i < bytesReadCount; i++)
103
- {
104
- output += this.list.removeFirst().await();
105
- }
106
- result = SyncResult.value(output);
107
- }
108
- }
109
- else
110
- {
111
- PreCondition.assertNotUndefinedAndNotNull(countOrOutput, "output");
112
-
113
- if (isUndefinedOrNull(startIndex))
114
- {
115
- startIndex = 0;
116
- }
117
- if (isUndefinedOrNull(count))
118
- {
119
- count = countOrOutput.length - startIndex;
120
- }
121
-
122
- PreCondition.assertInsertIndex(startIndex, countOrOutput.length, "startIndex");
123
- PreCondition.assertBetween(0, count, countOrOutput.length - startIndex, "count");
124
-
125
- if (!this.list.any().await())
126
- {
127
- result = SyncResult.error<number>(new EmptyError());
128
- }
129
- else
130
- {
131
- const bytesReadCount: number = Math.min(count, this.list.getCount().await());
132
- for (let i = 0; i < bytesReadCount; i++)
133
- {
134
- countOrOutput[startIndex + i] = this.list.removeFirst().await();
135
- }
136
- result = SyncResult.value(bytesReadCount);
137
- }
138
- }
139
- return result;
140
- }
141
-
142
- public readUntil(searchString: string): AsyncResult<string>
143
- {
144
- return CharacterReadStream.readUntil(this, searchString);
145
- }
146
-
147
- public readLine(): AsyncResult<string>
148
- {
149
- return CharacterReadStream.readLine(this);
150
- }
151
- }
@@ -1,81 +0,0 @@
1
- import { PreCondition } from "./preCondition";
2
- import { AsyncResult } from "./asyncResult";
3
- import { SyncResult } from "./syncResult";
4
-
5
- export abstract class CharacterReadStream
6
- {
7
- /**
8
- * Read a single character from this stream.
9
- */
10
- public abstract readCharacter(): AsyncResult<string>;
11
-
12
- public readCharacters(count: number): AsyncResult<string>
13
- {
14
- return CharacterReadStream.readCharacters(this, count);
15
- }
16
-
17
- public static readCharacters(readStream: CharacterReadStream, count: number): AsyncResult<string>
18
- {
19
- let characters: string = "";
20
- function readUntilCount(countRemaining: number): AsyncResult<string>
21
- {
22
- return readStream.readCharacter()
23
- .then((character: string) =>
24
- {
25
- characters += character;
26
- return countRemaining === 0
27
- ? SyncResult.value(characters)
28
- : readUntilCount(countRemaining - 1);
29
- });
30
- }
31
- return readUntilCount(count);
32
- }
33
-
34
- /**
35
- * Read characters from this stream until the provided {@link searchString} is found or the end
36
- * of the stream is reached. The {@link searchString} will be included in the returned string if
37
- * it is found..
38
- * @param searchString The string to search for.
39
- */
40
- public readUntil(searchString: string): AsyncResult<string>
41
- {
42
- return CharacterReadStream.readUntil(this, searchString);
43
- }
44
-
45
- public static readUntil(readStream: CharacterReadStream, searchString: string): AsyncResult<string>
46
- {
47
- PreCondition.assertNotUndefinedAndNotNull(readStream, "readStream");
48
- PreCondition.assertNotEmpty(searchString, "searchString");
49
-
50
- let characters: string = "";
51
- function readUntilSearchString(): AsyncResult<string>
52
- {
53
- return readStream.readCharacter()
54
- .then((character: string) =>
55
- {
56
- characters += character;
57
- return characters.endsWith(searchString)
58
- ? SyncResult.value(characters)
59
- : readUntilSearchString();
60
- });
61
- }
62
- return readUntilSearchString();
63
- }
64
-
65
- /**
66
- * Read a sequence of characters from this stream until either a newline character ('\\n') or
67
- * the end of the stream is reached. Terminating newline characters will be included in the
68
- * returned string.
69
- */
70
- public readLine(): AsyncResult<string>
71
- {
72
- return CharacterReadStream.readLine(this);
73
- }
74
-
75
- public static readLine(readStream: CharacterReadStream): AsyncResult<string>
76
- {
77
- PreCondition.assertNotUndefinedAndNotNull(readStream, "readStream");
78
-
79
- return readStream.readUntil("\n");
80
- }
81
- }
@@ -1,128 +0,0 @@
1
- import { AsyncIterator } from "./asyncIterator";
2
- import { PromiseAsyncResult } from "./promiseAsyncResult";
3
- import { CharacterReadStream } from "./characterReadStream";
4
- import { JavascriptAsyncIterator } from "./javascript";
5
- import { NotFoundError } from "./notFoundError";
6
- import { PreCondition } from "./preCondition";
7
- import { Type } from "./types";
8
-
9
- export class CharacterReadStreamAsyncIterator implements AsyncIterator<string>
10
- {
11
- private readonly readStream: CharacterReadStream;
12
- private current: string;
13
- private started: boolean;
14
-
15
- private constructor(readStream: CharacterReadStream)
16
- {
17
- PreCondition.assertNotUndefinedAndNotNull(readStream, "readStream");
18
-
19
- this.readStream = readStream;
20
- this.current = "";
21
- this.started = false;
22
- }
23
-
24
- public static create(readStream: CharacterReadStream): CharacterReadStreamAsyncIterator
25
- {
26
- return new CharacterReadStreamAsyncIterator(readStream);
27
- }
28
-
29
- public next(): PromiseAsyncResult<boolean>
30
- {
31
- return PromiseAsyncResult.create(async () =>
32
- {
33
- this.started = true;
34
-
35
- this.current = await this.readStream.readCharacter()
36
- .catch(NotFoundError, () => "");
37
-
38
- return this.hasCurrent();
39
- });
40
- }
41
-
42
- public hasStarted(): boolean
43
- {
44
- return this.started;
45
- }
46
-
47
- public hasCurrent(): boolean
48
- {
49
- return this.current !== "";
50
- }
51
-
52
- public getCurrent(): string
53
- {
54
- PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
55
-
56
- return this.current;
57
- }
58
-
59
- public start(): PromiseAsyncResult<this>
60
- {
61
- return AsyncIterator.start<string,this>(this);
62
- }
63
-
64
- public takeCurrent(): PromiseAsyncResult<string>
65
- {
66
- return AsyncIterator.takeCurrent(this);
67
- }
68
-
69
- public any(): PromiseAsyncResult<boolean>
70
- {
71
- return AsyncIterator.any(this);
72
- }
73
-
74
- public getCount(): PromiseAsyncResult<number>
75
- {
76
- return AsyncIterator.getCount(this);
77
- }
78
-
79
- public toArray(): PromiseAsyncResult<string[]>
80
- {
81
- return AsyncIterator.toArray(this);
82
- }
83
-
84
- public where(condition: (value: string) => boolean | PromiseLike<boolean>): AsyncIterator<string>
85
- {
86
- return AsyncIterator.where(this, condition);
87
- }
88
-
89
- public map<TOutput>(mapping: (value: string) => (TOutput | PromiseLike<TOutput>)): AsyncIterator<TOutput>
90
- {
91
- return AsyncIterator.map(this, mapping);
92
- }
93
-
94
- public whereInstanceOf<U extends string>(typeCheck: (value: string) => value is U): AsyncIterator<U>
95
- {
96
- return AsyncIterator.whereInstanceOf(this, typeCheck);
97
- }
98
-
99
- public whereInstanceOfType<U extends string>(type: Type<U>): AsyncIterator<U>
100
- {
101
- return AsyncIterator.whereInstanceOfType(this, type);
102
- }
103
-
104
- public first(condition?: (value: string) => (boolean | PromiseLike<boolean>)): PromiseAsyncResult<string>
105
- {
106
- return AsyncIterator.first(this, condition);
107
- }
108
-
109
- public last(condition?: (value: string) => (boolean | PromiseLike<boolean>)): PromiseAsyncResult<string>
110
- {
111
- return AsyncIterator.last(this, condition);
112
- }
113
-
114
- public take(maximumToTake: number): AsyncIterator<string>
115
- {
116
- return AsyncIterator.take(this, maximumToTake);
117
- }
118
-
119
- public skip(maximumToSkip: number): AsyncIterator<string>
120
- {
121
- return AsyncIterator.skip(this, maximumToSkip);
122
- }
123
-
124
- public [Symbol.asyncIterator](): JavascriptAsyncIterator<string>
125
- {
126
- return AsyncIterator[Symbol.asyncIterator](this);
127
- }
128
- }
@@ -1,45 +0,0 @@
1
- import { PromiseAsyncResult } from "./promiseAsyncResult";
2
- import { PostCondition } from "./postCondition";
3
- import { PreCondition } from "./preCondition";
4
- import { AsyncResult } from "./asyncResult";
5
-
6
- export abstract class CharacterWriteStream
7
- {
8
- /**
9
- * Write the provided text to this {@link CharacterWriteStream}.
10
- * @param text The text to write.
11
- * @returns The number of characters that were written.
12
- */
13
- public abstract writeString(text: string): AsyncResult<number>
14
-
15
- /**
16
- * Write the provided text (if provided) and then write a newline character sequence to this
17
- * {@link CharacterWriteStream}.
18
- * @param text The optional text to write before the newline character sequence.
19
- * @returns The number of characters that were written.
20
- */
21
- public writeLine(text?: string): AsyncResult<number>
22
- {
23
- return CharacterWriteStream.writeLine(this, text);
24
- }
25
-
26
- public static writeLine(writeStream: CharacterWriteStream, text?: string): AsyncResult<number>
27
- {
28
- PreCondition.assertNotUndefinedAndNotNull(writeStream, "writeStream");
29
-
30
- return PromiseAsyncResult.create(async () =>
31
- {
32
- let result: number = 0;
33
-
34
- if (text)
35
- {
36
- result += await writeStream.writeString(text);
37
- }
38
- result += await writeStream.writeString("\n");
39
-
40
- PostCondition.assertGreaterThan(result, 0, "result");
41
-
42
- return result;
43
- });
44
- }
45
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * An individual parameter from a {@link CommandLineParameters} object.
3
- */
4
- export class CommandLineParameter<T>
5
- {
6
- /**
7
- * The full name of this {@link CommandLineParameter}.
8
- */
9
- private readonly name: string;
10
- /**
11
- * The description for this {@link CommandLineParameter}.
12
- */
13
- private readonly description: string;
14
- /**
15
- * The function that can be invoked to get this {@link CommandLineParameter}'s value.
16
- */
17
- private readonly valueGetter: () => T;
18
-
19
- private constructor(name: string, description: string, valueGetter: () => T)
20
- {
21
- this.name = name;
22
- this.description = description;
23
- this.valueGetter = valueGetter;
24
- }
25
-
26
- /**
27
- * Create a new {@link CommandLineParameter}.
28
- * @param name The full name of the {@link CommandLineParameter}.
29
- * @param description The description for the {@link CommandLineParameter}.
30
- * @param valueGetter The function that will be used to get the returned
31
- * {@link CommandLineParameter}'s value.
32
- */
33
- public static create<T>(name: string, description: string, valueGetter: () => T)
34
- {
35
- return new CommandLineParameter<T>(name, description, valueGetter);
36
- }
37
-
38
- /**
39
- * Get the value for this {@link CommandLineParameter}.
40
- */
41
- public getValue(): T
42
- {
43
- return this.valueGetter();
44
- }
45
- }
@@ -1,21 +0,0 @@
1
- import { JavascriptIterable } from "./javascript";
2
-
3
- /**
4
- * A class that can be used to define and interact with an application's command line interface.
5
- */
6
- export class CommandLineParameters
7
- {
8
- private readonly args: JavascriptIterable<string>;
9
-
10
- private constructor(argv: JavascriptIterable<string>)
11
- {
12
- this.args = argv
13
- }
14
-
15
- public static create(args: JavascriptIterable<string>): CommandLineParameters
16
- {
17
- return new CommandLineParameters(args)
18
- }
19
-
20
-
21
- }
@@ -1,144 +0,0 @@
1
- import { Comparison } from "./comparison";
2
- import { PreCondition } from "./preCondition";
3
-
4
- /**
5
- * An type that can be compared against another type.
6
- */
7
- export abstract class Comparable<T>
8
- {
9
- protected constructor()
10
- {
11
- }
12
-
13
- /**
14
- * Compare this value against the provided value.
15
- * @param value The value to compare against.
16
- */
17
- public abstract compareTo(value: T): Comparison;
18
-
19
- /**
20
- * Get whether this value is less than the provided value.
21
- * @param value The value to compare against.
22
- */
23
- public lessThan(value: T): boolean
24
- {
25
- return Comparable.lessThan(this, value);
26
- }
27
-
28
- /**
29
- * Get whether the left value is less than the right value.
30
- * @param left The left value in the comparison.
31
- * @param right The right value in the comparison.
32
- */
33
- public static lessThan<T>(left: Comparable<T>, right: T): boolean
34
- {
35
- PreCondition.assertNotUndefinedAndNotNull(left, "left");
36
-
37
- return left.compareTo(right) === Comparison.LessThan;
38
- }
39
-
40
- /**
41
- * Get whether this value is less than or equal to the provided value.
42
- * @param value The value to compare against.
43
- */
44
- public lessThanOrEqualTo(value: T): boolean
45
- {
46
- return Comparable.lessThanOrEqualTo(this, value);
47
- }
48
-
49
- /**
50
- * Get whether the left value is less than or equal to the right value.
51
- * @param left The left value in the comparison.
52
- * @param right The right value in the comparison.
53
- */
54
- public static lessThanOrEqualTo<T>(left: Comparable<T>, right: T): boolean
55
- {
56
- PreCondition.assertNotUndefinedAndNotNull(left, "left");
57
-
58
- return left.compareTo(right) !== Comparison.GreaterThan;
59
- }
60
-
61
- /**
62
- * Get whether this value equals the provided value.
63
- * @param value The value to compare against.
64
- */
65
- public equals(value: T): boolean
66
- {
67
- return Comparable.equals(this, value);
68
- }
69
-
70
- /**
71
- * Get whether the left value equals the right value.
72
- * @param left The left value in the comparison.
73
- * @param right The right value in the comparison.
74
- */
75
- public static equals<T>(left: Comparable<T>, right: T): boolean
76
- {
77
- PreCondition.assertNotUndefinedAndNotNull(left, "left");
78
-
79
- return left.compareTo(right) === Comparison.Equal;
80
- }
81
-
82
- /**
83
- * Get whether this value is not equal to the provided value.
84
- * @param value The value to compare against.
85
- */
86
- public notEquals(value: T): boolean
87
- {
88
- return Comparable.notEquals(this, value);
89
- }
90
-
91
- /**
92
- * Get whether the left value is not equal to the right value.
93
- * @param left The left value in the comparison.
94
- * @param right The right value in the comparison.
95
- */
96
- public static notEquals<T>(left: Comparable<T>, right: T): boolean
97
- {
98
- PreCondition.assertNotUndefinedAndNotNull(left, "left");
99
-
100
- return left.compareTo(right) !== Comparison.Equal;
101
- }
102
-
103
- /**
104
- * Get whether this value is greater than or equal to the provided value.
105
- * @param value The value to compare against.
106
- */
107
- public greaterThanOrEqualTo(value: T): boolean
108
- {
109
- return Comparable.greaterThanOrEqualTo(this, value);
110
- }
111
-
112
- /**
113
- * Get whether the left value is greater than or equal to the right value.
114
- * @param left The left value in the comparison.
115
- * @param right The right value in the comparison.
116
- */
117
- public static greaterThanOrEqualTo<T>(left: Comparable<T>, right: T): boolean
118
- {
119
- PreCondition.assertNotUndefinedAndNotNull(left, "left");
120
-
121
- return left.compareTo(right) !== Comparison.LessThan;
122
- }
123
-
124
- /**
125
- * Get whether this value is greater than the provided value.
126
- * @param value The value to compare against.
127
- */
128
- public greaterThan(value: T): boolean
129
- {
130
- return Comparable.greaterThan(this, value);
131
- }
132
-
133
- /**
134
- * Get whether the left value is greater than the right value.
135
- * @param left The left value in the comparison.
136
- * @param right The right value in the comparison.
137
- */
138
- public static greaterThan<T>(left: Comparable<T>, right: T): boolean
139
- {
140
- PreCondition.assertNotUndefinedAndNotNull(left, "left");
141
-
142
- return left.compareTo(right) === Comparison.GreaterThan;
143
- }
144
- }