@everyonesoftware/common 2.0.0 → 3.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 (59) hide show
  1. package/.github/workflows/publish.yml +54 -36
  2. package/package.json +6 -2
  3. package/sources/asyncIterator.ts +436 -436
  4. package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +47 -47
  5. package/sources/asyncResult.ts +95 -95
  6. package/sources/byteList.ts +201 -201
  7. package/sources/byteListStream.ts +120 -120
  8. package/sources/byteReadStream.ts +23 -23
  9. package/sources/byteWriteStream.ts +15 -15
  10. package/sources/characterList.ts +194 -194
  11. package/sources/characterListStream.ts +150 -150
  12. package/sources/characterReadStream.ts +80 -80
  13. package/sources/characterReadStreamIterator.ts +127 -127
  14. package/sources/concatenateIterable.ts +118 -118
  15. package/sources/concatenateIterator.ts +164 -164
  16. package/sources/currentProcess.ts +157 -157
  17. package/sources/dateTime.ts +129 -129
  18. package/sources/depthFirstSearch.ts +229 -229
  19. package/sources/flatMapIterable.ts +103 -103
  20. package/sources/flatMapIterator.ts +151 -151
  21. package/sources/generator.ts +250 -250
  22. package/sources/index.ts +1 -1
  23. package/sources/iterator.ts +480 -480
  24. package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +123 -123
  25. package/sources/javascriptSetSet.ts +133 -133
  26. package/sources/listQueue.ts +61 -61
  27. package/sources/listStack.ts +61 -61
  28. package/sources/luxonDateTime.ts +108 -108
  29. package/sources/mapAsyncIterator.ts +140 -140
  30. package/sources/mutableMap.ts +291 -291
  31. package/sources/node.ts +36 -36
  32. package/sources/promiseAsyncResult.ts +173 -173
  33. package/sources/queue.ts +48 -48
  34. package/sources/recreationDotGovClient.ts +258 -258
  35. package/sources/searchControl.ts +41 -41
  36. package/sources/set.ts +243 -243
  37. package/sources/skipAsyncIterator.ts +144 -144
  38. package/sources/stack.ts +47 -47
  39. package/sources/syncResult.ts +299 -299
  40. package/sources/takeAsyncIterator.ts +140 -140
  41. package/sources/whereAsyncIterator.ts +142 -142
  42. package/sources/wonderlandTrailClient.ts +1502 -1502
  43. package/tests/assertTestTests.ts +74 -74
  44. package/tests/byteListStreamTests.ts +389 -389
  45. package/tests/byteListTests.ts +26 -26
  46. package/tests/characterListStreamTests.ts +390 -390
  47. package/tests/characterListTests.ts +249 -249
  48. package/tests/dateTimeTests.ts +29 -29
  49. package/tests/depthFirstSearchTests.ts +105 -105
  50. package/tests/generatorTests.ts +85 -85
  51. package/tests/mutableMapTests.ts +153 -153
  52. package/tests/promiseAsyncResultTests.ts +687 -687
  53. package/tests/queueTests.ts +28 -28
  54. package/tests/recreationDotGovClientTests.ts +190 -190
  55. package/tests/setTests.ts +139 -139
  56. package/tests/stackTests.ts +65 -65
  57. package/tests/syncResultTests.ts +1250 -1250
  58. package/tests/wonderlandTrailClientTests.ts +451 -451
  59. package/tsup.config.ts +12 -12
