@tstdl/base 0.90.17 → 0.90.19
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/cancellation/token.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export declare class CancellationSignal implements PromiseLike<void>, Subscribab
|
|
|
88
88
|
export declare class CancellationToken extends CancellationSignal {
|
|
89
89
|
#private;
|
|
90
90
|
/** Signal for this token */
|
|
91
|
-
|
|
91
|
+
get signal(): CancellationSignal;
|
|
92
92
|
/**
|
|
93
93
|
* @param initialState which state to initialze this token to
|
|
94
94
|
* - `false`: unset
|
package/cancellation/token.js
CHANGED
|
@@ -86,8 +86,11 @@ export class CancellationSignal {
|
|
|
86
86
|
}
|
|
87
87
|
export class CancellationToken extends CancellationSignal {
|
|
88
88
|
#stateSubject;
|
|
89
|
+
#signal;
|
|
89
90
|
/** Signal for this token */
|
|
90
|
-
signal
|
|
91
|
+
get signal() {
|
|
92
|
+
return (this.#signal ??= new CancellationSignal(this.#stateSubject));
|
|
93
|
+
}
|
|
91
94
|
/**
|
|
92
95
|
* @param initialState which state to initialze this token to
|
|
93
96
|
* - `false`: unset
|
|
@@ -97,8 +100,7 @@ export class CancellationToken extends CancellationSignal {
|
|
|
97
100
|
constructor(initialState = false) {
|
|
98
101
|
const stateSubject = new BehaviorSubject(initialState);
|
|
99
102
|
super(stateSubject);
|
|
100
|
-
this.#stateSubject =
|
|
101
|
-
this.signal = new CancellationSignal(this.#stateSubject);
|
|
103
|
+
this.#stateSubject = stateSubject;
|
|
102
104
|
}
|
|
103
105
|
static from(source, config) {
|
|
104
106
|
const source$ = (source instanceof AbortSignal) ? fromEvent(source, 'abort', () => true)
|
|
@@ -126,7 +128,7 @@ export class CancellationToken extends CancellationSignal {
|
|
|
126
128
|
* Become a child of the provided parent. Events from the parent are propagated to this token. Events from this token are *not* propagated to the parent.
|
|
127
129
|
*/
|
|
128
130
|
inherit(parent, config) {
|
|
129
|
-
const state$ = (
|
|
131
|
+
const { state$ } = (parent instanceof CancellationToken) ? parent.signal : parent;
|
|
130
132
|
CancellationToken.connect(state$, this, config);
|
|
131
133
|
return this;
|
|
132
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.19",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"@typescript-eslint/parser": "6.8",
|
|
125
125
|
"concurrently": "8.2",
|
|
126
126
|
"esbuild": "0.19",
|
|
127
|
-
"eslint": "8.
|
|
127
|
+
"eslint": "8.52",
|
|
128
128
|
"eslint-import-resolver-typescript": "3.6",
|
|
129
129
|
"eslint-plugin-import": "2.28",
|
|
130
130
|
"tsc-alias": "1.8",
|
package/rpc/rpc.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
3
|
+
import { filter, Subject, takeUntil } from 'rxjs';
|
|
3
4
|
import { NotImplementedError } from '../errors/not-implemented.error.js';
|
|
4
5
|
import { deserialize, registerSerializer, serialize } from '../serializer/index.js';
|
|
5
6
|
import { hasOwnProperty } from '../utils/object/object.js';
|
|
@@ -7,7 +8,6 @@ import { reflectMethods } from '../utils/proxy.js';
|
|
|
7
8
|
import { getRandomString } from '../utils/random.js';
|
|
8
9
|
import { _throw } from '../utils/throw.js';
|
|
9
10
|
import { assert, isDefined } from '../utils/type-guards.js';
|
|
10
|
-
import { filter, Subject, takeUntil } from 'rxjs';
|
|
11
11
|
import { MessagePortRpcEndpoint } from './endpoints/message-port.rpc-endpoint.js';
|
|
12
12
|
import { createRpcMessage } from './model.js';
|
|
13
13
|
import { RpcEndpoint } from './rpc-endpoint.js';
|
package/tsconfig.json
CHANGED
|
@@ -2,9 +2,9 @@ import { firstValueFrom, Subject } from 'rxjs';
|
|
|
2
2
|
import { CancellationToken } from '../cancellation/token.js';
|
|
3
3
|
import { CircularBuffer } from '../data-structures/circular-buffer.js';
|
|
4
4
|
export class FeedableAsyncIterable {
|
|
5
|
-
readSubject;
|
|
6
|
-
closedToken;
|
|
7
|
-
buffer;
|
|
5
|
+
readSubject = new Subject();
|
|
6
|
+
closedToken = new CancellationToken();
|
|
7
|
+
buffer = new CircularBuffer();
|
|
8
8
|
get $read() {
|
|
9
9
|
return firstValueFrom(this.readSubject);
|
|
10
10
|
}
|
|
@@ -17,14 +17,9 @@ export class FeedableAsyncIterable {
|
|
|
17
17
|
get bufferSize() {
|
|
18
18
|
return this.buffer.size;
|
|
19
19
|
}
|
|
20
|
-
constructor() {
|
|
21
|
-
this.readSubject = new Subject();
|
|
22
|
-
this.closedToken = new CancellationToken();
|
|
23
|
-
this.buffer = new CircularBuffer();
|
|
24
|
-
}
|
|
25
20
|
feed(item) {
|
|
26
21
|
if (this.closed) {
|
|
27
|
-
throw new Error('
|
|
22
|
+
throw new Error('Feedable is already closed.');
|
|
28
23
|
}
|
|
29
24
|
this.buffer.add({ item, error: undefined });
|
|
30
25
|
}
|
|
@@ -33,7 +28,7 @@ export class FeedableAsyncIterable {
|
|
|
33
28
|
}
|
|
34
29
|
throw(error) {
|
|
35
30
|
if (this.closed) {
|
|
36
|
-
throw new Error('
|
|
31
|
+
throw new Error('Feedable is already closed.');
|
|
37
32
|
}
|
|
38
33
|
this.buffer.add({ item: undefined, error });
|
|
39
34
|
this.end();
|