@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.
- package/outputs/chunk-AY3YWKOM.js +7741 -0
- package/outputs/chunk-AY3YWKOM.js.map +1 -0
- package/outputs/sources.cjs +9007 -0
- package/outputs/sources.cjs.map +1 -0
- package/outputs/sources.d.cts +4082 -0
- package/outputs/sources.d.ts +4082 -0
- package/outputs/sources.js +1370 -0
- package/outputs/sources.js.map +1 -0
- package/outputs/tests.cjs +17208 -0
- package/outputs/tests.cjs.map +1 -0
- package/outputs/tests.d.cts +3 -0
- package/outputs/tests.d.ts +3 -0
- package/outputs/tests.js +9798 -0
- package/outputs/tests.js.map +1 -0
- package/package.json +11 -2
- package/.c8rc.json +0 -12
- package/.github/workflows/publish.yml +0 -36
- package/.mocharc.json +0 -9
- package/sources/assertMessageParameters.ts +0 -22
- package/sources/asyncIterator.ts +0 -437
- package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +0 -48
- package/sources/asyncResult.ts +0 -95
- package/sources/basicDisposable.ts +0 -57
- package/sources/byteList.ts +0 -202
- package/sources/byteListStream.ts +0 -121
- package/sources/byteReadStream.ts +0 -24
- package/sources/byteWriteStream.ts +0 -16
- package/sources/bytes.ts +0 -25
- package/sources/characterList.ts +0 -195
- package/sources/characterListStream.ts +0 -151
- package/sources/characterReadStream.ts +0 -81
- package/sources/characterReadStreamIterator.ts +0 -128
- package/sources/characterWriteStream.ts +0 -45
- package/sources/commandLineParameter.ts +0 -45
- package/sources/commandLineParameters.ts +0 -21
- package/sources/comparable.ts +0 -144
- package/sources/comparer.ts +0 -133
- package/sources/comparison.ts +0 -20
- package/sources/concatenateIterable.ts +0 -119
- package/sources/concatenateIterator.ts +0 -165
- package/sources/condition.ts +0 -329
- package/sources/currentProcess.ts +0 -158
- package/sources/dateTime.ts +0 -130
- package/sources/depthFirstSearch.ts +0 -230
- package/sources/disposable.ts +0 -31
- package/sources/emptyError.ts +0 -10
- package/sources/english.ts +0 -45
- package/sources/equalFunctions.ts +0 -123
- package/sources/fetchHttpClient.ts +0 -89
- package/sources/fetchHttpResponse.ts +0 -106
- package/sources/flatMapIterable.ts +0 -104
- package/sources/flatMapIterator.ts +0 -152
- package/sources/generator.ts +0 -251
- package/sources/httpClient.ts +0 -36
- package/sources/httpHeader.ts +0 -37
- package/sources/httpHeaders.ts +0 -216
- package/sources/httpIncomingRequest.ts +0 -30
- package/sources/httpIncomingResponse.ts +0 -19
- package/sources/httpMethod.ts +0 -164
- package/sources/httpOutgoingRequest.ts +0 -119
- package/sources/httpOutgoingResponse.ts +0 -113
- package/sources/httpServer.ts +0 -34
- package/sources/inMemoryCharacterWriteStream.ts +0 -78
- package/sources/index.ts +0 -101
- package/sources/iterable.ts +0 -345
- package/sources/iterator.ts +0 -481
- package/sources/iteratorToJavascriptIteratorAdapter.ts +0 -48
- package/sources/javascript.ts +0 -59
- package/sources/javascriptArrayList.ts +0 -175
- package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +0 -124
- package/sources/javascriptIteratorToIteratorAdapter.ts +0 -133
- package/sources/javascriptMapMap.ts +0 -143
- package/sources/javascriptSetSet.ts +0 -134
- package/sources/list.ts +0 -330
- package/sources/listQueue.ts +0 -62
- package/sources/listStack.ts +0 -62
- package/sources/luxonDateTime.ts +0 -109
- package/sources/map.ts +0 -302
- package/sources/mapAsyncIterator.ts +0 -141
- package/sources/mapIterable.ts +0 -105
- package/sources/mapIterator.ts +0 -145
- package/sources/mutableCondition.ts +0 -451
- package/sources/mutableHttpHeaders.ts +0 -204
- package/sources/mutableMap.ts +0 -292
- package/sources/network.ts +0 -18
- package/sources/node.ts +0 -37
- package/sources/nodeJSCharacterWriteStream.ts +0 -42
- package/sources/nodeJSHttpIncomingRequest.ts +0 -132
- package/sources/nodeJSHttpServer.ts +0 -134
- package/sources/notFoundError.ts +0 -12
- package/sources/postCondition.ts +0 -284
- package/sources/postConditionError.ts +0 -12
- package/sources/preCondition.ts +0 -284
- package/sources/preConditionError.ts +0 -12
- package/sources/promiseAsyncResult.ts +0 -174
- package/sources/property.ts +0 -63
- package/sources/queue.ts +0 -49
- package/sources/realNetwork.ts +0 -28
- package/sources/recreationDotGovClient.ts +0 -259
- package/sources/searchControl.ts +0 -42
- package/sources/set.ts +0 -244
- package/sources/skipAsyncIterator.ts +0 -145
- package/sources/skipIterator.ts +0 -155
- package/sources/stack.ts +0 -48
- package/sources/stringComparer.ts +0 -33
- package/sources/stringIterator.ts +0 -149
- package/sources/strings.ts +0 -322
- package/sources/syncResult.ts +0 -300
- package/sources/takeAsyncIterator.ts +0 -141
- package/sources/takeIterator.ts +0 -151
- package/sources/toStringFunctions.ts +0 -185
- package/sources/types.ts +0 -371
- package/sources/whereAsyncIterator.ts +0 -143
- package/sources/whereIterable.ts +0 -108
- package/sources/whereIterator.ts +0 -157
- package/sources/wonderlandTrailClient.ts +0 -1503
- package/tests/assertTest.ts +0 -113
- package/tests/assertTestTests.ts +0 -75
- package/tests/basicTestSkip.ts +0 -51
- package/tests/byteListStreamTests.ts +0 -390
- package/tests/byteListTests.ts +0 -27
- package/tests/bytesTests.ts +0 -43
- package/tests/characterListStreamTests.ts +0 -391
- package/tests/characterListTests.ts +0 -250
- package/tests/characterWriteStreamTests.ts +0 -12
- package/tests/comparerTests.ts +0 -92
- package/tests/conditionTests.ts +0 -877
- package/tests/consoleTestRunner.ts +0 -404
- package/tests/consoleTestRunnerTests.ts +0 -651
- package/tests/dateTimeTests.ts +0 -30
- package/tests/depthFirstSearchTests.ts +0 -106
- package/tests/disposableTests.ts +0 -121
- package/tests/englishTests.ts +0 -103
- package/tests/equalFunctionsTests.ts +0 -223
- package/tests/failedTest.ts +0 -43
- package/tests/fetchHttpClientTests.ts +0 -33
- package/tests/generatorTests.ts +0 -86
- package/tests/httpClientTests.ts +0 -18
- package/tests/inMemoryCharacterWriteStreamTests.ts +0 -117
- package/tests/iterableTests.ts +0 -141
- package/tests/iteratorTests.ts +0 -1086
- package/tests/javascriptMapMapTests.ts +0 -21
- package/tests/listTests.ts +0 -338
- package/tests/mapIteratorTests.ts +0 -55
- package/tests/mapTests.ts +0 -104
- package/tests/mutableConditionTests.ts +0 -273
- package/tests/mutableMapTests.ts +0 -154
- package/tests/nodeJSHttpServerTests.ts +0 -75
- package/tests/notFoundErrorTests.ts +0 -24
- package/tests/postConditionErrorTests.ts +0 -24
- package/tests/preConditionErrorTests.ts +0 -24
- package/tests/promiseAsyncResultTests.ts +0 -688
- package/tests/propertyTests.ts +0 -63
- package/tests/queueTests.ts +0 -29
- package/tests/recreationDotGovClientTests.ts +0 -191
- package/tests/setTests.ts +0 -140
- package/tests/skippedTest.ts +0 -39
- package/tests/stackTests.ts +0 -66
- package/tests/stringComparerTests.ts +0 -60
- package/tests/stringIteratorTests.ts +0 -156
- package/tests/stringsTests.ts +0 -516
- package/tests/syncResultTests.ts +0 -1251
- package/tests/test.ts +0 -228
- package/tests/testAction.ts +0 -75
- package/tests/testActionTests.ts +0 -93
- package/tests/testFailureTests.ts +0 -12
- package/tests/testRunner.ts +0 -267
- package/tests/testRunnerTests.ts +0 -895
- package/tests/testSkip.ts +0 -34
- package/tests/tests.ts +0 -103
- package/tests/toStringFunctionsTests.ts +0 -55
- package/tests/typesTests.ts +0 -257
- package/tests/whereIteratorTests.ts +0 -77
- package/tests/wonderlandTrailClientTests.ts +0 -452
- package/tsconfig.json +0 -20
- package/tsup.config.ts +0 -13
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Disposable } from "./disposable";
|
|
2
|
-
import { PreCondition } from "./preCondition";
|
|
3
|
-
import { SyncResult } from "./syncResult";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A {@link Disposable} type that can be configured with a function that will be invoked when the
|
|
7
|
-
* object is disposed.
|
|
8
|
-
*/
|
|
9
|
-
export class SyncDisposable implements Disposable
|
|
10
|
-
{
|
|
11
|
-
private readonly disposedFunction: () => void;
|
|
12
|
-
private disposed: boolean;
|
|
13
|
-
|
|
14
|
-
protected constructor(disposedFunction: () => void)
|
|
15
|
-
{
|
|
16
|
-
PreCondition.assertNotUndefinedAndNotNull(disposedFunction, "disposedFunction");
|
|
17
|
-
|
|
18
|
-
this.disposedFunction = disposedFunction;
|
|
19
|
-
this.disposed = false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Create a new {@link Disposable} that will invoke the provided {@link Function} when it is
|
|
24
|
-
* disposed.
|
|
25
|
-
* @param disposedFunction The function to invoke when the returned {@link Disposable} is
|
|
26
|
-
* disposed.
|
|
27
|
-
*/
|
|
28
|
-
public static create(disposedFunction: () => void): SyncDisposable
|
|
29
|
-
{
|
|
30
|
-
return new SyncDisposable(disposedFunction);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public dispose(): SyncResult<boolean>
|
|
34
|
-
{
|
|
35
|
-
return SyncResult.create(() =>
|
|
36
|
-
{
|
|
37
|
-
const result: boolean = !this.disposed;
|
|
38
|
-
if (result)
|
|
39
|
-
{
|
|
40
|
-
try
|
|
41
|
-
{
|
|
42
|
-
this.disposedFunction();
|
|
43
|
-
}
|
|
44
|
-
finally
|
|
45
|
-
{
|
|
46
|
-
this.disposed = true;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public isDisposed(): boolean
|
|
54
|
-
{
|
|
55
|
-
return this.disposed;
|
|
56
|
-
}
|
|
57
|
-
}
|
package/sources/byteList.ts
DELETED
|
@@ -1,202 +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
|
-
/**
|
|
12
|
-
* A {@link List} of bytes.
|
|
13
|
-
*/
|
|
14
|
-
export class ByteList implements List<number>
|
|
15
|
-
{
|
|
16
|
-
private bytes: Uint8Array;
|
|
17
|
-
private count: number;
|
|
18
|
-
|
|
19
|
-
private constructor()
|
|
20
|
-
{
|
|
21
|
-
this.bytes = new Uint8Array(0);
|
|
22
|
-
this.count = 0;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public static create(initialValues?: JavascriptIterable<number>): ByteList
|
|
26
|
-
{
|
|
27
|
-
const result: ByteList = new ByteList();
|
|
28
|
-
if (initialValues)
|
|
29
|
-
{
|
|
30
|
-
result.addAll(initialValues);
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public add(value: number): this
|
|
36
|
-
{
|
|
37
|
-
return List.add(this, value);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public addAll(values: JavascriptIterable<number>): this
|
|
41
|
-
{
|
|
42
|
-
return List.addAll(this, values);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public insert(index: number, value: number): this
|
|
46
|
-
{
|
|
47
|
-
PreCondition.assertInsertIndex(index, this.getCount().await(), "index");
|
|
48
|
-
PreCondition.assertByte(value, "value");
|
|
49
|
-
|
|
50
|
-
if (this.count < this.bytes.length)
|
|
51
|
-
{
|
|
52
|
-
if (index < this.count)
|
|
53
|
-
{
|
|
54
|
-
this.bytes.copyWithin(index + 1, index, this.count);
|
|
55
|
-
}
|
|
56
|
-
this.bytes[index] = value;
|
|
57
|
-
}
|
|
58
|
-
else
|
|
59
|
-
{
|
|
60
|
-
const newCapacity: number = (this.bytes.length * 2) + 1;
|
|
61
|
-
const newBytes: Uint8Array = new Uint8Array(newCapacity);
|
|
62
|
-
if (index > 0)
|
|
63
|
-
{
|
|
64
|
-
newBytes.set(this.bytes.subarray(0, index));
|
|
65
|
-
}
|
|
66
|
-
newBytes[index] = value;
|
|
67
|
-
if (index < this.count)
|
|
68
|
-
{
|
|
69
|
-
newBytes.set(this.bytes.subarray(index), index + 1);
|
|
70
|
-
}
|
|
71
|
-
this.bytes = newBytes;
|
|
72
|
-
}
|
|
73
|
-
this.count++;
|
|
74
|
-
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public insertAll(index: number, values: JavascriptIterable<number>): this
|
|
79
|
-
{
|
|
80
|
-
return List.insertAll(this, index, values);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public remove(value: number, equalFunctions?: EqualFunctions): SyncResult<number>
|
|
84
|
-
{
|
|
85
|
-
PreCondition.assertByte(value, "value");
|
|
86
|
-
|
|
87
|
-
return List.remove(this, value, equalFunctions);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public removeAt(index: number): SyncResult<number>
|
|
91
|
-
{
|
|
92
|
-
PreCondition.assertAccessIndex(index, this.count, "index");
|
|
93
|
-
|
|
94
|
-
const result: number = this.bytes[index];
|
|
95
|
-
this.bytes.copyWithin(index, index + 1, this.count);
|
|
96
|
-
this.count--;
|
|
97
|
-
|
|
98
|
-
return SyncResult.value(result);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
public removeFirst(): SyncResult<number>
|
|
102
|
-
{
|
|
103
|
-
return List.removeFirst(this);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
public removeLast(): SyncResult<number>
|
|
107
|
-
{
|
|
108
|
-
return List.removeLast(this);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
public set(index: number, value: number): this
|
|
112
|
-
{
|
|
113
|
-
PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
|
|
114
|
-
PreCondition.assertByte(value, "value");
|
|
115
|
-
|
|
116
|
-
this.bytes[index] = value;
|
|
117
|
-
|
|
118
|
-
return this;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public iterate(): Iterator<number>
|
|
122
|
-
{
|
|
123
|
-
return Iterator.create(this.bytes[Symbol.iterator]().take(this.count));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
public get(index: number): SyncResult<number>
|
|
127
|
-
{
|
|
128
|
-
PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
|
|
129
|
-
|
|
130
|
-
return SyncResult.value(this.bytes.at(index)!);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
public toArray(): SyncResult<number[]>
|
|
134
|
-
{
|
|
135
|
-
return List.toArray(this);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
public any(): SyncResult<boolean>
|
|
139
|
-
{
|
|
140
|
-
return this.getCount().then(count => count > 0);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
public getCount(): SyncResult<number>
|
|
144
|
-
{
|
|
145
|
-
return SyncResult.value(this.count);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public equals(right: JavascriptIterable<number>, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
149
|
-
{
|
|
150
|
-
return List.equals(this, right, equalFunctions);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
public toString(toStringFunctions?: ToStringFunctions): string
|
|
154
|
-
{
|
|
155
|
-
return List.toString(this, toStringFunctions);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
public concatenate(...toConcatenate: JavascriptIterable<number>[]): Iterable<number>
|
|
159
|
-
{
|
|
160
|
-
return List.concatenate(this, ...toConcatenate);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
public map<TOutput>(mapping: (value: number) => TOutput | SyncResult<TOutput>): Iterable<TOutput>
|
|
164
|
-
{
|
|
165
|
-
return List.map(this, mapping);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
public flatMap<TOutput>(mapping: (value: number) => JavascriptIterable<TOutput>): Iterable<TOutput>
|
|
169
|
-
{
|
|
170
|
-
return List.flatMap(this, mapping);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
public where(condition: (value: number) => (boolean | SyncResult<boolean>)): Iterable<number>
|
|
174
|
-
{
|
|
175
|
-
return List.where(this, condition);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
public instanceOf<TOutput extends number>(typeOrTypeCheck: Type<TOutput> | ((value: number) => value is TOutput)): Iterable<TOutput>
|
|
179
|
-
{
|
|
180
|
-
return List.instanceOf(this, typeOrTypeCheck);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
public first(condition?: ((value: number) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<number>
|
|
184
|
-
{
|
|
185
|
-
return List.first(this, condition);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
public last(condition?: ((value: number) => (boolean | SyncResult<boolean>)) | undefined): SyncResult<number>
|
|
189
|
-
{
|
|
190
|
-
return List.last(this, condition);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
public contains(value: number, equalFunctions?: EqualFunctions): SyncResult<boolean>
|
|
194
|
-
{
|
|
195
|
-
return List.contains(this, value, equalFunctions);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
public [Symbol.iterator](): JavascriptIterator<number>
|
|
199
|
-
{
|
|
200
|
-
return List[Symbol.iterator](this);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { ByteList } from "./byteList";
|
|
2
|
-
import { ByteReadStream } from "./byteReadStream";
|
|
3
|
-
import { ByteWriteStream } from "./byteWriteStream";
|
|
4
|
-
import { EmptyError } from "./emptyError";
|
|
5
|
-
import { PreCondition } from "./preCondition";
|
|
6
|
-
import { SyncResult } from "./syncResult";
|
|
7
|
-
import { isArray, isNumber, isUndefinedOrNull } from "./types";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A {@link ByteReadStream} and {@link ByteWriteStream} implementation that is implemented using a
|
|
11
|
-
* {@link ByteList}.
|
|
12
|
-
*/
|
|
13
|
-
export class ByteListStream implements ByteReadStream, ByteWriteStream
|
|
14
|
-
{
|
|
15
|
-
private readonly list: ByteList;
|
|
16
|
-
|
|
17
|
-
private constructor()
|
|
18
|
-
{
|
|
19
|
-
this.list = ByteList.create();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public static create(initialValues?: Uint8Array | number[]): ByteListStream
|
|
23
|
-
{
|
|
24
|
-
const result: ByteListStream = new ByteListStream();
|
|
25
|
-
if (initialValues)
|
|
26
|
-
{
|
|
27
|
-
result.writeBytes(initialValues).await();
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Get the number of bytes that are available to be read.
|
|
34
|
-
*/
|
|
35
|
-
public getAvailableByteCount(): number
|
|
36
|
-
{
|
|
37
|
-
return this.list.getCount().await();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public writeBytes(bytes: Uint8Array | number[], startIndex?: number, length?: number): SyncResult<number>
|
|
41
|
-
{
|
|
42
|
-
PreCondition.assertNotUndefinedAndNotNull(bytes, "bytes");
|
|
43
|
-
|
|
44
|
-
if (isArray(bytes))
|
|
45
|
-
{
|
|
46
|
-
bytes = new Uint8Array(bytes);
|
|
47
|
-
}
|
|
48
|
-
if (isUndefinedOrNull(startIndex))
|
|
49
|
-
{
|
|
50
|
-
startIndex = 0;
|
|
51
|
-
}
|
|
52
|
-
if (isUndefinedOrNull(length))
|
|
53
|
-
{
|
|
54
|
-
length = bytes.length - startIndex;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
PreCondition.assertInsertIndex(startIndex, bytes.length, "startIndex");
|
|
58
|
-
PreCondition.assertBetween(0, length, bytes.length - startIndex, "length");
|
|
59
|
-
|
|
60
|
-
this.list.addAll(bytes.subarray(startIndex, length + startIndex));
|
|
61
|
-
|
|
62
|
-
return SyncResult.value(length);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public readBytes(count: number): SyncResult<Uint8Array>;
|
|
66
|
-
public readBytes(output: Uint8Array, startIndex?: number, count?: number): SyncResult<number>;
|
|
67
|
-
readBytes(countOrOutput: number | Uint8Array, startIndex?: number, count?: number): SyncResult<number> | SyncResult<Uint8Array>
|
|
68
|
-
{
|
|
69
|
-
let result: SyncResult<number> | SyncResult<Uint8Array>;
|
|
70
|
-
if (isNumber(countOrOutput))
|
|
71
|
-
{
|
|
72
|
-
PreCondition.assertGreaterThanOrEqualTo(countOrOutput, 0, "count");
|
|
73
|
-
|
|
74
|
-
if (!this.list.any().await())
|
|
75
|
-
{
|
|
76
|
-
result = SyncResult.error<Uint8Array>(new EmptyError());
|
|
77
|
-
}
|
|
78
|
-
else
|
|
79
|
-
{
|
|
80
|
-
const bytesReadCount: number = Math.min(countOrOutput, this.list.getCount().await());
|
|
81
|
-
const output: Uint8Array = new Uint8Array(bytesReadCount);
|
|
82
|
-
for (let i = 0; i < bytesReadCount; i++)
|
|
83
|
-
{
|
|
84
|
-
output[i] = this.list.removeFirst().await();
|
|
85
|
-
}
|
|
86
|
-
result = SyncResult.value(output);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else
|
|
90
|
-
{
|
|
91
|
-
PreCondition.assertNotUndefinedAndNotNull(countOrOutput, "output");
|
|
92
|
-
|
|
93
|
-
if (isUndefinedOrNull(startIndex))
|
|
94
|
-
{
|
|
95
|
-
startIndex = 0;
|
|
96
|
-
}
|
|
97
|
-
if (isUndefinedOrNull(count))
|
|
98
|
-
{
|
|
99
|
-
count = countOrOutput.length - startIndex;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
PreCondition.assertInsertIndex(startIndex, countOrOutput.length, "startIndex");
|
|
103
|
-
PreCondition.assertBetween(0, count, countOrOutput.length - startIndex, "count");
|
|
104
|
-
|
|
105
|
-
if (!this.list.any().await())
|
|
106
|
-
{
|
|
107
|
-
result = SyncResult.error<number>(new EmptyError());
|
|
108
|
-
}
|
|
109
|
-
else
|
|
110
|
-
{
|
|
111
|
-
const bytesReadCount: number = Math.min(count, this.list.getCount().await());
|
|
112
|
-
for (let i = 0; i < bytesReadCount; i++)
|
|
113
|
-
{
|
|
114
|
-
countOrOutput[startIndex + i] = this.list.removeFirst().await();
|
|
115
|
-
}
|
|
116
|
-
result = SyncResult.value(bytesReadCount);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return result;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|
package/sources/bytes.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A collection of values and functions for interacting with bytes.
|
|
3
|
-
*/
|
|
4
|
-
export abstract class Bytes
|
|
5
|
-
{
|
|
6
|
-
/**
|
|
7
|
-
* The minimum value that a byte can have.
|
|
8
|
-
*/
|
|
9
|
-
public static readonly minimumValue: number = 0;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The maximum value (inclusive) that a byte can have.
|
|
13
|
-
*/
|
|
14
|
-
public static readonly maximumValue: number = 255;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Get whether the provided value is within the range of a valid byte (between 0 and
|
|
18
|
-
* 255).
|
|
19
|
-
* @param value The value to check.
|
|
20
|
-
*/
|
|
21
|
-
public static isByte(value: number): boolean
|
|
22
|
-
{
|
|
23
|
-
return Bytes.minimumValue <= value && value <= Bytes.maximumValue;
|
|
24
|
-
}
|
|
25
|
-
}
|
package/sources/characterList.ts
DELETED
|
@@ -1,195 +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 { 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
|
-
}
|