@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.
- package/.github/workflows/publish.yml +54 -36
- package/package.json +6 -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/tsup.config.ts +12 -12
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
import { PromiseAsyncResult } from "./promiseAsyncResult";
|
|
2
|
-
import { AsyncIterator } from "./asyncIterator";
|
|
3
|
-
import { JavascriptAsyncIterator } from "./javascript";
|
|
4
|
-
import { PreCondition } from "./preCondition";
|
|
5
|
-
import { Type } from "./types";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* An {@link AsyncIterator} that skips the first maximum number of values from an inner
|
|
9
|
-
* {@link AsyncIterator} before beginning to return values.
|
|
10
|
-
*/
|
|
11
|
-
export class SkipAsyncIterator<T> implements AsyncIterator<T>
|
|
12
|
-
{
|
|
13
|
-
private readonly innerIterator: AsyncIterator<T>;
|
|
14
|
-
private started: boolean;
|
|
15
|
-
private readonly maximumToSkip: number;
|
|
16
|
-
|
|
17
|
-
private constructor(innerIterator: AsyncIterator<T>, maximumToSkip: number)
|
|
18
|
-
{
|
|
19
|
-
PreCondition.assertNotUndefinedAndNotNull(innerIterator, "innerIterator");
|
|
20
|
-
PreCondition.assertNotUndefinedAndNotNull(maximumToSkip, "maximumToSkip");
|
|
21
|
-
PreCondition.assertInteger(maximumToSkip, "maximumToSkip");
|
|
22
|
-
PreCondition.assertGreaterThanOrEqualTo(maximumToSkip, 0, "maximumToSkip");
|
|
23
|
-
|
|
24
|
-
this.innerIterator = innerIterator;
|
|
25
|
-
this.started = false;
|
|
26
|
-
this.maximumToSkip = maximumToSkip;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public static create<T>(innerIterator: AsyncIterator<T>, maximumToSkip: number): SkipAsyncIterator<T>
|
|
30
|
-
{
|
|
31
|
-
return new SkipAsyncIterator(innerIterator, maximumToSkip);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public next(): PromiseAsyncResult<boolean>
|
|
35
|
-
{
|
|
36
|
-
return PromiseAsyncResult.create(async () =>
|
|
37
|
-
{
|
|
38
|
-
if (!this.hasStarted())
|
|
39
|
-
{
|
|
40
|
-
this.started = true;
|
|
41
|
-
await this.innerIterator.start();
|
|
42
|
-
|
|
43
|
-
for (let i = 0; i < this.maximumToSkip; i++)
|
|
44
|
-
{
|
|
45
|
-
if (!await this.innerIterator.next())
|
|
46
|
-
{
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else
|
|
52
|
-
{
|
|
53
|
-
await this.innerIterator.next();
|
|
54
|
-
}
|
|
55
|
-
return this.hasCurrent();
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public hasStarted(): boolean
|
|
60
|
-
{
|
|
61
|
-
return this.started;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public hasCurrent(): boolean
|
|
65
|
-
{
|
|
66
|
-
return this.hasStarted() && this.innerIterator.hasCurrent();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public getCurrent(): T
|
|
70
|
-
{
|
|
71
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
72
|
-
|
|
73
|
-
return this.innerIterator.getCurrent();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public start(): PromiseAsyncResult<this>
|
|
77
|
-
{
|
|
78
|
-
return AsyncIterator.start<T, this>(this);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
public takeCurrent(): PromiseAsyncResult<T>
|
|
82
|
-
{
|
|
83
|
-
return AsyncIterator.takeCurrent(this);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public any(): PromiseAsyncResult<boolean>
|
|
87
|
-
{
|
|
88
|
-
return AsyncIterator.any(this);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public getCount(): PromiseAsyncResult<number>
|
|
92
|
-
{
|
|
93
|
-
return AsyncIterator.getCount(this);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
public toArray(): PromiseAsyncResult<T[]>
|
|
97
|
-
{
|
|
98
|
-
return AsyncIterator.toArray(this);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
public where(condition: (value: T) => (boolean | PromiseLike<boolean>)): AsyncIterator<T>
|
|
102
|
-
{
|
|
103
|
-
return AsyncIterator.where(this, condition);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
public whereInstanceOf<U extends T>(typeCheck: (value: T) => value is U): AsyncIterator<U>
|
|
107
|
-
{
|
|
108
|
-
return AsyncIterator.whereInstanceOf(this, typeCheck);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
public whereInstanceOfType<U extends T>(type: Type<U>): AsyncIterator<U>
|
|
112
|
-
{
|
|
113
|
-
return AsyncIterator.whereInstanceOfType(this, type);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
public map<TOutput>(mapping: (value: T) => (TOutput | PromiseLike<TOutput>)): AsyncIterator<TOutput>
|
|
117
|
-
{
|
|
118
|
-
return AsyncIterator.map(this, mapping);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public first(condition?: (value: T) => (boolean | PromiseLike<boolean>)): PromiseAsyncResult<T>
|
|
122
|
-
{
|
|
123
|
-
return AsyncIterator.first(this, condition);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
public last(condition?: (value: T) => (boolean | PromiseLike<boolean>)): PromiseAsyncResult<T>
|
|
127
|
-
{
|
|
128
|
-
return AsyncIterator.last(this, condition);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
public [Symbol.asyncIterator](): JavascriptAsyncIterator<T>
|
|
132
|
-
{
|
|
133
|
-
return AsyncIterator[Symbol.asyncIterator](this);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public take(maximumToTake: number): AsyncIterator<T>
|
|
137
|
-
{
|
|
138
|
-
return AsyncIterator.take(this, maximumToTake);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
public skip(maximumToSkip: number): AsyncIterator<T>
|
|
142
|
-
{
|
|
143
|
-
return AsyncIterator.skip(this, maximumToSkip);
|
|
144
|
-
}
|
|
1
|
+
import { PromiseAsyncResult } from "./promiseAsyncResult";
|
|
2
|
+
import { AsyncIterator } from "./asyncIterator";
|
|
3
|
+
import { JavascriptAsyncIterator } from "./javascript";
|
|
4
|
+
import { PreCondition } from "./preCondition";
|
|
5
|
+
import { Type } from "./types";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* An {@link AsyncIterator} that skips the first maximum number of values from an inner
|
|
9
|
+
* {@link AsyncIterator} before beginning to return values.
|
|
10
|
+
*/
|
|
11
|
+
export class SkipAsyncIterator<T> implements AsyncIterator<T>
|
|
12
|
+
{
|
|
13
|
+
private readonly innerIterator: AsyncIterator<T>;
|
|
14
|
+
private started: boolean;
|
|
15
|
+
private readonly maximumToSkip: number;
|
|
16
|
+
|
|
17
|
+
private constructor(innerIterator: AsyncIterator<T>, maximumToSkip: number)
|
|
18
|
+
{
|
|
19
|
+
PreCondition.assertNotUndefinedAndNotNull(innerIterator, "innerIterator");
|
|
20
|
+
PreCondition.assertNotUndefinedAndNotNull(maximumToSkip, "maximumToSkip");
|
|
21
|
+
PreCondition.assertInteger(maximumToSkip, "maximumToSkip");
|
|
22
|
+
PreCondition.assertGreaterThanOrEqualTo(maximumToSkip, 0, "maximumToSkip");
|
|
23
|
+
|
|
24
|
+
this.innerIterator = innerIterator;
|
|
25
|
+
this.started = false;
|
|
26
|
+
this.maximumToSkip = maximumToSkip;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public static create<T>(innerIterator: AsyncIterator<T>, maximumToSkip: number): SkipAsyncIterator<T>
|
|
30
|
+
{
|
|
31
|
+
return new SkipAsyncIterator(innerIterator, maximumToSkip);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public next(): PromiseAsyncResult<boolean>
|
|
35
|
+
{
|
|
36
|
+
return PromiseAsyncResult.create(async () =>
|
|
37
|
+
{
|
|
38
|
+
if (!this.hasStarted())
|
|
39
|
+
{
|
|
40
|
+
this.started = true;
|
|
41
|
+
await this.innerIterator.start();
|
|
42
|
+
|
|
43
|
+
for (let i = 0; i < this.maximumToSkip; i++)
|
|
44
|
+
{
|
|
45
|
+
if (!await this.innerIterator.next())
|
|
46
|
+
{
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else
|
|
52
|
+
{
|
|
53
|
+
await this.innerIterator.next();
|
|
54
|
+
}
|
|
55
|
+
return this.hasCurrent();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public hasStarted(): boolean
|
|
60
|
+
{
|
|
61
|
+
return this.started;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public hasCurrent(): boolean
|
|
65
|
+
{
|
|
66
|
+
return this.hasStarted() && this.innerIterator.hasCurrent();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public getCurrent(): T
|
|
70
|
+
{
|
|
71
|
+
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
72
|
+
|
|
73
|
+
return this.innerIterator.getCurrent();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public start(): PromiseAsyncResult<this>
|
|
77
|
+
{
|
|
78
|
+
return AsyncIterator.start<T, this>(this);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public takeCurrent(): PromiseAsyncResult<T>
|
|
82
|
+
{
|
|
83
|
+
return AsyncIterator.takeCurrent(this);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public any(): PromiseAsyncResult<boolean>
|
|
87
|
+
{
|
|
88
|
+
return AsyncIterator.any(this);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public getCount(): PromiseAsyncResult<number>
|
|
92
|
+
{
|
|
93
|
+
return AsyncIterator.getCount(this);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public toArray(): PromiseAsyncResult<T[]>
|
|
97
|
+
{
|
|
98
|
+
return AsyncIterator.toArray(this);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public where(condition: (value: T) => (boolean | PromiseLike<boolean>)): AsyncIterator<T>
|
|
102
|
+
{
|
|
103
|
+
return AsyncIterator.where(this, condition);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public whereInstanceOf<U extends T>(typeCheck: (value: T) => value is U): AsyncIterator<U>
|
|
107
|
+
{
|
|
108
|
+
return AsyncIterator.whereInstanceOf(this, typeCheck);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public whereInstanceOfType<U extends T>(type: Type<U>): AsyncIterator<U>
|
|
112
|
+
{
|
|
113
|
+
return AsyncIterator.whereInstanceOfType(this, type);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public map<TOutput>(mapping: (value: T) => (TOutput | PromiseLike<TOutput>)): AsyncIterator<TOutput>
|
|
117
|
+
{
|
|
118
|
+
return AsyncIterator.map(this, mapping);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public first(condition?: (value: T) => (boolean | PromiseLike<boolean>)): PromiseAsyncResult<T>
|
|
122
|
+
{
|
|
123
|
+
return AsyncIterator.first(this, condition);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public last(condition?: (value: T) => (boolean | PromiseLike<boolean>)): PromiseAsyncResult<T>
|
|
127
|
+
{
|
|
128
|
+
return AsyncIterator.last(this, condition);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public [Symbol.asyncIterator](): JavascriptAsyncIterator<T>
|
|
132
|
+
{
|
|
133
|
+
return AsyncIterator[Symbol.asyncIterator](this);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public take(maximumToTake: number): AsyncIterator<T>
|
|
137
|
+
{
|
|
138
|
+
return AsyncIterator.take(this, maximumToTake);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public skip(maximumToSkip: number): AsyncIterator<T>
|
|
142
|
+
{
|
|
143
|
+
return AsyncIterator.skip(this, maximumToSkip);
|
|
144
|
+
}
|
|
145
145
|
}
|
package/sources/stack.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { EqualFunctions } from "./equalFunctions";
|
|
2
|
-
import { JavascriptIterable } from "./javascript";
|
|
3
|
-
import { ListStack } from "./listStack";
|
|
4
|
-
import { AsyncResult } from "./asyncResult";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A data structure that stores values in a first-in-last-out order.
|
|
8
|
-
*/
|
|
9
|
-
export abstract class Stack<T>
|
|
10
|
-
{
|
|
11
|
-
/**
|
|
12
|
-
* Create an instance of the default {@link Stack} implementation.
|
|
13
|
-
* @returns A new {@link Stack} object.
|
|
14
|
-
*/
|
|
15
|
-
public static create<T>(): ListStack<T>
|
|
16
|
-
{
|
|
17
|
-
return ListStack.create();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Get whether there are any values in this {@link Stack}.
|
|
22
|
-
*/
|
|
23
|
-
public abstract any(): AsyncResult<boolean>;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Push the provided value onto the top of this {@link Stack}.
|
|
27
|
-
* @param value The value to push on the top of this {@link Stack}.
|
|
28
|
-
*/
|
|
29
|
-
public abstract add(value: T): AsyncResult<void>;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Push the provided values onto the top of this {@link Stack}.
|
|
33
|
-
* @param values The values to push onto this {@link Stack}.
|
|
34
|
-
*/
|
|
35
|
-
public abstract addAll(values: JavascriptIterable<T>): AsyncResult<void>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Remove the top value off of this {@link Stack}.
|
|
39
|
-
*/
|
|
40
|
-
public abstract remove(): AsyncResult<T>;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Get whether this {@link Stack} contains the provided value.
|
|
44
|
-
* @param value The value to look for.
|
|
45
|
-
* @param equalFunctions The functions to use to compare values.
|
|
46
|
-
*/
|
|
47
|
-
public abstract contains(value: T, equalFunctions?: EqualFunctions): AsyncResult<boolean>;
|
|
1
|
+
import { EqualFunctions } from "./equalFunctions";
|
|
2
|
+
import { JavascriptIterable } from "./javascript";
|
|
3
|
+
import { ListStack } from "./listStack";
|
|
4
|
+
import { AsyncResult } from "./asyncResult";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A data structure that stores values in a first-in-last-out order.
|
|
8
|
+
*/
|
|
9
|
+
export abstract class Stack<T>
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* Create an instance of the default {@link Stack} implementation.
|
|
13
|
+
* @returns A new {@link Stack} object.
|
|
14
|
+
*/
|
|
15
|
+
public static create<T>(): ListStack<T>
|
|
16
|
+
{
|
|
17
|
+
return ListStack.create();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get whether there are any values in this {@link Stack}.
|
|
22
|
+
*/
|
|
23
|
+
public abstract any(): AsyncResult<boolean>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Push the provided value onto the top of this {@link Stack}.
|
|
27
|
+
* @param value The value to push on the top of this {@link Stack}.
|
|
28
|
+
*/
|
|
29
|
+
public abstract add(value: T): AsyncResult<void>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Push the provided values onto the top of this {@link Stack}.
|
|
33
|
+
* @param values The values to push onto this {@link Stack}.
|
|
34
|
+
*/
|
|
35
|
+
public abstract addAll(values: JavascriptIterable<T>): AsyncResult<void>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Remove the top value off of this {@link Stack}.
|
|
39
|
+
*/
|
|
40
|
+
public abstract remove(): AsyncResult<T>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get whether this {@link Stack} contains the provided value.
|
|
44
|
+
* @param value The value to look for.
|
|
45
|
+
* @param equalFunctions The functions to use to compare values.
|
|
46
|
+
*/
|
|
47
|
+
public abstract contains(value: T, equalFunctions?: EqualFunctions): AsyncResult<boolean>;
|
|
48
48
|
}
|