@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.
Files changed (60) hide show
  1. package/.github/workflows/publish.yml +54 -38
  2. package/package.json +9 -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/tsconfig.json +3 -0
  60. package/tsup.config.ts +12 -12
@@ -1,124 +1,124 @@
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
- }
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
124
  }
@@ -1,134 +1,134 @@
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
- }
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
134
  }
@@ -1,62 +1,62 @@
1
- import { EmptyError } from "./emptyError";
2
- import { EqualFunctions } from "./equalFunctions";
3
- import { JavascriptIterable } from "./javascript";
4
- import { List } from "./list";
5
- import { PreCondition } from "./preCondition";
6
- import { Queue } from "./queue";
7
- import { SyncResult } from "./syncResult";
8
-
9
- export class ListQueue<T> implements Queue<T>
10
- {
11
- private readonly list: List<T>;
12
-
13
- private constructor(list?: List<T>)
14
- {
15
- this.list = list ?? List.create();
16
- }
17
-
18
- public static create<T>(list?: List<T>): ListQueue<T>
19
- {
20
- return new ListQueue<T>(list);
21
- }
22
-
23
- public any(): SyncResult<boolean>
24
- {
25
- return this.list.any();
26
- }
27
-
28
- public add(value: T): SyncResult<void>
29
- {
30
- return SyncResult.create(() =>
31
- {
32
- this.list.add(value);
33
- });
34
- }
35
-
36
- public addAll(values: JavascriptIterable<T>): SyncResult<void>
37
- {
38
- PreCondition.assertNotUndefinedAndNotNull(values, "values");
39
-
40
- return SyncResult.create(() =>
41
- {
42
- this.list.addAll(values);
43
- });
44
- }
45
-
46
- public remove(): SyncResult<T>
47
- {
48
- return SyncResult.create(() =>
49
- {
50
- if (!this.any().await())
51
- {
52
- throw new EmptyError();
53
- }
54
- return this.list.removeLast().await();
55
- });
56
- }
57
-
58
- public contains(value: T, equalFunctions?: EqualFunctions): SyncResult<boolean>
59
- {
60
- return this.list.contains(value, equalFunctions);
61
- }
1
+ import { EmptyError } from "./emptyError";
2
+ import { EqualFunctions } from "./equalFunctions";
3
+ import { JavascriptIterable } from "./javascript";
4
+ import { List } from "./list";
5
+ import { PreCondition } from "./preCondition";
6
+ import { Queue } from "./queue";
7
+ import { SyncResult } from "./syncResult";
8
+
9
+ export class ListQueue<T> implements Queue<T>
10
+ {
11
+ private readonly list: List<T>;
12
+
13
+ private constructor(list?: List<T>)
14
+ {
15
+ this.list = list ?? List.create();
16
+ }
17
+
18
+ public static create<T>(list?: List<T>): ListQueue<T>
19
+ {
20
+ return new ListQueue<T>(list);
21
+ }
22
+
23
+ public any(): SyncResult<boolean>
24
+ {
25
+ return this.list.any();
26
+ }
27
+
28
+ public add(value: T): SyncResult<void>
29
+ {
30
+ return SyncResult.create(() =>
31
+ {
32
+ this.list.add(value);
33
+ });
34
+ }
35
+
36
+ public addAll(values: JavascriptIterable<T>): SyncResult<void>
37
+ {
38
+ PreCondition.assertNotUndefinedAndNotNull(values, "values");
39
+
40
+ return SyncResult.create(() =>
41
+ {
42
+ this.list.addAll(values);
43
+ });
44
+ }
45
+
46
+ public remove(): SyncResult<T>
47
+ {
48
+ return SyncResult.create(() =>
49
+ {
50
+ if (!this.any().await())
51
+ {
52
+ throw new EmptyError();
53
+ }
54
+ return this.list.removeLast().await();
55
+ });
56
+ }
57
+
58
+ public contains(value: T, equalFunctions?: EqualFunctions): SyncResult<boolean>
59
+ {
60
+ return this.list.contains(value, equalFunctions);
61
+ }
62
62
  }