@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,78 +0,0 @@
1
- import { CharacterWriteStream } from "./characterWriteStream";
2
- import { PreCondition } from "./preCondition";
3
- import { getLength } from "./strings";
4
- import { SyncResult } from "./syncResult";
5
-
6
- export class InMemoryCharacterWriteStream extends CharacterWriteStream
7
- {
8
- private writtenText: string;
9
- private newlineSequence: string;
10
-
11
- private constructor()
12
- {
13
- super();
14
-
15
- this.writtenText = "";
16
- this.newlineSequence = "\n";
17
- }
18
-
19
- public static create(): InMemoryCharacterWriteStream
20
- {
21
- return new InMemoryCharacterWriteStream();
22
- }
23
-
24
- public getNewlineSequence(): string
25
- {
26
- return this.newlineSequence;
27
- }
28
-
29
- public setNewlineSequence(newlineSequence: string): this
30
- {
31
- PreCondition.assertNotUndefinedAndNotNull(newlineSequence, "newlineSequence");
32
-
33
- this.newlineSequence = newlineSequence;
34
-
35
- return this;
36
- }
37
-
38
- public getWrittenText(): string
39
- {
40
- return this.writtenText;
41
- }
42
-
43
- public clearWrittenText(): this
44
- {
45
- this.writtenText = "";
46
-
47
- return this;
48
- }
49
-
50
- public writeString(text: string): SyncResult<number>
51
- {
52
- return SyncResult.create(() =>
53
- {
54
- if (text)
55
- {
56
- this.writtenText += text;
57
- }
58
- return getLength(text);
59
- });
60
- }
61
-
62
- public writeLine(text?: string): SyncResult<number>
63
- {
64
- return SyncResult.create(() =>
65
- {
66
- let result: number = 0;
67
- if (text)
68
- {
69
- result += this.writeString(text).await();
70
- }
71
- if (this.newlineSequence)
72
- {
73
- result += this.writeString(this.newlineSequence).await();
74
- }
75
- return result;
76
- });
77
- }
78
- }
package/sources/index.ts DELETED
@@ -1,101 +0,0 @@
1
- /**
2
- * @file Automatically generated by barrelsby.
3
- */
4
-
5
- export * from "./assertMessageParameters";
6
- export * from "./asyncIterator";
7
- export * from "./asyncIteratorToJavascriptAsyncIteratorAdapter";
8
- export * from "./asyncResult";
9
- export * from "./basicDisposable";
10
- export * from "./byteList";
11
- export * from "./byteListStream";
12
- export * from "./byteReadStream";
13
- export * from "./bytes";
14
- export * from "./byteWriteStream";
15
- export * from "./characterList";
16
- export * from "./characterListStream";
17
- export * from "./characterReadStream";
18
- export * from "./characterReadStreamIterator";
19
- export * from "./characterWriteStream";
20
- export * from "./commandLineParameter";
21
- export * from "./commandLineParameters";
22
- export * from "./comparable";
23
- export * from "./comparer";
24
- export * from "./comparison";
25
- export * from "./concatenateIterable";
26
- export * from "./concatenateIterator";
27
- export * from "./condition";
28
- export * from "./currentProcess";
29
- export * from "./dateTime";
30
- export * from "./depthFirstSearch";
31
- export * from "./disposable";
32
- export * from "./emptyError";
33
- export * from "./english";
34
- export * from "./equalFunctions";
35
- export * from "./fetchHttpClient";
36
- export * from "./fetchHttpResponse";
37
- export * from "./flatMapIterable";
38
- export * from "./flatMapIterator";
39
- export * from "./generator";
40
- export * from "./httpClient";
41
- export * from "./httpHeader";
42
- export * from "./httpHeaders";
43
- export * from "./httpIncomingRequest";
44
- export * from "./httpIncomingResponse";
45
- export * from "./httpMethod";
46
- export * from "./httpOutgoingRequest";
47
- export * from "./httpOutgoingResponse";
48
- export * from "./httpServer";
49
- export * from "./inMemoryCharacterWriteStream";
50
- export * from "./iterable";
51
- export * from "./iterator";
52
- export * from "./iteratorToJavascriptIteratorAdapter";
53
- export * from "./javascript";
54
- export * from "./javascriptArrayList";
55
- export * from "./javascriptAsyncIteratorToAsyncIteratorAdapter";
56
- export * from "./javascriptIteratorToIteratorAdapter";
57
- export * from "./javascriptMapMap";
58
- export * from "./javascriptSetSet";
59
- export * from "./list";
60
- export * from "./listQueue";
61
- export * from "./listStack";
62
- export * from "./luxonDateTime";
63
- export * from "./map";
64
- export * from "./mapAsyncIterator";
65
- export * from "./mapIterable";
66
- export * from "./mapIterator";
67
- export * from "./mutableCondition";
68
- export * from "./mutableHttpHeaders";
69
- export * from "./mutableMap";
70
- export * from "./network";
71
- export * from "./node";
72
- export * from "./nodeJSCharacterWriteStream";
73
- export * from "./nodeJSHttpIncomingRequest";
74
- export * from "./nodeJSHttpServer";
75
- export * from "./notFoundError";
76
- export * from "./postCondition";
77
- export * from "./postConditionError";
78
- export * from "./preCondition";
79
- export * from "./preConditionError";
80
- export * from "./promiseAsyncResult";
81
- export * from "./property";
82
- export * from "./queue";
83
- export * from "./realNetwork";
84
- export * from "./recreationDotGovClient";
85
- export * from "./searchControl";
86
- export * from "./set";
87
- export * from "./skipAsyncIterator";
88
- export * from "./skipIterator";
89
- export * from "./stack";
90
- export * from "./stringComparer";
91
- export * from "./stringIterator";
92
- export * from "./strings";
93
- export * from "./syncResult";
94
- export * from "./takeAsyncIterator";
95
- export * from "./takeIterator";
96
- export * from "./toStringFunctions";
97
- export * from "./types";
98
- export * from "./whereAsyncIterator";
99
- export * from "./whereIterable";
100
- export * from "./whereIterator";
101
- export * from "./wonderlandTrailClient";
@@ -1,345 +0,0 @@
1
- import { Comparable } from "./comparable";
2
- import { Comparer } from "./comparer";
3
- import { ConcatenateIterable } from "./concatenateIterable";
4
- import { EqualFunctions } from "./equalFunctions";
5
- import { FlatMapIterable } from "./flatMapIterable";
6
- import { Iterator } from "./iterator";
7
- import { JavascriptIterable, JavascriptIterator } from "./javascript";
8
- import { List } from "./list";
9
- import { MapIterable } from "./mapIterable";
10
- import { PreCondition } from "./preCondition";
11
- import { SyncResult } from "./syncResult";
12
- import { ToStringFunctions } from "./toStringFunctions";
13
- import { instanceOf, isIterable, isUndefinedOrNull, Type } from "./types";
14
- import { WhereIterable } from "./whereIterable";
15
-
16
- /**
17
- * An object that can be iterated over.
18
- */
19
- export abstract class Iterable<T> implements JavascriptIterable<T>
20
- {
21
- public static create<T>(values?: JavascriptIterable<T>): Iterable<T>
22
- {
23
- return List.create(values);
24
- }
25
-
26
- /**
27
- * Iterate over the values in this {@link Iterable}.
28
- */
29
- public abstract iterate(): Iterator<T>;
30
-
31
- public [Symbol.iterator](): JavascriptIterator<T>
32
- {
33
- return Iterable[Symbol.iterator](this);
34
- }
35
-
36
- public static [Symbol.iterator]<T>(iterable: Iterable<T>): JavascriptIterator<T>
37
- {
38
- PreCondition.assertNotUndefinedAndNotNull(iterable, "iterable");
39
-
40
- return iterable.iterate()[Symbol.iterator]();
41
- }
42
-
43
- /**
44
- * Get all of the values in this {@link Iterable} in an {@link Array}.
45
- */
46
- public toArray(): SyncResult<T[]>
47
- {
48
- return Iterable.toArray(this);
49
- }
50
-
51
- /**
52
- * Get all of the values in the provided {@link Iterable} in an {@link Array}.
53
- */
54
- public static toArray<T>(iterable: Iterable<T>): SyncResult<T[]>
55
- {
56
- PreCondition.assertNotUndefinedAndNotNull(iterable, "iterable");
57
-
58
- return iterable.iterate().toArray();
59
- }
60
-
61
- /**
62
- * Get whether this {@link Iterable} contains any values.
63
- */
64
- public any(): SyncResult<boolean>
65
- {
66
- return Iterable.any(this);
67
- }
68
-
69
- /**
70
- * Get whether the provided {@link JavascriptIterable} contains any values.
71
- */
72
- public static any<T>(iterable: JavascriptIterable<T>): SyncResult<boolean>
73
- {
74
- PreCondition.assertNotUndefinedAndNotNull(iterable, "iterable");
75
-
76
- return Iterator.create(iterable).any();
77
- }
78
-
79
- /**
80
- * Get the number of values in this {@link Iterable}.
81
- */
82
- public getCount(): SyncResult<number>
83
- {
84
- return Iterable.getCount(this);
85
- }
86
-
87
- /**
88
- * Get the number of values in the provided {@link Iterable}.
89
- */
90
- public static getCount<T>(iterable: Iterable<T>): SyncResult<number>
91
- {
92
- return iterable.iterate().getCount();
93
- }
94
-
95
- /**
96
- * Get whether this {@link Iterable} is equal to the provided {@link Iterable}.
97
- * @param right The {@link Iterable} to compare against this {@link Iterable}.
98
- * @param equalFunctions The optional {@link EqualFunctions} to use to determine if the two
99
- * {@link Iterable}s are equal.
100
- */
101
- public equals(right: JavascriptIterable<T>, equalFunctions?: EqualFunctions): SyncResult<boolean>
102
- {
103
- return Iterable.equals(this, right, equalFunctions);
104
- }
105
-
106
- public static equals<T>(left: JavascriptIterable<T>, right: JavascriptIterable<T>, equalFunctions?: EqualFunctions): SyncResult<boolean>
107
- {
108
- return SyncResult.create(() =>
109
- {
110
- if (isUndefinedOrNull(equalFunctions))
111
- {
112
- equalFunctions = EqualFunctions.create();
113
- }
114
-
115
- let result: boolean | undefined = Comparer.equalSameUndefinedNull(left, right);
116
- if (result === undefined)
117
- {
118
- result = true;
119
-
120
- const leftIterator: Iterator<T> = Iterator.create(left).start().await();
121
- const rightIterator: Iterator<T> = Iterator.create(right).start().await();
122
- while (leftIterator.hasCurrent() && rightIterator.hasCurrent())
123
- {
124
- result = equalFunctions.areEqual(leftIterator.getCurrent(), rightIterator.getCurrent()).await();
125
- if (result === false)
126
- {
127
- break;
128
- }
129
- else
130
- {
131
- leftIterator.next().await();
132
- rightIterator.next().await();
133
- }
134
- }
135
- if (result)
136
- {
137
- result = (leftIterator.hasCurrent() === rightIterator.hasCurrent());
138
- }
139
- }
140
- return result;
141
- });
142
- }
143
-
144
- /**
145
- * Get the {@link String} representation of this {@link Iterable}.
146
- */
147
- public toString(toStringFunctions?: ToStringFunctions): string
148
- {
149
- return Iterable.toString(this, toStringFunctions);
150
- }
151
-
152
- /**
153
- * Get the {@link String} representation of the provided {@link Iterable}.
154
- */
155
- public static toString<T>(iterable: Iterable<T>, toStringFunctions?: ToStringFunctions): string
156
- {
157
- PreCondition.assertNotUndefinedAndNotNull(iterable, "iterable");
158
-
159
- if (isUndefinedOrNull(toStringFunctions))
160
- {
161
- toStringFunctions = ToStringFunctions.create();
162
- }
163
- return toStringFunctions.toString(iterable);
164
- }
165
-
166
- public concatenate(...toConcatenate: JavascriptIterable<T>[]): Iterable<T>
167
- {
168
- return Iterable.concatenate(this, ...toConcatenate);
169
- }
170
-
171
- public static concatenate<T>(iterable: Iterable<T>, ...toConcatenate: JavascriptIterable<T>[]): Iterable<T>
172
- {
173
- PreCondition.assertNotUndefinedAndNotNull(iterable, "iterator");
174
- PreCondition.assertNotUndefinedAndNotNull(toConcatenate, "toConcatenate");
175
-
176
- return ConcatenateIterable.create(iterable, ...toConcatenate);
177
- }
178
-
179
- /**
180
- * Get a {@link MapIterable} that maps all of the {@link T} values in this {@link Iterable} to
181
- * {@link TOutput} values.
182
- * @param mapping The mapping function to use to convert values of type {@link T} to
183
- * {@link TOutput}.
184
- */
185
- public map<TOutput>(mapping: (value: T) => (TOutput | SyncResult<TOutput>)): Iterable<TOutput>
186
- {
187
- return Iterable.map(this, mapping);
188
- }
189
-
190
- /**
191
- * Get a {@link MapIterable} that maps all of the {@link T} values in the provided
192
- * {@link Iterable} to {@link TOutput} values.
193
- * @param mapping The mapping function to use to convert values of type {@link T} to
194
- * {@link TOutput}.
195
- */
196
- public static map<TInput, TOutput>(iterable: Iterable<TInput>, mapping: (value: TInput) => (TOutput | SyncResult<TOutput>)): Iterable<TOutput>
197
- {
198
- PreCondition.assertNotUndefinedAndNotNull(iterable, "iterable");
199
- PreCondition.assertNotUndefinedAndNotNull(mapping, "mapping");
200
-
201
- return MapIterable.create(iterable, mapping);
202
- }
203
-
204
- public flatMap<TOutput>(mapping: (value: T) => JavascriptIterable<TOutput>): Iterable<TOutput>
205
- {
206
- return Iterable.flatMap(this, mapping);
207
- }
208
-
209
- public static flatMap<T,TOutput>(iterable: Iterable<T>, mapping: (value: T) => JavascriptIterable<TOutput>): Iterable<TOutput>
210
- {
211
- return FlatMapIterable.create(iterable, mapping);
212
- }
213
-
214
- /**
215
- * Get an {@link Iterable} that contains values from this {@link Iterable} that match the
216
- * provided condition.
217
- * @param condition The condition to run against each of the values in this {@link Iterable}.
218
- */
219
- public where(condition: (value: T) => (boolean | SyncResult<boolean>)): Iterable<T>
220
- {
221
- return Iterable.where(this, condition);
222
- }
223
-
224
- /**
225
- * Get an {@link Iterable} that contains values from the provided {@link Iterable} that match
226
- * the provided condition.
227
- * @param iterable The {@link Iterable} to get values from.
228
- * @param condition The condition that the values must match to be contained in the new
229
- * {@link Iterable}.
230
- */
231
- public static where<T>(iterable: JavascriptIterable<T>, condition: (value: T) => (boolean | SyncResult<boolean>)): Iterable<T>
232
- {
233
- PreCondition.assertNotUndefinedAndNotNull(iterable, "iterable");
234
- PreCondition.assertNotUndefinedAndNotNull(condition, "condition");
235
-
236
- if (!isIterable(iterable))
237
- {
238
- iterable = Iterable.create(iterable);
239
- }
240
- return WhereIterable.create(iterable as Iterable<T>, condition);
241
- }
242
-
243
- /**
244
- * Get an {@link Iterable} that contains values from this {@link Iterable} that match the
245
- * provided {@link Type} or type check function.
246
- * @param typeOrTypeCheck The {@link Type} or type check function that returned values must
247
- * match.
248
- */
249
- public instanceOf<TOutput extends T>(typeOrTypeCheck: Type<TOutput> | ((value: T) => value is TOutput)): Iterable<TOutput>
250
- {
251
- return Iterable.instanceOf(this, typeOrTypeCheck);
252
- }
253
-
254
- /**
255
- * Get an {@link Iterable} that contains values from the provided {@link Iterable} that match
256
- * the provided {@link Type} or type check function.
257
- * @param iterable The {@link Iterable} to get values from.
258
- * @param typeOrTypeCheck The {@link Type} or type check function that returned values must
259
- * match.
260
- */
261
- public static instanceOf<TInput, TOutput extends TInput>(iterable: JavascriptIterable<TInput>, typeOrTypeCheck: Type<TOutput> | ((value: TInput) => value is TOutput)): Iterable<TOutput>
262
- {
263
- PreCondition.assertNotUndefinedAndNotNull(iterable, "iterable");
264
- PreCondition.assertNotUndefinedAndNotNull(typeOrTypeCheck, "typeOrTypeCheck");
265
-
266
- return Iterable.where(iterable, (value: TInput) => instanceOf(value, typeOrTypeCheck))
267
- .map((value: TInput) => (value as unknown) as TOutput);
268
- }
269
-
270
- /**
271
- * Get the first value in this {@link Iterable}.
272
- */
273
- public first(condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>
274
- {
275
- return Iterable.first(this, condition);
276
- }
277
-
278
- /**
279
- * Get the first value from the provided {@link JavascriptIterable}.
280
- * @param iterable The {@link JavascriptIterable} to get the first value from.
281
- */
282
- public static first<T>(iterable: JavascriptIterable<T>, condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>
283
- {
284
- PreCondition.assertNotUndefinedAndNotNull(iterable, "iterable");
285
-
286
- return Iterator.create(iterable).first(condition);
287
- }
288
-
289
- /**
290
- * Get the last value in this {@link Iterable}.
291
- */
292
- public last(condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>
293
- {
294
- return Iterable.last(this, condition);
295
- }
296
-
297
- /**
298
- * Get the last value from the provided {@link JavascriptIterable}.
299
- * @param iterable The {@link JavascriptIterable} to get the last value from.
300
- */
301
- public static last<T>(iterable: JavascriptIterable<T>, condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>
302
- {
303
- PreCondition.assertNotUndefinedAndNotNull(iterable, "iterable");
304
-
305
- return Iterator.create(iterable).last(condition);
306
- }
307
-
308
- /**
309
- * Find the maximum value in the provided {@link Iterable}.
310
- * @param iterable The values to find the maximum of.
311
- */
312
- public static findMaximum<T extends Comparable<T>>(iterable: JavascriptIterable<T> | Iterable<T>): SyncResult<T>
313
- {
314
- PreCondition.assertNotUndefinedAndNotNull(iterable, "iterable");
315
-
316
- return Iterator.findMaximum(Iterator.create(iterable));
317
- }
318
-
319
- public contains(value: T, equalFunctions?: EqualFunctions): SyncResult<boolean>
320
- {
321
- return Iterable.contains(this, value, equalFunctions);
322
- }
323
-
324
- public static contains<T>(iterable: Iterable<T>, value: T, equalFunctions?: EqualFunctions): SyncResult<boolean>
325
- {
326
- return SyncResult.create(() =>
327
- {
328
- if (!equalFunctions)
329
- {
330
- equalFunctions = EqualFunctions.create();
331
- }
332
-
333
- let result: boolean = false;
334
- for (const iterableValue of iterable)
335
- {
336
- if (equalFunctions.areEqual(value, iterableValue).await())
337
- {
338
- result = true;
339
- break;
340
- }
341
- }
342
- return result;
343
- });
344
- }
345
- }