@@ -1,24 +1,24 @@
1
- import { AsyncResult } from "./asyncResult";
2
-
3
- /**
4
- * A stream that reads bytes.
5
- */
6
- export abstract class ByteReadStream
7
- {
8
- /**
9
- * Attempt to read the provided {@link count} number of bytes. Returns the bytes that were read.
10
- * The number of bytes returned may be less than the number requested.
11
- * @param count The number of bytes to attempt to read.
12
- */
13
- public abstract readBytes(count: number): AsyncResult<Uint8Array>;
14
- /**
15
- * Attempt to read bytes into the provided output array. Returns the number of bytes that were
16
- * read.
17
- * @param output The array that the read bytes will be written to.
18
- * @param startIndex The index in the {@link output} array to start writting the read bytes to.
19
- * Defaults to 0.
20
- * @param count The maximum number of bytes to read. Defaults to the length of the output array
21
- * minus the startIndex.
22
- */
23
- public abstract readBytes(output: Uint8Array, startIndex?: number, count?: number): AsyncResult<number>;
1
+ import { AsyncResult } from "./asyncResult";
2
+
3
+ /**
4
+ * A stream that reads bytes.
5
+ */
6
+ export abstract class ByteReadStream
7
+ {
8
+ /**
9
+ * Attempt to read the provided {@link count} number of bytes. Returns the bytes that were read.
10
+ * The number of bytes returned may be less than the number requested.
11
+ * @param count The number of bytes to attempt to read.
12
+ */
13
+ public abstract readBytes(count: number): AsyncResult<Uint8Array>;
14
+ /**
15
+ * Attempt to read bytes into the provided output array. Returns the number of bytes that were
16
+ * read.
17
+ * @param output The array that the read bytes will be written to.
18
+ * @param startIndex The index in the {@link output} array to start writting the read bytes to.
19
+ * Defaults to 0.
20
+ * @param count The maximum number of bytes to read. Defaults to the length of the output array
21
+ * minus the startIndex.
22
+ */
23
+ public abstract readBytes(output: Uint8Array, startIndex?: number, count?: number): AsyncResult<number>;
24
24
  }
@@ -1,16 +1,16 @@
1
- import { AsyncResult } from "./asyncResult";
2
-
3
- /**
4
- * A stream that writes bytes.
5
- */
6
- export abstract class ByteWriteStream
7
- {
8
- /**
9
- * Write the provided bytes to this {@link ByteWriteStream}.
10
- * @param bytes The bytes to write.
11
- * @param startIndex The index to start writing from.
12
- * @param length The number of bytes to write.
13
- * @returns The number of bytes that were written.
14
- */
15
- public abstract writeBytes(bytes: Uint8Array | number[], startIndex?: number, length?: number): AsyncResult<number>
1
+ import { AsyncResult } from "./asyncResult";
2
+
3
+ /**
4
+ * A stream that writes bytes.
5
+ */
6
+ export abstract class ByteWriteStream
7
+ {
8
+ /**
9
+ * Write the provided bytes to this {@link ByteWriteStream}.
10
+ * @param bytes The bytes to write.
11
+ * @param startIndex The index to start writing from.
12
+ * @param length The number of bytes to write.
13
+ * @returns The number of bytes that were written.
14
+ */
15
+ public abstract writeBytes(bytes: Uint8Array | number[], startIndex?: number, length?: number): AsyncResult<number>
16
16
  }
@@ -1,195 +1,195 @@
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 { StringIterator } from "./stringIterator";
8
- import { join } from "./strings";
9
- import { SyncResult } from "./syncResult";
10
- import { ToStringFunctions } from "./toStringFunctions";
11
- import { isString, Type } from "./types";
12
-
13
- export class CharacterList implements List<string>
14
- {
15
- private characters: string;
16
-
17
- private constructor(values?: JavascriptIterable<string> | string)
18
- {
19
- if (isString(values))
20
- {
21
- this.characters = values;
22
- }
23
- else if (values)
24
- {
25
- this.characters = join("", values);
26
- }
27
- else
28
- {
29
- this.characters = "";
30
- }
31
- }
32
-
33
- public static create(values?: JavascriptIterable<string>): CharacterList
34
- {
35
- return new CharacterList(values);
36
- }
37
-
38
- public getCount(): SyncResult<number>
39
- {
40
- return SyncResult.value(this.characters.length);
41
- }
42
-
43
- public insert(index: number, value: string): this
44
- {
45
- PreCondition.assertInsertIndex(index, this.getCount().await(), "index");
46
- PreCondition.assertCharacter(value, "value");
47
-
48
- if (index === 0)
49
- {
50
- this.characters = value + this.characters;
51
- }
52
- else if (index === this.getCount().await())
53
- {
54
- this.characters += value;
55
- }
56
- else
57
- {
58
- this.characters = this.characters.slice(0, index) + value + this.characters.slice(index);
59
- }
60
-
61
- return this;
62
- }
63
-
64
- public removeAt(index: number): SyncResult<string>
65
- {
66
- PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
67
-
68
- const result: string = this.get(index).await();
69
- this.characters =
70
- (index === 0 ? "" : this.characters.slice(0, index)) +
71
- (index === this.getCount().await() - 1 ? "" : this.characters.slice(index + 1));
72
-
73
- return SyncResult.value(result);
74
- }
75
-
76
- public set(index: number, value: string): this
77
- {
78
- PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
79
- PreCondition.assertCharacter(value, "value");
80
-
81
- this.characters =
82
- (index === 0 ? "" : this.characters.slice(0, index)) +
83
- value +
84
- (index === this.getCount().await() - 1 ? "" : this.characters.slice(index + 1));
85
-
86
- return this;
87
- }
88
-
89
- public iterate(): Iterator<string>
90
- {
91
- return StringIterator.create(this.characters);
92
- }
93
-
94
- public get(index: number): SyncResult<string>
95
- {
96
- PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
97
-
98
- return SyncResult.value(this.characters.charAt(index));
99
- }
100
-
101
- public add(value: string): this
102
- {
103
- return List.add(this, value);
104
- }
105
-
106
- public addAll(values: JavascriptIterable<string>): this
107
- {
108
- return List.addAll(this, values);
109
- }
110
-
111
- public insertAll(index: number, values: JavascriptIterable<string>): this
112
- {
113
- return List.insertAll(this, index, values);
114
- }
115
-
116
- public remove(value: string, equalFunctions?: EqualFunctions): SyncResult<string>
117
- {
118
- return List.remove(this, value, equalFunctions);
119
- }
120
-
121
- public removeFirst(): SyncResult<string>
122
- {
123
- return List.removeFirst(this);
124
- }
125
-
126
- public removeLast(): SyncResult<string>
127
- {
128
- return List.removeLast(this);
129
- }
130
-
131
- public toArray(): SyncResult<string[]>
132
- {
133
- return List.toArray(this);
134
- }
135
-
136
- public any(): SyncResult<boolean>
137
- {
138
- return List.any(this);
139
- }
140
-
141
- public equals(right: JavascriptIterable<string>, equalFunctions?: EqualFunctions): SyncResult<boolean>
142
- {
143
- return List.equals(this, right, equalFunctions);
144
- }
145
-
146
- public toString(toStringFunctions?: ToStringFunctions): string
147
- {
148
- return List.toString(this, toStringFunctions);
149
- }
150
-
151
- public concatenate(...toConcatenate: JavascriptIterable<string>[]): Iterable<string>
152
- {
153
- return List.concatenate(this, ...toConcatenate);
154
- }
155
-
156
- public map<TOutput>(mapping: (value: string) => TOutput | SyncResult<TOutput>): Iterable<TOutput>
157
- {
158
- return List.map(this, mapping);
159
- }
160
-
161
- public flatMap<TOutput>(mapping: (value: string) => JavascriptIterable<TOutput>): Iterable<TOutput>
162
- {
163
- return List.flatMap(this, mapping);
164
- }
165
-
166
- public where(condition: (value: string) => (boolean | SyncResult<boolean>)): Iterable<string>
167
- {
168
- return List.where(this, condition);
169
- }
170
-
171
- public instanceOf<TOutput extends string>(typeOrTypeCheck: Type<TOutput> | ((value: string) => value is TOutput)): Iterable<TOutput>
172
- {
173
- return List.instanceOf(this, typeOrTypeCheck);
174
- }
175
-
176
- public first(condition?: (value: string) => (boolean | SyncResult<boolean>)): SyncResult<string>
177
- {
178
- return List.first(this, condition);
179
- }
180
-
181
- public last(condition?: (value: string) => (boolean | SyncResult<boolean>)): SyncResult<string>
182
- {
183
- return List.last(this, condition);
184
- }
185
-
186
- public contains(value: string, equalFunctions?: EqualFunctions): SyncResult<boolean>
187
- {
188
- return List.contains(this, value, equalFunctions);
189
- }
190
-
191
- public [Symbol.iterator](): JavascriptIterator<string>
192
- {
193
- return List[Symbol.iterator](this);
194
- }
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 { StringIterator } from "./stringIterator";
8
+ import { join } from "./strings";
9
+ import { SyncResult } from "./syncResult";
10
+ import { ToStringFunctions } from "./toStringFunctions";
11
+ import { isString, Type } from "./types";
12
+
13
+ export class CharacterList implements List<string>
14
+ {
15
+ private characters: string;
16
+
17
+ private constructor(values?: JavascriptIterable<string> | string)
18
+ {
19
+ if (isString(values))
20
+ {
21
+ this.characters = values;
22
+ }
23
+ else if (values)
24
+ {
25
+ this.characters = join("", values);
26
+ }
27
+ else
28
+ {
29
+ this.characters = "";
30
+ }
31
+ }
32
+
33
+ public static create(values?: JavascriptIterable<string>): CharacterList
34
+ {
35
+ return new CharacterList(values);
36
+ }
37
+
38
+ public getCount(): SyncResult<number>
39
+ {
40
+ return SyncResult.value(this.characters.length);
41
+ }
42
+
43
+ public insert(index: number, value: string): this
44
+ {
45
+ PreCondition.assertInsertIndex(index, this.getCount().await(), "index");
46
+ PreCondition.assertCharacter(value, "value");
47
+
48
+ if (index === 0)
49
+ {
50
+ this.characters = value + this.characters;
51
+ }
52
+ else if (index === this.getCount().await())
53
+ {
54
+ this.characters += value;
55
+ }
56
+ else
57
+ {
58
+ this.characters = this.characters.slice(0, index) + value + this.characters.slice(index);
59
+ }
60
+
61
+ return this;
62
+ }
63
+
64
+ public removeAt(index: number): SyncResult<string>
65
+ {
66
+ PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
67
+
68
+ const result: string = this.get(index).await();
69
+ this.characters =
70
+ (index === 0 ? "" : this.characters.slice(0, index)) +
71
+ (index === this.getCount().await() - 1 ? "" : this.characters.slice(index + 1));
72
+
73
+ return SyncResult.value(result);
74
+ }
75
+
76
+ public set(index: number, value: string): this
77
+ {
78
+ PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
79
+ PreCondition.assertCharacter(value, "value");
80
+
81
+ this.characters =
82
+ (index === 0 ? "" : this.characters.slice(0, index)) +
83
+ value +
84
+ (index === this.getCount().await() - 1 ? "" : this.characters.slice(index + 1));
85
+
86
+ return this;
87
+ }
88
+
89
+ public iterate(): Iterator<string>
90
+ {
91
+ return StringIterator.create(this.characters);
92
+ }
93
+
94
+ public get(index: number): SyncResult<string>
95
+ {
96
+ PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
97
+
98
+ return SyncResult.value(this.characters.charAt(index));
99
+ }
100
+
101
+ public add(value: string): this
102
+ {
103
+ return List.add(this, value);
104
+ }
105
+
106
+ public addAll(values: JavascriptIterable<string>): this
107
+ {
108
+ return List.addAll(this, values);
109
+ }
110
+
111
+ public insertAll(index: number, values: JavascriptIterable<string>): this
112
+ {
113
+ return List.insertAll(this, index, values);
114
+ }
115
+
116
+ public remove(value: string, equalFunctions?: EqualFunctions): SyncResult<string>
117
+ {
118
+ return List.remove(this, value, equalFunctions);
119
+ }
120
+
121
+ public removeFirst(): SyncResult<string>
122
+ {
123
+ return List.removeFirst(this);
124
+ }
125
+
126
+ public removeLast(): SyncResult<string>
127
+ {
128
+ return List.removeLast(this);
129
+ }
130
+
131
+ public toArray(): SyncResult<string[]>
132
+ {
133
+ return List.toArray(this);
134
+ }
135
+
136
+ public any(): SyncResult<boolean>
137
+ {
138
+ return List.any(this);
139
+ }
140
+
141
+ public equals(right: JavascriptIterable<string>, equalFunctions?: EqualFunctions): SyncResult<boolean>
142
+ {
143
+ return List.equals(this, right, equalFunctions);
144
+ }
145
+
146
+ public toString(toStringFunctions?: ToStringFunctions): string
147
+ {
148
+ return List.toString(this, toStringFunctions);
149
+ }
150
+
151
+ public concatenate(...toConcatenate: JavascriptIterable<string>[]): Iterable<string>
152
+ {
153
+ return List.concatenate(this, ...toConcatenate);
154
+ }
155
+
156
+ public map<TOutput>(mapping: (value: string) => TOutput | SyncResult<TOutput>): Iterable<TOutput>
157
+ {
158
+ return List.map(this, mapping);
159
+ }
160
+
161
+ public flatMap<TOutput>(mapping: (value: string) => JavascriptIterable<TOutput>): Iterable<TOutput>
162
+ {
163
+ return List.flatMap(this, mapping);
164
+ }
165
+
166
+ public where(condition: (value: string) => (boolean | SyncResult<boolean>)): Iterable<string>
167
+ {
168
+ return List.where(this, condition);
169
+ }
170
+
171
+ public instanceOf<TOutput extends string>(typeOrTypeCheck: Type<TOutput> | ((value: string) => value is TOutput)): Iterable<TOutput>
172
+ {
173
+ return List.instanceOf(this, typeOrTypeCheck);
174
+ }
175
+
176
+ public first(condition?: (value: string) => (boolean | SyncResult<boolean>)): SyncResult<string>
177
+ {
178
+ return List.first(this, condition);
179
+ }
180
+
181
+ public last(condition?: (value: string) => (boolean | SyncResult<boolean>)): SyncResult<string>
182
+ {
183
+ return List.last(this, condition);
184
+ }
185
+
186
+ public contains(value: string, equalFunctions?: EqualFunctions): SyncResult<boolean>
187
+ {
188
+ return List.contains(this, value, equalFunctions);
189
+ }
190
+
191
+ public [Symbol.iterator](): JavascriptIterator<string>
192
+ {
193
+ return List[Symbol.iterator](this);
194
+ }
195
195
  }