@thi.ng/rstream 7.1.1 → 7.2.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/CHANGELOG.md +11 -1
- package/api.d.ts +1 -0
- package/defworker.d.ts +2 -1
- package/defworker.js +4 -1
- package/forkjoin.d.ts +2 -2
- package/package.json +11 -11
- package/promises.d.ts +8 -5
- package/promises.js +8 -5
- package/tunnel.d.ts +3 -3
- package/worker.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2021-11-
|
|
3
|
+
- **Last updated**: 2021-11-21T17:09:28Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,16 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [7.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream@7.2.0) (2021-11-21)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- update defWorker() arg types ([e07521e](https://github.com/thi-ng/umbrella/commit/e07521e))
|
|
17
|
+
- add `WorkerSource` type alias
|
|
18
|
+
- add support for zero-arg fns returning a worker instance
|
|
19
|
+
- helps v. much with Vite's `xxx?worker` imports
|
|
20
|
+
- see /examples/mandelbrot for usage
|
|
21
|
+
|
|
12
22
|
### [7.1.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream@7.1.1) (2021-11-19)
|
|
13
23
|
|
|
14
24
|
#### 🩹 Bug fixes
|
package/api.d.ts
CHANGED
|
@@ -183,4 +183,5 @@ export interface IStream<T> extends ISubscriber<T> {
|
|
|
183
183
|
}
|
|
184
184
|
export declare type StreamCancel = () => void;
|
|
185
185
|
export declare type StreamSource<T> = (sub: Stream<T>) => StreamCancel | void;
|
|
186
|
+
export declare type WorkerSource = Worker | Blob | Fn0<Worker> | string;
|
|
186
187
|
//# sourceMappingURL=api.d.ts.map
|
package/defworker.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WorkerSource } from "./api.js";
|
|
1
2
|
export declare const defInlineWorker: (src: string) => Worker;
|
|
2
|
-
export declare const defWorker: (worker:
|
|
3
|
+
export declare const defWorker: (worker: WorkerSource) => Worker;
|
|
3
4
|
//# sourceMappingURL=defworker.d.ts.map
|
package/defworker.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { isFunction } from "@thi.ng/checks/is-function";
|
|
1
2
|
export const defInlineWorker = (src) => defWorker(new Blob([src], { type: "text/javascript" }));
|
|
2
3
|
export const defWorker = (worker) => worker instanceof Worker
|
|
3
4
|
? worker
|
|
4
|
-
:
|
|
5
|
+
: isFunction(worker)
|
|
6
|
+
? worker()
|
|
7
|
+
: new Worker(worker instanceof Blob ? URL.createObjectURL(worker) : worker);
|
package/forkjoin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ArrayLikeIterable, Fn, Fn3 } from "@thi.ng/api";
|
|
2
|
-
import type { CommonOpts, ITransformable } from "./api.js";
|
|
2
|
+
import type { CommonOpts, ITransformable, WorkerSource } from "./api.js";
|
|
3
3
|
import type { Subscription } from "./subscription.js";
|
|
4
4
|
export interface ForkJoinOpts<IN, MSG, RES, OUT> extends Partial<CommonOpts> {
|
|
5
5
|
/**
|
|
@@ -38,7 +38,7 @@ export interface ForkJoinOpts<IN, MSG, RES, OUT> extends Partial<CommonOpts> {
|
|
|
38
38
|
* string. In the latter two cases, a worker is created
|
|
39
39
|
* automatically using `makeWorker()`.
|
|
40
40
|
*/
|
|
41
|
-
worker:
|
|
41
|
+
worker: WorkerSource;
|
|
42
42
|
/**
|
|
43
43
|
* Optional max number of workers to use. Defaults to
|
|
44
44
|
* `navigator.hardwareConcurrency` (or if unavailable, then 4 as
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/rstream",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "Reactive streams & subscription primitives for constructing dataflow graphs / pipelines",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.3.
|
|
38
|
-
"@thi.ng/arrays": "^2.1.
|
|
39
|
-
"@thi.ng/associative": "^6.1.
|
|
40
|
-
"@thi.ng/atom": "^5.1.
|
|
41
|
-
"@thi.ng/checks": "^3.1.
|
|
42
|
-
"@thi.ng/errors": "^2.1.
|
|
43
|
-
"@thi.ng/logger": "^1.1.
|
|
44
|
-
"@thi.ng/transducers": "^8.1.
|
|
37
|
+
"@thi.ng/api": "^8.3.2",
|
|
38
|
+
"@thi.ng/arrays": "^2.1.2",
|
|
39
|
+
"@thi.ng/associative": "^6.1.2",
|
|
40
|
+
"@thi.ng/atom": "^5.1.2",
|
|
41
|
+
"@thi.ng/checks": "^3.1.2",
|
|
42
|
+
"@thi.ng/errors": "^2.1.2",
|
|
43
|
+
"@thi.ng/logger": "^1.1.2",
|
|
44
|
+
"@thi.ng/transducers": "^8.1.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@microsoft/api-extractor": "^7.18.19",
|
|
48
|
-
"@thi.ng/testament": "^0.2.
|
|
48
|
+
"@thi.ng/testament": "^0.2.2",
|
|
49
49
|
"rimraf": "^3.0.2",
|
|
50
50
|
"tools": "^0.0.1",
|
|
51
51
|
"typedoc": "^0.22.9",
|
|
@@ -201,5 +201,5 @@
|
|
|
201
201
|
],
|
|
202
202
|
"year": 2017
|
|
203
203
|
},
|
|
204
|
-
"gitHead": "
|
|
204
|
+
"gitHead": "e8a7c2a40191b391cef182c2978e5a6c85987a87\n"
|
|
205
205
|
}
|
package/promises.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { ISubscription, WithErrorHandlerOpts } from "./api.js";
|
|
2
2
|
/**
|
|
3
|
-
* Wraps given iterable in `Promise.all()` to yield {@link Stream} of
|
|
4
|
-
*
|
|
3
|
+
* Wraps given iterable in `Promise.all()` to yield {@link Stream} of results in
|
|
4
|
+
* same order as arguments, then closes.
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
|
-
* If any of the promises rejects, all others will do so too. In this
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* If any of the promises rejects, all others will do so too. In this case the
|
|
8
|
+
* stream calls {@link ISubscriber.error} in all of its subscribers.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Type signature updated to use `Awaited<T>`, a new core type introduced in
|
|
12
|
+
* TypeScript 4.5.
|
|
10
13
|
*
|
|
11
14
|
* @example
|
|
12
15
|
* ```ts
|
package/promises.js
CHANGED
|
@@ -2,13 +2,16 @@ import { mapcat } from "@thi.ng/transducers/mapcat";
|
|
|
2
2
|
import { __optsWithID } from "./idgen.js";
|
|
3
3
|
import { fromPromise } from "./promise.js";
|
|
4
4
|
/**
|
|
5
|
-
* Wraps given iterable in `Promise.all()` to yield {@link Stream} of
|
|
6
|
-
*
|
|
5
|
+
* Wraps given iterable in `Promise.all()` to yield {@link Stream} of results in
|
|
6
|
+
* same order as arguments, then closes.
|
|
7
7
|
*
|
|
8
8
|
* @remarks
|
|
9
|
-
* If any of the promises rejects, all others will do so too. In this
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* If any of the promises rejects, all others will do so too. In this case the
|
|
10
|
+
* stream calls {@link ISubscriber.error} in all of its subscribers.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Type signature updated to use `Awaited<T>`, a new core type introduced in
|
|
14
|
+
* TypeScript 4.5.
|
|
12
15
|
*
|
|
13
16
|
* @example
|
|
14
17
|
* ```ts
|
package/tunnel.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Fn } from "@thi.ng/api";
|
|
1
|
+
import type { Fn, Fn0 } from "@thi.ng/api";
|
|
2
2
|
import { Subscription } from "./subscription.js";
|
|
3
3
|
export interface TunnelOpts<A> {
|
|
4
4
|
/**
|
|
5
5
|
* Tunnelled worker instance, source blob or script URL.
|
|
6
6
|
* If `interrupt` is enabled, the worker MUST be given as blob or URL.
|
|
7
7
|
*/
|
|
8
|
-
src: Worker | Blob | string
|
|
8
|
+
src: Worker | Blob | string | Fn0<Worker>;
|
|
9
9
|
/**
|
|
10
10
|
* Max. number of worker instances to use. Only useful if
|
|
11
11
|
* `interrupt` is disabled. If more than one worker is used,
|
|
@@ -62,7 +62,7 @@ export declare const tunnel: <A, B>(opts: TunnelOpts<A>) => Tunnel<A, B>;
|
|
|
62
62
|
*/
|
|
63
63
|
export declare class Tunnel<A, B> extends Subscription<A, B> {
|
|
64
64
|
workers: Worker[];
|
|
65
|
-
src: Worker | Blob | string
|
|
65
|
+
src: Worker | Blob | string | Fn0<Worker>;
|
|
66
66
|
transferables?: Fn<A, any[]>;
|
|
67
67
|
terminate: number;
|
|
68
68
|
interrupt: boolean;
|
package/worker.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WithErrorHandlerOpts } from "./api.js";
|
|
1
|
+
import type { WithErrorHandlerOpts, WorkerSource } from "./api.js";
|
|
2
2
|
export interface FromWorkerOpts extends WithErrorHandlerOpts {
|
|
3
3
|
/**
|
|
4
4
|
* If true, the worker will be terminated when the stream
|
|
@@ -31,5 +31,5 @@ export interface FromWorkerOpts extends WithErrorHandlerOpts {
|
|
|
31
31
|
* @param worker -
|
|
32
32
|
* @param opts -
|
|
33
33
|
*/
|
|
34
|
-
export declare const fromWorker: <T>(worker:
|
|
34
|
+
export declare const fromWorker: <T>(worker: WorkerSource, opts?: Partial<FromWorkerOpts> | undefined) => import("./stream.js").Stream<T>;
|
|
35
35
|
//# sourceMappingURL=worker.d.ts.map
|