@thi.ng/rstream 7.1.0 → 7.2.2

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 CHANGED
@@ -1,12 +1,29 @@
1
1
  # Change Log
2
2
 
3
- Last updated: 2021-11-17T23:24:59Z
3
+ - **Last updated**: 2021-12-13T10:26:00Z
4
+ - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
4
5
 
5
6
  All notable changes to this project will be documented in this file.
6
7
  See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
7
8
 
8
- **Note:** Unlisted _patch_ versions only involve non-code changes and/or
9
- version bumps of transitive dependencies.
9
+ **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
+ and/or version bumps of transitive dependencies.
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
+
22
+ ### [7.1.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream@7.1.1) (2021-11-19)
23
+
24
+ #### 🩹 Bug fixes
25
+
26
+ - add note about Awaited<T> type sig (1c82afa7e) ([efd8647](https://github.com/thi-ng/umbrella/commit/efd8647))
10
27
 
11
28
  ## [7.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream@7.1.0) (2021-11-17)
12
29
 
@@ -720,7 +737,7 @@ version bumps of transitive dependencies.
720
737
 
721
738
  - minor fix StreamSync.addAll() ([cc286e1](https://github.com/thi-ng/umbrella/commit/cc286e1))
722
739
 
723
- ## [1.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream@1.6.0) (2018-04-25)
740
+ ## [1.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream@1.6.0) (2018-04-24)
724
741
 
725
742
  #### 🚀 Features
726
743
 
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: Worker | string | Blob) => 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
- : new Worker(worker instanceof Blob ? URL.createObjectURL(worker) : worker);
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: string | Worker | Blob;
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.1.0",
3
+ "version": "7.2.2",
4
4
  "description": "Reactive streams & subscription primitives for constructing dataflow graphs / pipelines",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -30,26 +30,26 @@
30
30
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
31
31
  "doc:readme": "yarn doc:stats && tools:readme",
32
32
  "doc:stats": "tools:module-stats",
33
- "pub": "yarn build && yarn npm publish --access public",
33
+ "pub": "yarn npm publish --access public",
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.3.0",
38
- "@thi.ng/arrays": "^2.1.0",
39
- "@thi.ng/associative": "^6.1.0",
40
- "@thi.ng/atom": "^5.1.0",
41
- "@thi.ng/checks": "^3.1.0",
42
- "@thi.ng/errors": "^2.1.0",
43
- "@thi.ng/logger": "^1.1.0",
44
- "@thi.ng/transducers": "^8.1.0"
37
+ "@thi.ng/api": "^8.3.3",
38
+ "@thi.ng/arrays": "^2.1.3",
39
+ "@thi.ng/associative": "^6.1.4",
40
+ "@thi.ng/atom": "^5.1.3",
41
+ "@thi.ng/checks": "^3.1.3",
42
+ "@thi.ng/errors": "^2.1.3",
43
+ "@thi.ng/logger": "^1.1.3",
44
+ "@thi.ng/transducers": "^8.2.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@microsoft/api-extractor": "^7.18.19",
48
- "@thi.ng/testament": "^0.2.0",
47
+ "@microsoft/api-extractor": "^7.19.2",
48
+ "@thi.ng/testament": "^0.2.3",
49
49
  "rimraf": "^3.0.2",
50
50
  "tools": "^0.0.1",
51
- "typedoc": "^0.22.8",
52
- "typescript": "^4.4.4"
51
+ "typedoc": "^0.22.10",
52
+ "typescript": "^4.5.3"
53
53
  },
54
54
  "keywords": [
55
55
  "async",
@@ -201,5 +201,5 @@
201
201
  ],
202
202
  "year": 2017
203
203
  },
204
- "gitHead": "519eedf95c076202f3429eb8e46ccff275bfe446\n"
204
+ "gitHead": "1ba92c6b9509e74e509b4c0b875fc380a97bbbc1\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
- * results in same order as arguments, then closes.
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
- * case the stream calls {@link ISubscriber.error} in all of its
9
- * subscribers.
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
@@ -36,5 +39,5 @@ import type { ISubscription, WithErrorHandlerOpts } from "./api.js";
36
39
  * @param promises -
37
40
  * @param opts -
38
41
  */
39
- export declare const fromPromises: <T>(promises: Iterable<T | PromiseLike<T>>, opts?: Partial<WithErrorHandlerOpts> | undefined) => ISubscription<T[], T>;
42
+ export declare const fromPromises: <T>(promises: Iterable<T | PromiseLike<T>>, opts?: Partial<WithErrorHandlerOpts> | undefined) => ISubscription<Awaited<T>[], Awaited<T>>;
40
43
  //# sourceMappingURL=promises.d.ts.map
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
- * results in same order as arguments, then closes.
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
- * case the stream calls {@link ISubscriber.error} in all of its
11
- * subscribers.
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: Worker | Blob | string, opts?: Partial<FromWorkerOpts> | undefined) => import("./stream.js").Stream<T>;
34
+ export declare const fromWorker: <T>(worker: WorkerSource, opts?: Partial<FromWorkerOpts> | undefined) => import("./stream.js").Stream<T>;
35
35
  //# sourceMappingURL=worker.d.ts.map