@everyonesoftware/common 1.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.
- package/.github/workflows/publish.yml +54 -38
- package/package.json +9 -2
- package/sources/asyncIterator.ts +436 -436
- package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +47 -47
- package/sources/asyncResult.ts +95 -95
- package/sources/byteList.ts +201 -201
- package/sources/byteListStream.ts +120 -120
- package/sources/byteReadStream.ts +23 -23
- package/sources/byteWriteStream.ts +15 -15
- package/sources/characterList.ts +194 -194
- package/sources/characterListStream.ts +150 -150
- package/sources/characterReadStream.ts +80 -80
- package/sources/characterReadStreamIterator.ts +127 -127
- package/sources/concatenateIterable.ts +118 -118
- package/sources/concatenateIterator.ts +164 -164
- package/sources/currentProcess.ts +157 -157
- package/sources/dateTime.ts +129 -129
- package/sources/depthFirstSearch.ts +229 -229
- package/sources/flatMapIterable.ts +103 -103
- package/sources/flatMapIterator.ts +151 -151
- package/sources/generator.ts +250 -250
- package/sources/index.ts +1 -1
- package/sources/iterator.ts +480 -480
- package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +123 -123
- package/sources/javascriptSetSet.ts +133 -133
- package/sources/listQueue.ts +61 -61
- package/sources/listStack.ts +61 -61
- package/sources/luxonDateTime.ts +108 -108
- package/sources/mapAsyncIterator.ts +140 -140
- package/sources/mutableMap.ts +291 -291
- package/sources/node.ts +36 -36
- package/sources/promiseAsyncResult.ts +173 -173
- package/sources/queue.ts +48 -48
- package/sources/recreationDotGovClient.ts +258 -258
- package/sources/searchControl.ts +41 -41
- package/sources/set.ts +243 -243
- package/sources/skipAsyncIterator.ts +144 -144
- package/sources/stack.ts +47 -47
- package/sources/syncResult.ts +299 -299
- package/sources/takeAsyncIterator.ts +140 -140
- package/sources/whereAsyncIterator.ts +142 -142
- package/sources/wonderlandTrailClient.ts +1502 -1502
- package/tests/assertTestTests.ts +74 -74
- package/tests/byteListStreamTests.ts +389 -389
- package/tests/byteListTests.ts +26 -26
- package/tests/characterListStreamTests.ts +390 -390
- package/tests/characterListTests.ts +249 -249
- package/tests/dateTimeTests.ts +29 -29
- package/tests/depthFirstSearchTests.ts +105 -105
- package/tests/generatorTests.ts +85 -85
- package/tests/mutableMapTests.ts +153 -153
- package/tests/promiseAsyncResultTests.ts +687 -687
- package/tests/queueTests.ts +28 -28
- package/tests/recreationDotGovClientTests.ts +190 -190
- package/tests/setTests.ts +139 -139
- package/tests/stackTests.ts +65 -65
- package/tests/syncResultTests.ts +1250 -1250
- package/tests/wonderlandTrailClientTests.ts +451 -451
- package/tsconfig.json +3 -0
- package/tsup.config.ts +12 -12
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
import { PreCondition } from "./preCondition";
|
|
2
|
-
import { AsyncResult } from "./asyncResult";
|
|
3
|
-
import { instanceOfType, isPromise, isUndefinedOrNull, Type } from "./types";
|
|
4
|
-
|
|
5
|
-
export class PromiseAsyncResult<T> implements AsyncResult<T>
|
|
6
|
-
{
|
|
7
|
-
private readonly promise: Promise<T>;
|
|
8
|
-
|
|
9
|
-
private constructor(promise: Promise<T>)
|
|
10
|
-
{
|
|
11
|
-
PreCondition.assertNotUndefinedAndNotNull(promise, "promise");
|
|
12
|
-
|
|
13
|
-
this.promise = promise;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public static create<T>(action: () => (T | Promise<T>)): PromiseAsyncResult<T>;
|
|
17
|
-
public static create<T>(promise: Promise<T>): PromiseAsyncResult<T>;
|
|
18
|
-
static create<T>(actionOrPromise: (() => (T | Promise<T>)) | Promise<T>): PromiseAsyncResult<T>
|
|
19
|
-
{
|
|
20
|
-
PreCondition.assertNotUndefinedAndNotNull(actionOrPromise, "action or promise");
|
|
21
|
-
|
|
22
|
-
return new PromiseAsyncResult(Promise.resolve(isPromise<T>(actionOrPromise) ? actionOrPromise : actionOrPromise()));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public static value<T>(value: T): PromiseAsyncResult<T>
|
|
26
|
-
{
|
|
27
|
-
return PromiseAsyncResult.create(Promise.resolve(value));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public static error<T>(error: unknown): PromiseAsyncResult<T>
|
|
31
|
-
{
|
|
32
|
-
return PromiseAsyncResult.create(Promise.reject(error));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public static yield(): PromiseAsyncResult<void>
|
|
36
|
-
{
|
|
37
|
-
return PromiseAsyncResult.create(Promise.resolve());
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseAsyncResult<TResult1 | TResult2>
|
|
41
|
-
{
|
|
42
|
-
return PromiseAsyncResult.create(this.promise.then(onfulfilled, onrejected));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public onValue(onValueFunction: (value: T) => (void | Promise<void>)): PromiseAsyncResult<T>
|
|
46
|
-
{
|
|
47
|
-
return this.then<T>(async (value: T) =>
|
|
48
|
-
{
|
|
49
|
-
let result: PromiseAsyncResult<T>;
|
|
50
|
-
try
|
|
51
|
-
{
|
|
52
|
-
await onValueFunction(value);
|
|
53
|
-
result = this;
|
|
54
|
-
}
|
|
55
|
-
catch (error)
|
|
56
|
-
{
|
|
57
|
-
result = PromiseAsyncResult.error(error);
|
|
58
|
-
}
|
|
59
|
-
return result;
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): PromiseAsyncResult<T | TResult>
|
|
64
|
-
public catch<TError,TResult = never>(errorType: Type<TError>, onrejected: (reason: TError) => (TResult | PromiseLike<TResult>)): PromiseAsyncResult<T | TResult>
|
|
65
|
-
catch<TResult = never>(errorTypeOrOnRejected?: Type<Error> | ((reason: unknown) => TResult | PromiseLike<TResult>) | null, onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): PromiseAsyncResult<T | TResult>
|
|
66
|
-
{
|
|
67
|
-
let errorType: Type<Error> | undefined;
|
|
68
|
-
if (!isUndefinedOrNull(onrejected))
|
|
69
|
-
{
|
|
70
|
-
errorType = errorTypeOrOnRejected as Type<unknown>;
|
|
71
|
-
|
|
72
|
-
PreCondition.assertNotUndefinedAndNotNull(errorType, "errorType");
|
|
73
|
-
}
|
|
74
|
-
else
|
|
75
|
-
{
|
|
76
|
-
onrejected = errorTypeOrOnRejected as ((reason: any) => TResult | PromiseLike<TResult>) | null;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return PromiseAsyncResult.create<T | TResult>(this.promise.catch((reason: unknown) =>
|
|
80
|
-
{
|
|
81
|
-
let value: TResult | PromiseLike<TResult> | undefined;
|
|
82
|
-
if (errorType && !instanceOfType(reason, errorType))
|
|
83
|
-
{
|
|
84
|
-
throw reason;
|
|
85
|
-
}
|
|
86
|
-
else if (!isUndefinedOrNull(onrejected))
|
|
87
|
-
{
|
|
88
|
-
value = onrejected(reason);
|
|
89
|
-
}
|
|
90
|
-
return value!;
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
public onError(onErrorFunction: (reason: unknown) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
|
|
95
|
-
public onError<TError>(errorType: Type<TError>, onErrorFunction: (reason: TError) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
|
|
96
|
-
onError(errorTypeOrOnErrorFunction: Type<unknown> | ((reason: unknown) => (void | PromiseLike<void>)), onErrorFunction?: (reason: unknown) => (void | PromiseLike<void>)): PromiseAsyncResult<T>
|
|
97
|
-
{
|
|
98
|
-
let errorType: Type<unknown> | undefined;
|
|
99
|
-
if (!isUndefinedOrNull(onErrorFunction))
|
|
100
|
-
{
|
|
101
|
-
errorType = errorTypeOrOnErrorFunction as Type<unknown>;
|
|
102
|
-
|
|
103
|
-
PreCondition.assertNotUndefinedAndNotNull(errorType, "errorType");
|
|
104
|
-
}
|
|
105
|
-
else
|
|
106
|
-
{
|
|
107
|
-
onErrorFunction = errorTypeOrOnErrorFunction as ((reason: unknown) => void | PromiseLike<void>);
|
|
108
|
-
}
|
|
109
|
-
PreCondition.assertNotUndefinedAndNotNull(onErrorFunction, "onErrorFunction");
|
|
110
|
-
|
|
111
|
-
let result: PromiseAsyncResult<T>;
|
|
112
|
-
if (errorType)
|
|
113
|
-
{
|
|
114
|
-
result = this.catch(errorType, async (reason: unknown) =>
|
|
115
|
-
{
|
|
116
|
-
await onErrorFunction(reason);
|
|
117
|
-
throw reason;
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
else
|
|
121
|
-
{
|
|
122
|
-
result = this.catch(async (reason: unknown) =>
|
|
123
|
-
{
|
|
124
|
-
await onErrorFunction(reason);
|
|
125
|
-
throw reason;
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public convertError(convertErrorFunction: (reason: unknown) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
|
|
133
|
-
public convertError<TError>(errorType: Type<TError>, convertErrorFunction: (reason: TError) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
|
|
134
|
-
convertError(errorTypeOrConvertErrorFunction: Type<unknown> | ((reason: unknown) => (unknown | PromiseLike<unknown>)), convertErrorFunction?: (reason: unknown) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>
|
|
135
|
-
{
|
|
136
|
-
let errorType: Type<unknown> | undefined;
|
|
137
|
-
if (!isUndefinedOrNull(convertErrorFunction))
|
|
138
|
-
{
|
|
139
|
-
errorType = errorTypeOrConvertErrorFunction as Type<unknown>;
|
|
140
|
-
|
|
141
|
-
PreCondition.assertNotUndefinedAndNotNull(errorType, "errorType");
|
|
142
|
-
}
|
|
143
|
-
else
|
|
144
|
-
{
|
|
145
|
-
convertErrorFunction = errorTypeOrConvertErrorFunction as ((reason: unknown) => void | PromiseLike<void>);
|
|
146
|
-
}
|
|
147
|
-
PreCondition.assertNotUndefinedAndNotNull(convertErrorFunction, "convertErrorFunction");
|
|
148
|
-
|
|
149
|
-
let result: PromiseAsyncResult<T>;
|
|
150
|
-
if (errorType)
|
|
151
|
-
{
|
|
152
|
-
result = this.catch(errorType, async (reason: unknown) =>
|
|
153
|
-
{
|
|
154
|
-
throw await convertErrorFunction(reason);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
else
|
|
158
|
-
{
|
|
159
|
-
result = this.catch(async (reason: unknown) =>
|
|
160
|
-
{
|
|
161
|
-
throw await convertErrorFunction(reason);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
public finally(onfinally?: (() => (void | Promise<void>)) | null): PromiseAsyncResult<T>
|
|
169
|
-
{
|
|
170
|
-
return PromiseAsyncResult.create(this.promise.finally(onfinally));
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
readonly [Symbol.toStringTag]: string = "AsyncResult";
|
|
1
|
+
import { PreCondition } from "./preCondition";
|
|
2
|
+
import { AsyncResult } from "./asyncResult";
|
|
3
|
+
import { instanceOfType, isPromise, isUndefinedOrNull, Type } from "./types";
|
|
4
|
+
|
|
5
|
+
export class PromiseAsyncResult<T> implements AsyncResult<T>
|
|
6
|
+
{
|
|
7
|
+
private readonly promise: Promise<T>;
|
|
8
|
+
|
|
9
|
+
private constructor(promise: Promise<T>)
|
|
10
|
+
{
|
|
11
|
+
PreCondition.assertNotUndefinedAndNotNull(promise, "promise");
|
|
12
|
+
|
|
13
|
+
this.promise = promise;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public static create<T>(action: () => (T | Promise<T>)): PromiseAsyncResult<T>;
|
|
17
|
+
public static create<T>(promise: Promise<T>): PromiseAsyncResult<T>;
|
|
18
|
+
static create<T>(actionOrPromise: (() => (T | Promise<T>)) | Promise<T>): PromiseAsyncResult<T>
|
|
19
|
+
{
|
|
20
|
+
PreCondition.assertNotUndefinedAndNotNull(actionOrPromise, "action or promise");
|
|
21
|
+
|
|
22
|
+
return new PromiseAsyncResult(Promise.resolve(isPromise<T>(actionOrPromise) ? actionOrPromise : actionOrPromise()));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public static value<T>(value: T): PromiseAsyncResult<T>
|
|
26
|
+
{
|
|
27
|
+
return PromiseAsyncResult.create(Promise.resolve(value));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public static error<T>(error: unknown): PromiseAsyncResult<T>
|
|
31
|
+
{
|
|
32
|
+
return PromiseAsyncResult.create(Promise.reject(error));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public static yield(): PromiseAsyncResult<void>
|
|
36
|
+
{
|
|
37
|
+
return PromiseAsyncResult.create(Promise.resolve());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseAsyncResult<TResult1 | TResult2>
|
|
41
|
+
{
|
|
42
|
+
return PromiseAsyncResult.create(this.promise.then(onfulfilled, onrejected));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public onValue(onValueFunction: (value: T) => (void | Promise<void>)): PromiseAsyncResult<T>
|
|
46
|
+
{
|
|
47
|
+
return this.then<T>(async (value: T) =>
|
|
48
|
+
{
|
|
49
|
+
let result: PromiseAsyncResult<T>;
|
|
50
|
+
try
|
|
51
|
+
{
|
|
52
|
+
await onValueFunction(value);
|
|
53
|
+
result = this;
|
|
54
|
+
}
|
|
55
|
+
catch (error)
|
|
56
|
+
{
|
|
57
|
+
result = PromiseAsyncResult.error(error);
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): PromiseAsyncResult<T | TResult>
|
|
64
|
+
public catch<TError,TResult = never>(errorType: Type<TError>, onrejected: (reason: TError) => (TResult | PromiseLike<TResult>)): PromiseAsyncResult<T | TResult>
|
|
65
|
+
catch<TResult = never>(errorTypeOrOnRejected?: Type<Error> | ((reason: unknown) => TResult | PromiseLike<TResult>) | null, onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): PromiseAsyncResult<T | TResult>
|
|
66
|
+
{
|
|
67
|
+
let errorType: Type<Error> | undefined;
|
|
68
|
+
if (!isUndefinedOrNull(onrejected))
|
|
69
|
+
{
|
|
70
|
+
errorType = errorTypeOrOnRejected as Type<unknown>;
|
|
71
|
+
|
|
72
|
+
PreCondition.assertNotUndefinedAndNotNull(errorType, "errorType");
|
|
73
|
+
}
|
|
74
|
+
else
|
|
75
|
+
{
|
|
76
|
+
onrejected = errorTypeOrOnRejected as ((reason: any) => TResult | PromiseLike<TResult>) | null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return PromiseAsyncResult.create<T | TResult>(this.promise.catch((reason: unknown) =>
|
|
80
|
+
{
|
|
81
|
+
let value: TResult | PromiseLike<TResult> | undefined;
|
|
82
|
+
if (errorType && !instanceOfType(reason, errorType))
|
|
83
|
+
{
|
|
84
|
+
throw reason;
|
|
85
|
+
}
|
|
86
|
+
else if (!isUndefinedOrNull(onrejected))
|
|
87
|
+
{
|
|
88
|
+
value = onrejected(reason);
|
|
89
|
+
}
|
|
90
|
+
return value!;
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public onError(onErrorFunction: (reason: unknown) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
|
|
95
|
+
public onError<TError>(errorType: Type<TError>, onErrorFunction: (reason: TError) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
|
|
96
|
+
onError(errorTypeOrOnErrorFunction: Type<unknown> | ((reason: unknown) => (void | PromiseLike<void>)), onErrorFunction?: (reason: unknown) => (void | PromiseLike<void>)): PromiseAsyncResult<T>
|
|
97
|
+
{
|
|
98
|
+
let errorType: Type<unknown> | undefined;
|
|
99
|
+
if (!isUndefinedOrNull(onErrorFunction))
|
|
100
|
+
{
|
|
101
|
+
errorType = errorTypeOrOnErrorFunction as Type<unknown>;
|
|
102
|
+
|
|
103
|
+
PreCondition.assertNotUndefinedAndNotNull(errorType, "errorType");
|
|
104
|
+
}
|
|
105
|
+
else
|
|
106
|
+
{
|
|
107
|
+
onErrorFunction = errorTypeOrOnErrorFunction as ((reason: unknown) => void | PromiseLike<void>);
|
|
108
|
+
}
|
|
109
|
+
PreCondition.assertNotUndefinedAndNotNull(onErrorFunction, "onErrorFunction");
|
|
110
|
+
|
|
111
|
+
let result: PromiseAsyncResult<T>;
|
|
112
|
+
if (errorType)
|
|
113
|
+
{
|
|
114
|
+
result = this.catch(errorType, async (reason: unknown) =>
|
|
115
|
+
{
|
|
116
|
+
await onErrorFunction(reason);
|
|
117
|
+
throw reason;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
else
|
|
121
|
+
{
|
|
122
|
+
result = this.catch(async (reason: unknown) =>
|
|
123
|
+
{
|
|
124
|
+
await onErrorFunction(reason);
|
|
125
|
+
throw reason;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public convertError(convertErrorFunction: (reason: unknown) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
|
|
133
|
+
public convertError<TError>(errorType: Type<TError>, convertErrorFunction: (reason: TError) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
|
|
134
|
+
convertError(errorTypeOrConvertErrorFunction: Type<unknown> | ((reason: unknown) => (unknown | PromiseLike<unknown>)), convertErrorFunction?: (reason: unknown) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>
|
|
135
|
+
{
|
|
136
|
+
let errorType: Type<unknown> | undefined;
|
|
137
|
+
if (!isUndefinedOrNull(convertErrorFunction))
|
|
138
|
+
{
|
|
139
|
+
errorType = errorTypeOrConvertErrorFunction as Type<unknown>;
|
|
140
|
+
|
|
141
|
+
PreCondition.assertNotUndefinedAndNotNull(errorType, "errorType");
|
|
142
|
+
}
|
|
143
|
+
else
|
|
144
|
+
{
|
|
145
|
+
convertErrorFunction = errorTypeOrConvertErrorFunction as ((reason: unknown) => void | PromiseLike<void>);
|
|
146
|
+
}
|
|
147
|
+
PreCondition.assertNotUndefinedAndNotNull(convertErrorFunction, "convertErrorFunction");
|
|
148
|
+
|
|
149
|
+
let result: PromiseAsyncResult<T>;
|
|
150
|
+
if (errorType)
|
|
151
|
+
{
|
|
152
|
+
result = this.catch(errorType, async (reason: unknown) =>
|
|
153
|
+
{
|
|
154
|
+
throw await convertErrorFunction(reason);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
else
|
|
158
|
+
{
|
|
159
|
+
result = this.catch(async (reason: unknown) =>
|
|
160
|
+
{
|
|
161
|
+
throw await convertErrorFunction(reason);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public finally(onfinally?: (() => (void | Promise<void>)) | null): PromiseAsyncResult<T>
|
|
169
|
+
{
|
|
170
|
+
return PromiseAsyncResult.create(this.promise.finally(onfinally));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
readonly [Symbol.toStringTag]: string = "AsyncResult";
|
|
174
174
|
}
|
package/sources/queue.ts
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { EqualFunctions } from "./equalFunctions";
|
|
2
|
-
import { JavascriptIterable } from "./javascript";
|
|
3
|
-
import { ListQueue } from "./listQueue";
|
|
4
|
-
import { ListStack } from "./listStack";
|
|
5
|
-
import { AsyncResult } from "./asyncResult";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A data structure that stores values in a first-in-first-out order.
|
|
9
|
-
*/
|
|
10
|
-
export abstract class Queue<T>
|
|
11
|
-
{
|
|
12
|
-
/**
|
|
13
|
-
* Create an instance of the default {@link Queue} implementation.
|
|
14
|
-
* @returns A new {@link Queue} object.
|
|
15
|
-
*/
|
|
16
|
-
public static create<T>(): ListQueue<T>
|
|
17
|
-
{
|
|
18
|
-
return ListQueue.create();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Get whether there are any values in this {@link Stack}.
|
|
23
|
-
*/
|
|
24
|
-
public abstract any(): AsyncResult<boolean>;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Add the provided value onto the end of this {@link Queue}.
|
|
28
|
-
* @param value The value to add to the end of this {@link Queue}.
|
|
29
|
-
*/
|
|
30
|
-
public abstract add(value: T): AsyncResult<void>;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Add the provided values to the end of this {@link Queue}.
|
|
34
|
-
* @param values The values to add to the end of this {@link Queue}.
|
|
35
|
-
*/
|
|
36
|
-
public abstract addAll(values: JavascriptIterable<T>): AsyncResult<void>;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Remove the next value off of this {@link Queue}.
|
|
40
|
-
*/
|
|
41
|
-
public abstract remove(): AsyncResult<T>;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Get whether this {@link Stack} contains the provided value.
|
|
45
|
-
* @param value The value to look for.
|
|
46
|
-
* @param equalFunctions The functions to use to compare values.
|
|
47
|
-
*/
|
|
48
|
-
public abstract contains(value: T, equalFunctions?: EqualFunctions): AsyncResult<boolean>;
|
|
1
|
+
import { EqualFunctions } from "./equalFunctions";
|
|
2
|
+
import { JavascriptIterable } from "./javascript";
|
|
3
|
+
import { ListQueue } from "./listQueue";
|
|
4
|
+
import { ListStack } from "./listStack";
|
|
5
|
+
import { AsyncResult } from "./asyncResult";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A data structure that stores values in a first-in-first-out order.
|
|
9
|
+
*/
|
|
10
|
+
export abstract class Queue<T>
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* Create an instance of the default {@link Queue} implementation.
|
|
14
|
+
* @returns A new {@link Queue} object.
|
|
15
|
+
*/
|
|
16
|
+
public static create<T>(): ListQueue<T>
|
|
17
|
+
{
|
|
18
|
+
return ListQueue.create();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get whether there are any values in this {@link Stack}.
|
|
23
|
+
*/
|
|
24
|
+
public abstract any(): AsyncResult<boolean>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Add the provided value onto the end of this {@link Queue}.
|
|
28
|
+
* @param value The value to add to the end of this {@link Queue}.
|
|
29
|
+
*/
|
|
30
|
+
public abstract add(value: T): AsyncResult<void>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Add the provided values to the end of this {@link Queue}.
|
|
34
|
+
* @param values The values to add to the end of this {@link Queue}.
|
|
35
|
+
*/
|
|
36
|
+
public abstract addAll(values: JavascriptIterable<T>): AsyncResult<void>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Remove the next value off of this {@link Queue}.
|
|
40
|
+
*/
|
|
41
|
+
public abstract remove(): AsyncResult<T>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get whether this {@link Stack} contains the provided value.
|
|
45
|
+
* @param value The value to look for.
|
|
46
|
+
* @param equalFunctions The functions to use to compare values.
|
|
47
|
+
*/
|
|
48
|
+
public abstract contains(value: T, equalFunctions?: EqualFunctions): AsyncResult<boolean>;
|
|
49
49
|
}
|