@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,175 +0,0 @@
1
- import { EqualFunctions } from "./equalFunctions";
2
- import { Iterable } from "./iterable";
3
- import { Iterator } from "./iterator";
4
- import { JavascriptIterable, JavascriptIterator } from "./javascript";
5
- import { List } from "./list";
6
- import { PreCondition } from "./preCondition";
7
- import { SyncResult } from "./syncResult";
8
- import { ToStringFunctions } from "./toStringFunctions";
9
- import { Type } from "./types";
10
-
11
- export class JavascriptArrayList<T> implements List<T>
12
- {
13
- private readonly array: T[];
14
-
15
- private constructor()
16
- {
17
- this.array = [];
18
- }
19
-
20
- public static create<T>(values?: JavascriptIterable<T>): JavascriptArrayList<T>
21
- {
22
- const result: JavascriptArrayList<T> = new JavascriptArrayList<T>();
23
- if (values)
24
- {
25
- result.addAll(values);
26
- }
27
- return result;
28
- }
29
-
30
- public set(index: number, value: T): this
31
- {
32
- PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
33
-
34
- this.array[index] = value;
35
-
36
- return this;
37
- }
38
-
39
- public iterate(): Iterator<T>
40
- {
41
- return Iterator.create(this.array);
42
- }
43
-
44
- public getCount(): SyncResult<number>
45
- {
46
- return SyncResult.value(this.array.length);
47
- }
48
-
49
- public get(index: number): SyncResult<T>
50
- {
51
- PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
52
-
53
- return SyncResult.value(this.array[index]);
54
- }
55
-
56
- public insert(index: number, value: T): this
57
- {
58
- PreCondition.assertInsertIndex(index, this.getCount().await(), "index");
59
-
60
- this.array.splice(index, 0, value);
61
-
62
- return this;
63
- }
64
-
65
- public insertAll(index: number, values: JavascriptIterable<T>): this
66
- {
67
- PreCondition.assertInsertIndex(index, this.getCount().await(), "index");
68
- PreCondition.assertNotUndefinedAndNotNull(values, "values");
69
-
70
- this.array.splice(index, 0, ...values);
71
-
72
- return this;
73
- }
74
-
75
- public removeAt(index: number): SyncResult<T>
76
- {
77
- PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
78
-
79
- return SyncResult.value(this.array.splice(index, 1)[0]);
80
- }
81
-
82
- public removeFirst(): SyncResult<T>
83
- {
84
- PreCondition.assertNotEmpty(this, "this");
85
-
86
- return SyncResult.value(this.array.shift()!);
87
- }
88
-
89
- public removeLast(): SyncResult<T>
90
- {
91
- PreCondition.assertNotEmpty(this, "this");
92
-
93
- return SyncResult.value(this.array.pop()!);
94
- }
95
-
96
- public add(value: T): this
97
- {
98
- return List.add(this, value);
99
- }
100
-
101
- public addAll(values: JavascriptIterable<T>): this
102
- {
103
- return List.addAll(this, values);
104
- }
105
-
106
- public remove(value: T, equalFunctions?: EqualFunctions): SyncResult<T>
107
- {
108
- return List.remove(this, value, equalFunctions);
109
- }
110
-
111
- public toArray(): SyncResult<T[]>
112
- {
113
- return SyncResult.value(this.array.slice());
114
- }
115
-
116
- public any(): SyncResult<boolean>
117
- {
118
- return List.any(this);
119
- }
120
-
121
- public equals(right: JavascriptIterable<T>, equalFunctions?: EqualFunctions): SyncResult<boolean>
122
- {
123
- return List.equals(this, right, equalFunctions);
124
- }
125
-
126
- public toString(toStringFunctions?: ToStringFunctions): string
127
- {
128
- return List.toString(this, toStringFunctions);
129
- }
130
-
131
- public concatenate(...toConcatenate: JavascriptIterable<T>[]): Iterable<T>
132
- {
133
- return List.concatenate(this, ...toConcatenate);
134
- }
135
-
136
- public map<TOutput>(mapping: (value: T) => (TOutput | SyncResult<TOutput>)): Iterable<TOutput>
137
- {
138
- return List.map(this, mapping);
139
- }
140
-
141
- public flatMap<TOutput>(mapping: (value: T) => JavascriptIterable<TOutput>): Iterable<TOutput>
142
- {
143
- return List.flatMap(this, mapping);
144
- }
145
-
146
- public where(condition: (value: T) => (boolean | SyncResult<boolean>)): Iterable<T>
147
- {
148
- return List.where(this, condition);
149
- }
150
-
151
- public instanceOf<TOutput extends T>(typeOrTypeCheck: Type<TOutput> | ((value: T) => value is TOutput)): Iterable<TOutput>
152
- {
153
- return List.instanceOf(this, typeOrTypeCheck);
154
- }
155
-
156
- public first(condition?: ((value: T) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<T>
157
- {
158
- return List.first(this, condition);
159
- }
160
-
161
- public last(condition?: ((value: T) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<T>
162
- {
163
- return List.last(this, condition);
164
- }
165
-
166
- public [Symbol.iterator](): JavascriptIterator<T>
167
- {
168
- return List[Symbol.iterator](this);
169
- }
170
-
171
- public contains(value: T, equalFunctions?: EqualFunctions): SyncResult<boolean>
172
- {
173
- return List.contains(this, value, equalFunctions);
174
- }
175
- }
@@ -1,124 +0,0 @@
1
- import { PromiseAsyncResult } from "./promiseAsyncResult";
2
- import { AsyncIterator } from "./asyncIterator";
3
- import { JavascriptAsyncIterable, JavascriptAsyncIterator, JavascriptIteratorResult } from "./javascript";
4
- import { PreCondition } from "./preCondition";
5
- import { isJavascriptAsyncIterable, Type } from "./types";
6
- import { AsyncIteratorToJavascriptAsyncIteratorAdapter } from "./asyncIteratorToJavascriptAsyncIteratorAdapter";
7
-
8
- export class JavascriptAsyncIteratorToAsyncIteratorAdapter<T> implements AsyncIterator<T>
9
- {
10
- private readonly javascriptIterator: JavascriptAsyncIterator<T>;
11
- private javascriptIteratorResult?: JavascriptIteratorResult<T>;
12
-
13
- private constructor(javascriptIterator: JavascriptAsyncIterator<T>)
14
- {
15
- PreCondition.assertNotUndefinedAndNotNull(javascriptIterator, "javascriptIterator");
16
-
17
- this.javascriptIterator = javascriptIterator;
18
- }
19
-
20
- public static create<T>(javascriptIterator: JavascriptAsyncIterator<T> | JavascriptAsyncIterable<T>): JavascriptAsyncIteratorToAsyncIteratorAdapter<T>
21
- {
22
- if (isJavascriptAsyncIterable<T>(javascriptIterator))
23
- {
24
- javascriptIterator = javascriptIterator[Symbol.asyncIterator]();
25
- }
26
- return new JavascriptAsyncIteratorToAsyncIteratorAdapter(javascriptIterator);
27
- }
28
-
29
- public next(): PromiseAsyncResult<boolean>
30
- {
31
- return PromiseAsyncResult.create(async () =>
32
- {
33
- this.javascriptIteratorResult = await this.javascriptIterator.next();
34
- return this.hasCurrent();
35
- });
36
- }
37
-
38
- public hasStarted(): boolean
39
- {
40
- return this.javascriptIteratorResult !== undefined;
41
- }
42
-
43
- public hasCurrent(): boolean
44
- {
45
- return this.javascriptIteratorResult?.done === false;
46
- }
47
-
48
- public getCurrent(): T
49
- {
50
- PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
51
-
52
- return this.javascriptIteratorResult!.value;
53
- }
54
-
55
- public start(): PromiseAsyncResult<this>
56
- {
57
- return AsyncIterator.start<T, this>(this);
58
- }
59
-
60
- public takeCurrent(): PromiseAsyncResult<T>
61
- {
62
- return AsyncIterator.takeCurrent(this);
63
- }
64
-
65
- public any(): PromiseAsyncResult<boolean>
66
- {
67
- return AsyncIterator.any(this);
68
- }
69
-
70
- public getCount(): PromiseAsyncResult<number>
71
- {
72
- return AsyncIterator.getCount(this);
73
- }
74
-
75
- public toArray(): PromiseAsyncResult<T[]>
76
- {
77
- return AsyncIterator.toArray(this);
78
- }
79
-
80
- public map<TOutput>(mapping: (value: T) => (TOutput | PromiseLike<TOutput>)): AsyncIterator<TOutput>
81
- {
82
- return AsyncIterator.map(this, mapping);
83
- }
84
-
85
- public [Symbol.asyncIterator](): JavascriptAsyncIterator<T>
86
- {
87
- return AsyncIterator[Symbol.asyncIterator](this);
88
- }
89
-
90
- public first(condition?: (value: T) => (boolean | PromiseLike<boolean>)): PromiseAsyncResult<T>
91
- {
92
- return AsyncIterator.first(this, condition);
93
- }
94
-
95
- public last(condition?: (value: T) => (boolean | PromiseLike<boolean>)): PromiseAsyncResult<T>
96
- {
97
- return AsyncIterator.last(this, condition);
98
- }
99
-
100
- public where(condition: (value: T) => (boolean | PromiseLike<boolean>)): AsyncIterator<T>
101
- {
102
- return AsyncIterator.where(this, condition);
103
- }
104
-
105
- public whereInstanceOf<U extends T>(typeCheck: (value: T) => value is U): AsyncIterator<U>
106
- {
107
- return AsyncIterator.whereInstanceOf(this, typeCheck);
108
- }
109
-
110
- public whereInstanceOfType<U extends T>(type: Type<U>): AsyncIterator<U>
111
- {
112
- return AsyncIterator.whereInstanceOfType(this, type);
113
- }
114
-
115
- public take(maximumToTake: number): AsyncIterator<T>
116
- {
117
- return AsyncIterator.take(this, maximumToTake);
118
- }
119
-
120
- public skip(maximumToSkip: number): AsyncIterator<T>
121
- {
122
- return AsyncIterator.skip(this, maximumToSkip);
123
- }
124
- }
@@ -1,133 +0,0 @@
1
- import { Iterator } from "./iterator";
2
- import { JavascriptIterable, JavascriptIterator, JavascriptIteratorResult } from "./javascript";
3
- import { PreCondition } from "./preCondition";
4
- import { SyncResult } from "./syncResult";
5
- import { isJavascriptIterable, Type } from "./types";
6
-
7
- export class JavascriptIteratorToIteratorAdapter<T> implements Iterator<T>
8
- {
9
- private readonly javascriptIterator: JavascriptIterator<T>;
10
- private javascriptIteratorResult?: JavascriptIteratorResult<T>;
11
-
12
- private constructor(javascriptIterator: JavascriptIterator<T>)
13
- {
14
- PreCondition.assertNotUndefinedAndNotNull(javascriptIterator, "javascriptIterator");
15
-
16
- this.javascriptIterator = javascriptIterator;
17
- }
18
-
19
- public static create<T>(javascriptIterator: JavascriptIterator<T> | JavascriptIterable<T>): JavascriptIteratorToIteratorAdapter<T>
20
- {
21
- if (isJavascriptIterable<T>(javascriptIterator))
22
- {
23
- javascriptIterator = javascriptIterator[Symbol.iterator]();
24
- }
25
- return new JavascriptIteratorToIteratorAdapter(javascriptIterator);
26
- }
27
-
28
- public next(): SyncResult<boolean>
29
- {
30
- return SyncResult.create(() =>
31
- {
32
- this.javascriptIteratorResult = this.javascriptIterator.next();
33
- return this.hasCurrent();
34
- });
35
- }
36
-
37
- public hasStarted(): boolean
38
- {
39
- return this.javascriptIteratorResult !== undefined;
40
- }
41
-
42
- public hasCurrent(): boolean
43
- {
44
- return this.javascriptIteratorResult?.done === false;
45
- }
46
-
47
- public getCurrent(): T
48
- {
49
- PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
50
-
51
- return this.javascriptIteratorResult!.value;
52
- }
53
-
54
- public start(): SyncResult<this>
55
- {
56
- return Iterator.start<T, this>(this);
57
- }
58
-
59
- public takeCurrent(): SyncResult<T>
60
- {
61
- return Iterator.takeCurrent(this);
62
- }
63
-
64
- public any(): SyncResult<boolean>
65
- {
66
- return Iterator.any(this);
67
- }
68
-
69
- public getCount(): SyncResult<number>
70
- {
71
- return Iterator.getCount(this);
72
- }
73
-
74
- public toArray(): SyncResult<T[]>
75
- {
76
- return Iterator.toArray(this);
77
- }
78
-
79
- public concatenate(...toConcatenate: JavascriptIterable<T>[]): Iterator<T>
80
- {
81
- return Iterator.concatenate(this, ...toConcatenate);
82
- }
83
-
84
- public map<TOutput>(mapping: (value: T) => (TOutput | SyncResult<TOutput>)): Iterator<TOutput>
85
- {
86
- return Iterator.map(this, mapping);
87
- }
88
-
89
- public flatMap<TOutput>(mapping: (value: T) => JavascriptIterable<TOutput>): Iterator<TOutput>
90
- {
91
- return Iterator.flatMap(this, mapping);
92
- }
93
-
94
- public [Symbol.iterator](): JavascriptIterator<T>
95
- {
96
- return Iterator[Symbol.iterator](this);
97
- }
98
-
99
- public first(condition?: (value: T) => boolean): SyncResult<T>
100
- {
101
- return Iterator.first(this, condition);
102
- }
103
-
104
- public last(): SyncResult<T>
105
- {
106
- return Iterator.last(this);
107
- }
108
-
109
- public where(condition: (value: T) => boolean): Iterator<T>
110
- {
111
- return Iterator.where(this, condition);
112
- }
113
-
114
- public whereInstanceOf<U extends T>(typeCheck: (value: T) => value is U): Iterator<U>
115
- {
116
- return Iterator.whereInstanceOf(this, typeCheck);
117
- }
118
-
119
- public whereInstanceOfType<U extends T>(type: Type<U>): Iterator<U>
120
- {
121
- return Iterator.whereInstanceOfType(this, type);
122
- }
123
-
124
- public take(maximumToTake: number): Iterator<T>
125
- {
126
- return Iterator.take(this, maximumToTake);
127
- }
128
-
129
- public skip(maximumToSkip: number): Iterator<T>
130
- {
131
- return Iterator.skip(this, maximumToSkip);
132
- }
133
- }
@@ -1,143 +0,0 @@
1
- import { EqualFunctions } from "./equalFunctions";
2
- import { Iterable } from "./iterable";
3
- import { Iterator } from "./iterator";
4
- import { JavascriptIterable, JavascriptIterator, JavascriptMap } from "./javascript";
5
- import { MapEntry } from "./map";
6
- import { MutableMap } from "./mutableMap";
7
- import { NotFoundError } from "./notFoundError";
8
- import { SyncResult } from "./syncResult";
9
- import { ToStringFunctions } from "./toStringFunctions";
10
- import { Type } from "./types";
11
-
12
- export class JavascriptMapMap<TKey,TValue> implements MutableMap<TKey,TValue>
13
- {
14
- private readonly javascriptMap: JavascriptMap<TKey,TValue>;
15
-
16
- private constructor()
17
- {
18
- this.javascriptMap = new JavascriptMap();
19
- }
20
-
21
- public static create<TKey,TValue>(): JavascriptMapMap<TKey,TValue>
22
- {
23
- return new JavascriptMapMap<TKey,TValue>();
24
- }
25
-
26
- public any(): SyncResult<boolean>
27
- {
28
- return SyncResult.value(this.javascriptMap.size > 0);
29
- }
30
-
31
- public getCount(): SyncResult<number>
32
- {
33
- return SyncResult.value(this.javascriptMap.size);
34
- }
35
-
36
- public containsKey(key: TKey): SyncResult<boolean>
37
- {
38
- return SyncResult.value(this.javascriptMap.has(key));
39
- }
40
-
41
- public get(key: TKey): SyncResult<TValue>
42
- {
43
- return this.containsKey(key).await()
44
- ? SyncResult.value(this.javascriptMap.get(key)!)
45
- : SyncResult.error(new NotFoundError(`The key ${JSON.stringify(key)} was not found in the map.`));
46
- }
47
-
48
- public set(key: TKey, value: TValue): this
49
- {
50
- this.javascriptMap.set(key, value);
51
-
52
- return this;
53
- }
54
-
55
- public remove(key: TKey): SyncResult<TValue>
56
- {
57
- const value: TValue | undefined = this.javascriptMap.get(key);
58
- return this.javascriptMap.delete(key)
59
- ? SyncResult.value(value!)
60
- : SyncResult.error(new NotFoundError(`The key ${JSON.stringify(key)} was not found in the map.`));
61
- }
62
-
63
- public iterate(): Iterator<MapEntry<TKey,TValue>>
64
- {
65
- return Iterator.create(this.javascriptMap.entries())
66
- .map((entry: [TKey,TValue]) => { return {key: entry[0], value: entry[1]}; });
67
- }
68
-
69
- public iterateKeys(): Iterator<TKey>
70
- {
71
- return Iterator.create(this.javascriptMap.keys());
72
- }
73
-
74
- public iterateValues(): Iterator<TValue>
75
- {
76
- return Iterator.create(this.javascriptMap.values());
77
- }
78
-
79
- public toArray(): SyncResult<MapEntry<TKey, TValue>[]>
80
- {
81
- return MutableMap.toArray(this);
82
- }
83
-
84
- public equals(right: Iterable<MapEntry<TKey, TValue>>, equalFunctions?: EqualFunctions): SyncResult<boolean>
85
- {
86
- return MutableMap.equals(this, right, equalFunctions);
87
- }
88
-
89
- public toString(toStringFunctions?: ToStringFunctions): string
90
- {
91
- return MutableMap.toString(this, toStringFunctions);
92
- }
93
-
94
- public concatenate(...toConcatenate: JavascriptIterable<MapEntry<TKey, TValue>>[]): Iterable<MapEntry<TKey, TValue>>
95
- {
96
- return MutableMap.concatenate(this, ...toConcatenate);
97
- }
98
-
99
- public map<TOutput>(mapping: (value: MapEntry<TKey, TValue>) => (TOutput | SyncResult<TOutput>)): Iterable<TOutput>
100
- {
101
- return MutableMap.map(this, mapping);
102
- }
103
-
104
- public flatMap<TOutput>(mapping: (value: MapEntry<TKey, TValue>) => JavascriptIterable<TOutput>): Iterable<TOutput>
105
- {
106
- return MutableMap.flatMap(this, mapping);
107
- }
108
-
109
- public where(condition: (value: MapEntry<TKey, TValue>) => (boolean | SyncResult<boolean>)): Iterable<MapEntry<TKey, TValue>>
110
- {
111
- return MutableMap.where(this, condition);
112
- }
113
-
114
- public instanceOf<T extends MapEntry<TKey, TValue>>(typeOrTypeCheck: Type<T> | ((value: MapEntry<TKey, TValue>) => value is T)): Iterable<T>
115
- {
116
- return MutableMap.instanceOf(this, typeOrTypeCheck);
117
- }
118
-
119
- public first(condition?: ((entry: MapEntry<TKey, TValue>) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<MapEntry<TKey, TValue>>
120
- {
121
- return MutableMap.first(this, condition);
122
- }
123
-
124
- public last(condition?: ((entry: MapEntry<TKey, TValue>) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<MapEntry<TKey, TValue>>
125
- {
126
- return MutableMap.last(this, condition);
127
- }
128
-
129
- public getOrSet(key: TKey, valueCreator: () => TValue | SyncResult<TValue>): SyncResult<TValue>
130
- {
131
- return MutableMap.getOrSet(this, key, valueCreator);
132
- }
133
-
134
- public [Symbol.iterator](): JavascriptIterator<MapEntry<TKey, TValue>>
135
- {
136
- return MutableMap[Symbol.iterator](this);
137
- }
138
-
139
- public contains(value: MapEntry<TKey, TValue>, equalFunctions?: EqualFunctions): SyncResult<boolean>
140
- {
141
- return MutableMap.contains(this, value, equalFunctions);
142
- }
143
- }
@@ -1,134 +0,0 @@
1
- import { EqualFunctions } from "./equalFunctions";
2
- import { Iterable } from "./iterable";
3
- import { Iterator } from "./iterator";
4
- import { JavascriptIterable, JavascriptIterator, JavascriptSet } from "./javascript";
5
- import { NotFoundError } from "./notFoundError";
6
- import { Set } from "./set";
7
- import { SyncResult } from "./syncResult";
8
- import { ToStringFunctions } from "./toStringFunctions";
9
- import { Type } from "./types";
10
-
11
- export class JavascriptSetSet<T> implements Set<T>
12
- {
13
- private readonly set: JavascriptSet<T>;
14
-
15
- private constructor()
16
- {
17
- this.set = new JavascriptSet<T>();
18
- }
19
-
20
- public static create<T>(initialValues?: JavascriptIterable<T>): JavascriptSetSet<T>
21
- {
22
- const result: JavascriptSetSet<T> = new JavascriptSetSet<T>();
23
- if (initialValues)
24
- {
25
- result.addAll(initialValues);
26
- }
27
- return result;
28
- }
29
-
30
- public add(value: T): this
31
- {
32
- this.set.add(value);
33
-
34
- return this;
35
- }
36
-
37
- public addAll(values: JavascriptIterable<T>): this
38
- {
39
- return Set.addAll(this, values);
40
- }
41
-
42
- public remove(value: T): SyncResult<void>
43
- {
44
- return SyncResult.create(() =>
45
- {
46
- if (!this.set.delete(value))
47
- {
48
- throw new NotFoundError(`Could not find ${JSON.stringify(value)}.`);
49
- }
50
- });
51
- }
52
-
53
- public union(values: JavascriptIterable<T>): Set<T>
54
- {
55
- return Set.union(this, values);
56
- }
57
-
58
- public iterate(): Iterator<T>
59
- {
60
- return Iterator.create(this.set);
61
- }
62
-
63
- public toArray(): SyncResult<T[]>
64
- {
65
- return Set.toArray(this);
66
- }
67
-
68
- public any(): SyncResult<boolean>
69
- {
70
- return Set.any(this);
71
- }
72
-
73
- public getCount(): SyncResult<number>
74
- {
75
- return SyncResult.value(this.set.size);
76
- }
77
-
78
- public equals(right: JavascriptIterable<T>, equalFunctions?: EqualFunctions): SyncResult<boolean>
79
- {
80
- return Set.equals(this, right, equalFunctions);
81
- }
82
-
83
- public toString(toStringFunctions?: ToStringFunctions): string
84
- {
85
- return Set.toString(this, toStringFunctions);
86
- }
87
-
88
- public concatenate(...toConcatenate: JavascriptIterable<T>[]): Iterable<T>
89
- {
90
- return Set.concatenate(this, ...toConcatenate);
91
- }
92
-
93
- public map<TOutput>(mapping: (value: T) => TOutput | SyncResult<TOutput>): Iterable<TOutput>
94
- {
95
- return Set.map(this, mapping);
96
- }
97
-
98
- public flatMap<TOutput>(mapping: (value: T) => JavascriptIterable<TOutput>): Iterable<TOutput>
99
- {
100
- return Set.flatMap(this, mapping);
101
- }
102
-
103
- public where(condition: (value: T) => (boolean | SyncResult<boolean>)): Iterable<T>
104
- {
105
- return Set.where(this, condition);
106
- }
107
-
108
- public instanceOf<TOutput extends T>(typeOrTypeCheck: Type<TOutput> | ((value: T) => value is TOutput)): Iterable<TOutput>
109
- {
110
- return Set.instanceOf(this, typeOrTypeCheck);
111
- }
112
-
113
- public first(condition?: ((value: T) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<T>
114
- {
115
- return Set.first(this, condition);
116
- }
117
-
118
- public last(condition?: ((value: T) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<T>
119
- {
120
- return Set.last(this, condition);
121
- }
122
-
123
- public contains(value: T, equalFunctions?: EqualFunctions): SyncResult<boolean>
124
- {
125
- return equalFunctions === undefined
126
- ? SyncResult.value(this.set.has(value))
127
- : Iterable.contains(this, value, equalFunctions);
128
- }
129
-
130
- public [Symbol.iterator](): JavascriptIterator<T>
131
- {
132
- return Set[Symbol.iterator](this);
133
- }
134
- }