@thi.ng/rstream 6.0.21 → 7.0.4
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 +49 -620
- package/README.md +70 -52
- package/api.d.ts +2 -4
- package/api.js +0 -3
- package/{subs/asidechain.d.ts → asidechain.d.ts} +2 -2
- package/{subs/asidechain.js → asidechain.js} +1 -1
- package/{from/atom.d.ts → atom.d.ts} +2 -3
- package/{from/atom.js → atom.js} +8 -4
- package/{subs/bisect.d.ts → bisect.d.ts} +2 -2
- package/{subs/bisect.js → bisect.js} +3 -3
- package/{utils/checks.d.ts → checks.d.ts} +2 -1
- package/{utils/checks.js → checks.js} +3 -1
- package/{subs/debounce.d.ts → debounce.d.ts} +2 -2
- package/{subs/debounce.js → debounce.js} +7 -4
- package/defworker.d.ts +3 -0
- package/defworker.js +4 -0
- package/{from/event.d.ts → event.d.ts} +2 -2
- package/{from/event.js → event.js} +4 -4
- package/forkjoin.d.ts +2 -2
- package/forkjoin.js +8 -3
- package/idgen.d.ts +10 -0
- package/idgen.js +9 -0
- package/index.d.ts +35 -33
- package/index.js +35 -33
- package/internal/remove.d.ts +4 -0
- package/internal/remove.js +7 -0
- package/{from/interval.d.ts → interval.d.ts} +2 -3
- package/{from/interval.js → interval.js} +8 -5
- package/{from/iterable.d.ts → iterable.d.ts} +3 -4
- package/{from/iterable.js → iterable.js} +7 -7
- package/logger.d.ts +4 -0
- package/logger.js +3 -0
- package/{stream-merge.d.ts → merge.d.ts} +3 -3
- package/{stream-merge.js → merge.js} +7 -10
- package/metastream.d.ts +3 -3
- package/metastream.js +5 -5
- package/{from/object.d.ts → object.d.ts} +2 -2
- package/{from/object.js → object.js} +13 -6
- package/package.json +140 -31
- package/{subs/post-worker.d.ts → post-worker.d.ts} +1 -1
- package/{subs/post-worker.js → post-worker.js} +5 -4
- package/{from/promise.d.ts → promise.d.ts} +2 -3
- package/{from/promise.js → promise.js} +5 -5
- package/{from/promises.d.ts → promises.d.ts} +1 -1
- package/{from/promises.js → promises.js} +4 -4
- package/pubsub.d.ts +3 -3
- package/pubsub.js +12 -8
- package/{from/raf.d.ts → raf.d.ts} +2 -3
- package/{from/raf.js → raf.js} +6 -6
- package/{subs/resolve.d.ts → resolve.d.ts} +1 -1
- package/{subs/resolve.js → resolve.js} +5 -4
- package/{subs/sidechain-partition.d.ts → sidechain-partition.d.ts} +4 -4
- package/{subs/sidechain-partition.js → sidechain-partition.js} +7 -7
- package/{subs/sidechain-toggle.d.ts → sidechain-toggle.d.ts} +3 -3
- package/{subs/sidechain-toggle.js → sidechain-toggle.js} +4 -4
- package/stream.d.ts +2 -2
- package/stream.js +6 -5
- package/subscription.d.ts +4 -3
- package/subscription.js +26 -12
- package/{stream-sync.d.ts → sync.d.ts} +4 -4
- package/{stream-sync.js → sync.js} +15 -12
- package/{subs/timeout.d.ts → timeout.d.ts} +2 -2
- package/{subs/timeout.js → timeout.js} +4 -4
- package/{subs/trace.d.ts → trace.d.ts} +1 -1
- package/{subs/trace.js → trace.js} +0 -0
- package/{subs/transduce.d.ts → transduce.d.ts} +1 -1
- package/{subs/transduce.js → transduce.js} +1 -1
- package/trigger.d.ts +2 -2
- package/trigger.js +3 -3
- package/{subs/tunnel.d.ts → tunnel.d.ts} +1 -1
- package/{subs/tunnel.js → tunnel.js} +7 -6
- package/tween.d.ts +5 -5
- package/tween.js +8 -6
- package/{from/view.d.ts → view.d.ts} +3 -3
- package/{from/view.js → view.js} +4 -4
- package/{from/worker.d.ts → worker.d.ts} +2 -3
- package/{from/worker.js → worker.js} +7 -7
- package/lib/index.js +0 -1148
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1
- package/lib/index.umd.js.map +0 -1
- package/utils/idgen.d.ts +0 -4
- package/utils/idgen.js +0 -3
- package/utils/worker.d.ts +0 -3
- package/utils/worker.js +0 -4
package/index.js
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
export * from "./api";
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
16
|
-
export * from "./
|
|
17
|
-
export * from "./
|
|
18
|
-
export * from "./
|
|
19
|
-
export * from "./
|
|
20
|
-
export * from "./
|
|
21
|
-
export * from "./
|
|
22
|
-
export * from "./
|
|
23
|
-
export * from "./
|
|
24
|
-
export * from "./
|
|
25
|
-
export * from "./
|
|
26
|
-
export * from "./
|
|
27
|
-
export * from "./
|
|
28
|
-
export * from "./
|
|
29
|
-
export * from "./
|
|
30
|
-
export * from "./
|
|
31
|
-
export * from "./
|
|
32
|
-
export * from "./
|
|
33
|
-
export * from "./
|
|
1
|
+
export * from "./api.js";
|
|
2
|
+
export * from "./asidechain.js";
|
|
3
|
+
export * from "./atom.js";
|
|
4
|
+
export * from "./bisect.js";
|
|
5
|
+
export * from "./checks.js";
|
|
6
|
+
export * from "./debounce.js";
|
|
7
|
+
export * from "./defworker.js";
|
|
8
|
+
export * from "./event.js";
|
|
9
|
+
export * from "./forkjoin.js";
|
|
10
|
+
export * from "./idgen.js";
|
|
11
|
+
export * from "./interval.js";
|
|
12
|
+
export * from "./iterable.js";
|
|
13
|
+
export * from "./logger.js";
|
|
14
|
+
export * from "./merge.js";
|
|
15
|
+
export * from "./metastream.js";
|
|
16
|
+
export * from "./object.js";
|
|
17
|
+
export * from "./post-worker.js";
|
|
18
|
+
export * from "./promise.js";
|
|
19
|
+
export * from "./promises.js";
|
|
20
|
+
export * from "./pubsub.js";
|
|
21
|
+
export * from "./raf.js";
|
|
22
|
+
export * from "./resolve.js";
|
|
23
|
+
export * from "./sidechain-partition.js";
|
|
24
|
+
export * from "./sidechain-toggle.js";
|
|
25
|
+
export * from "./stream.js";
|
|
26
|
+
export * from "./subscription.js";
|
|
27
|
+
export * from "./sync.js";
|
|
28
|
+
export * from "./timeout.js";
|
|
29
|
+
export * from "./trace.js";
|
|
30
|
+
export * from "./transduce.js";
|
|
31
|
+
export * from "./trigger.js";
|
|
32
|
+
export * from "./tunnel.js";
|
|
33
|
+
export * from "./tween.js";
|
|
34
|
+
export * from "./view.js";
|
|
35
|
+
export * from "./worker.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CommonOpts } from "
|
|
2
|
-
import { Stream } from "../stream";
|
|
1
|
+
import { CommonOpts } from "./api.js";
|
|
3
2
|
export interface FromIntervalOpts extends CommonOpts {
|
|
4
3
|
/**
|
|
5
4
|
* If given, only the stated number of values will be emitted (in
|
|
@@ -21,5 +20,5 @@ export interface FromIntervalOpts extends CommonOpts {
|
|
|
21
20
|
* @param delay -
|
|
22
21
|
* @param opts -
|
|
23
22
|
*/
|
|
24
|
-
export declare const fromInterval: (delay: number, opts?: Partial<FromIntervalOpts> | undefined) => Stream<number>;
|
|
23
|
+
export declare const fromInterval: (delay: number, opts?: Partial<FromIntervalOpts> | undefined) => import("./stream.js").Stream<number>;
|
|
25
24
|
//# sourceMappingURL=interval.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CloseMode } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { CloseMode } from "./api.js";
|
|
2
|
+
import { __optsWithID } from "./idgen.js";
|
|
3
|
+
import { stream } from "./stream.js";
|
|
4
4
|
/**
|
|
5
5
|
* Returns a {@link Stream} of monotonically increasing counter values,
|
|
6
6
|
* emitted at given `delay` interval and up to the optionally defined
|
|
@@ -13,8 +13,11 @@ import { optsWithID } from "../utils/idgen";
|
|
|
13
13
|
* @param opts -
|
|
14
14
|
*/
|
|
15
15
|
export const fromInterval = (delay, opts) => {
|
|
16
|
-
opts =
|
|
17
|
-
|
|
16
|
+
opts = __optsWithID("interval", {
|
|
17
|
+
num: Infinity,
|
|
18
|
+
...opts,
|
|
19
|
+
});
|
|
20
|
+
return stream((stream) => {
|
|
18
21
|
let i = 0;
|
|
19
22
|
let count = opts.num;
|
|
20
23
|
stream.next(i++);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CommonOpts } from "
|
|
2
|
-
import { Stream } from "../stream";
|
|
1
|
+
import { CommonOpts } from "./api.js";
|
|
3
2
|
export interface FromIterableOpts extends CommonOpts {
|
|
4
3
|
/**
|
|
5
4
|
* Time delay (in ms) between emitted values. The default value of
|
|
@@ -24,7 +23,7 @@ export interface FromIterableOpts extends CommonOpts {
|
|
|
24
23
|
* @param src -
|
|
25
24
|
* @param opts -
|
|
26
25
|
*/
|
|
27
|
-
export declare const fromIterable: <T>(src: Iterable<T>, opts?: Partial<FromIterableOpts>) => Stream<T>;
|
|
26
|
+
export declare const fromIterable: <T>(src: Iterable<T>, opts?: Partial<FromIterableOpts>) => import("./stream.js").Stream<T>;
|
|
28
27
|
/**
|
|
29
28
|
* Creates a new {@link Stream} of given iterable which synchronously calls
|
|
30
29
|
* `.next()` for each item of the iterable when the first (and in this
|
|
@@ -35,5 +34,5 @@ export declare const fromIterable: <T>(src: Iterable<T>, opts?: Partial<FromIter
|
|
|
35
34
|
* @param src -
|
|
36
35
|
* @param opts -
|
|
37
36
|
*/
|
|
38
|
-
export declare const fromIterableSync: <T>(src: Iterable<T>, opts?: Partial<CommonOpts> | undefined) => Stream<T>;
|
|
37
|
+
export declare const fromIterableSync: <T>(src: Iterable<T>, opts?: Partial<CommonOpts> | undefined) => import("./stream.js").Stream<T>;
|
|
39
38
|
//# sourceMappingURL=iterable.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CloseMode } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { CloseMode } from "./api.js";
|
|
2
|
+
import { __optsWithID } from "./idgen.js";
|
|
3
|
+
import { stream } from "./stream.js";
|
|
4
4
|
/**
|
|
5
5
|
* Returns a {@link Stream} of values from provided iterable, emitted at
|
|
6
6
|
* the given `delay` interval.
|
|
@@ -16,7 +16,7 @@ import { optsWithID } from "../utils/idgen";
|
|
|
16
16
|
* @param src -
|
|
17
17
|
* @param opts -
|
|
18
18
|
*/
|
|
19
|
-
export const fromIterable = (src, opts = {}) =>
|
|
19
|
+
export const fromIterable = (src, opts = {}) => stream((stream) => {
|
|
20
20
|
const iter = src[Symbol.iterator]();
|
|
21
21
|
const id = setInterval(() => {
|
|
22
22
|
let val;
|
|
@@ -29,7 +29,7 @@ export const fromIterable = (src, opts = {}) => new Stream((stream) => {
|
|
|
29
29
|
}
|
|
30
30
|
}, opts.delay || 0);
|
|
31
31
|
return () => clearInterval(id);
|
|
32
|
-
},
|
|
32
|
+
}, __optsWithID("iterable", opts));
|
|
33
33
|
/**
|
|
34
34
|
* Creates a new {@link Stream} of given iterable which synchronously calls
|
|
35
35
|
* `.next()` for each item of the iterable when the first (and in this
|
|
@@ -40,9 +40,9 @@ export const fromIterable = (src, opts = {}) => new Stream((stream) => {
|
|
|
40
40
|
* @param src -
|
|
41
41
|
* @param opts -
|
|
42
42
|
*/
|
|
43
|
-
export const fromIterableSync = (src, opts) =>
|
|
43
|
+
export const fromIterableSync = (src, opts) => stream((stream) => {
|
|
44
44
|
for (let s of src) {
|
|
45
45
|
stream.next(s);
|
|
46
46
|
}
|
|
47
47
|
stream.closeIn !== CloseMode.NEVER && stream.done();
|
|
48
|
-
},
|
|
48
|
+
}, __optsWithID("iterable-sync", opts));
|
package/logger.d.ts
ADDED
package/logger.js
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ISubscribable, ISubscription, TransformableOpts } from "./api";
|
|
2
|
-
import { Subscription } from "./subscription";
|
|
1
|
+
import { ISubscribable, ISubscription, TransformableOpts } from "./api.js";
|
|
2
|
+
import { Subscription } from "./subscription.js";
|
|
3
3
|
export interface StreamMergeOpts<A, B> extends TransformableOpts<A, B> {
|
|
4
4
|
/**
|
|
5
5
|
* Input sources.
|
|
@@ -75,4 +75,4 @@ export declare class StreamMerge<A, B> extends Subscription<A, B> {
|
|
|
75
75
|
unsubscribe(sub?: ISubscription<B, any>): boolean;
|
|
76
76
|
protected markDone(src: ISubscribable<A>): void;
|
|
77
77
|
}
|
|
78
|
-
//# sourceMappingURL=
|
|
78
|
+
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { State } from "./api";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { State, } from "./api.js";
|
|
2
|
+
import { isFirstOrLastInput } from "./checks.js";
|
|
3
|
+
import { __optsWithID } from "./idgen.js";
|
|
4
|
+
import { __removeAllIDs } from "./internal/remove.js";
|
|
5
|
+
import { Subscription } from "./subscription.js";
|
|
5
6
|
/**
|
|
6
7
|
* Returns a new {@link StreamMerge} subscription, consuming values from
|
|
7
8
|
* multiple inputs and passing received values on to any subscribers.
|
|
@@ -62,7 +63,7 @@ export const merge = (opts) => new StreamMerge(opts);
|
|
|
62
63
|
export class StreamMerge extends Subscription {
|
|
63
64
|
constructor(opts) {
|
|
64
65
|
opts = opts || {};
|
|
65
|
-
super(undefined,
|
|
66
|
+
super(undefined, __optsWithID("streammerge", opts));
|
|
66
67
|
this.sources = new Map();
|
|
67
68
|
opts.src && this.addAll(opts.src);
|
|
68
69
|
}
|
|
@@ -104,11 +105,7 @@ export class StreamMerge extends Subscription {
|
|
|
104
105
|
return ok;
|
|
105
106
|
}
|
|
106
107
|
removeAllIDs(ids) {
|
|
107
|
-
|
|
108
|
-
for (let id of ids) {
|
|
109
|
-
ok = this.removeID(id) && ok;
|
|
110
|
-
}
|
|
111
|
-
return ok;
|
|
108
|
+
return __removeAllIDs(this, ids);
|
|
112
109
|
}
|
|
113
110
|
unsubscribe(sub) {
|
|
114
111
|
if (!sub) {
|
package/metastream.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Fn, Nullable } from "@thi.ng/api";
|
|
2
|
-
import { CommonOpts, ISubscription } from "./api";
|
|
3
|
-
import { Subscription } from "./subscription";
|
|
1
|
+
import type { Fn, Nullable } from "@thi.ng/api";
|
|
2
|
+
import { CommonOpts, ISubscription } from "./api.js";
|
|
3
|
+
import { Subscription } from "./subscription.js";
|
|
4
4
|
export interface MetaStreamOpts extends CommonOpts {
|
|
5
5
|
/**
|
|
6
6
|
* If true, emits the last received value from the metastream's
|
package/metastream.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { assert } from "@thi.ng/
|
|
2
|
-
import { CloseMode, State } from "./api";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { assert } from "@thi.ng/errors/assert";
|
|
2
|
+
import { CloseMode, State } from "./api.js";
|
|
3
|
+
import { __optsWithID } from "./idgen.js";
|
|
4
|
+
import { Subscription } from "./subscription.js";
|
|
5
5
|
/**
|
|
6
6
|
* Returns a {@link Subscription} which transforms each incoming value into a
|
|
7
7
|
* new {@link ISubscription}, subscribes to it (via an hidden / internal
|
|
@@ -87,7 +87,7 @@ export const metaStream = (factory, opts) => new MetaStream(factory, opts);
|
|
|
87
87
|
*/
|
|
88
88
|
export class MetaStream extends Subscription {
|
|
89
89
|
constructor(factory, opts = {}) {
|
|
90
|
-
super(undefined,
|
|
90
|
+
super(undefined, __optsWithID("metastram", opts));
|
|
91
91
|
this.factory = factory;
|
|
92
92
|
this.emitLast = opts.emitLast === true;
|
|
93
93
|
this.doneRequested = false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Keys, Predicate2 } from "@thi.ng/api";
|
|
2
|
-
import type { CommonOpts } from "
|
|
3
|
-
import { Subscription } from "
|
|
2
|
+
import type { CommonOpts } from "./api.js";
|
|
3
|
+
import { Subscription } from "./subscription.js";
|
|
4
4
|
export declare type KeyStreams<T, K extends Keys<T>> = {
|
|
5
5
|
[id in K]-?: Subscription<T[id], T[id]>;
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { dedupe } from "@thi.ng/transducers";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { dedupe } from "@thi.ng/transducers/dedupe";
|
|
2
|
+
import { __nextID } from "./idgen.js";
|
|
3
|
+
import { subscription } from "./subscription.js";
|
|
4
4
|
/**
|
|
5
5
|
* Takes an arbitrary object `src` and object of options (see
|
|
6
6
|
* {@link StreamObjOpts}). Creates a new object and for each selected
|
|
@@ -69,13 +69,20 @@ import { nextID } from "../utils/idgen";
|
|
|
69
69
|
* @param opts
|
|
70
70
|
*/
|
|
71
71
|
export const fromObject = (src, opts = {}) => {
|
|
72
|
-
const id = opts.id || `obj${
|
|
72
|
+
const id = opts.id || `obj${__nextID()}`;
|
|
73
73
|
const keys = opts.keys || Object.keys(src);
|
|
74
74
|
const _opts = opts.dedupe !== false
|
|
75
|
-
?
|
|
75
|
+
? {
|
|
76
|
+
xform: dedupe(opts.equiv || ((a, b) => a === b)),
|
|
77
|
+
...opts,
|
|
78
|
+
}
|
|
79
|
+
: opts;
|
|
76
80
|
const streams = {};
|
|
77
81
|
for (let k of keys) {
|
|
78
|
-
streams[k] = subscription(undefined,
|
|
82
|
+
streams[k] = subscription(undefined, {
|
|
83
|
+
..._opts,
|
|
84
|
+
id: `${id}-${k}`,
|
|
85
|
+
});
|
|
79
86
|
}
|
|
80
87
|
const res = {
|
|
81
88
|
streams,
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/rstream",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.4",
|
|
4
4
|
"description": "Reactive streams & subscription primitives for constructing dataflow graphs / pipelines",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"module": "./index.js",
|
|
6
|
-
"main": "./lib/index.js",
|
|
7
|
-
"umd:main": "./lib/index.umd.js",
|
|
8
7
|
"typings": "./index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
@@ -24,36 +24,28 @@
|
|
|
24
24
|
"author": "Karsten Schmidt <k+npm@thi.ng>",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "yarn clean &&
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"build:test": "rimraf build && tsc -p test/tsconfig.json",
|
|
31
|
-
"build:check": "tsc --isolatedModules --noEmit",
|
|
32
|
-
"test": "mocha test",
|
|
33
|
-
"cover": "nyc mocha test && nyc report --reporter=lcov",
|
|
34
|
-
"clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib from subs utils",
|
|
35
|
-
"doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",
|
|
36
|
-
"doc": "typedoc --excludePrivate --out doc --theme ../../tools/doc/typedoc-theme src/index.ts",
|
|
27
|
+
"build": "yarn clean && tsc --declaration",
|
|
28
|
+
"clean": "rimraf *.js *.d.ts *.map doc",
|
|
29
|
+
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
37
30
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
|
|
38
|
-
"
|
|
31
|
+
"doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
|
|
32
|
+
"doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
|
|
33
|
+
"pub": "yarn build && yarn publish --access public",
|
|
34
|
+
"test": "testament test"
|
|
39
35
|
},
|
|
40
36
|
"dependencies": {
|
|
41
|
-
"@thi.ng/api": "^
|
|
42
|
-
"@thi.ng/arrays": "^
|
|
43
|
-
"@thi.ng/associative": "^
|
|
44
|
-
"@thi.ng/atom": "^
|
|
45
|
-
"@thi.ng/checks": "^
|
|
46
|
-
"@thi.ng/errors": "^
|
|
47
|
-
"@thi.ng/
|
|
37
|
+
"@thi.ng/api": "^8.0.4",
|
|
38
|
+
"@thi.ng/arrays": "^2.0.4",
|
|
39
|
+
"@thi.ng/associative": "^6.0.4",
|
|
40
|
+
"@thi.ng/atom": "^5.0.4",
|
|
41
|
+
"@thi.ng/checks": "^3.0.4",
|
|
42
|
+
"@thi.ng/errors": "^2.0.4",
|
|
43
|
+
"@thi.ng/logger": "^1.0.4",
|
|
44
|
+
"@thi.ng/transducers": "^8.0.4"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@thi.ng/testament": "^0.1.4"
|
|
48
48
|
},
|
|
49
|
-
"files": [
|
|
50
|
-
"*.js",
|
|
51
|
-
"*.d.ts",
|
|
52
|
-
"lib",
|
|
53
|
-
"from",
|
|
54
|
-
"subs",
|
|
55
|
-
"utils"
|
|
56
|
-
],
|
|
57
49
|
"keywords": [
|
|
58
50
|
"async",
|
|
59
51
|
"datastructure",
|
|
@@ -74,7 +66,124 @@
|
|
|
74
66
|
"publishConfig": {
|
|
75
67
|
"access": "public"
|
|
76
68
|
},
|
|
77
|
-
"
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=12.7"
|
|
71
|
+
},
|
|
72
|
+
"files": [
|
|
73
|
+
"*.js",
|
|
74
|
+
"*.d.ts",
|
|
75
|
+
"internal"
|
|
76
|
+
],
|
|
77
|
+
"exports": {
|
|
78
|
+
".": {
|
|
79
|
+
"import": "./index.js"
|
|
80
|
+
},
|
|
81
|
+
"./api": {
|
|
82
|
+
"import": "./api.js"
|
|
83
|
+
},
|
|
84
|
+
"./asidechain": {
|
|
85
|
+
"import": "./asidechain.js"
|
|
86
|
+
},
|
|
87
|
+
"./atom": {
|
|
88
|
+
"import": "./atom.js"
|
|
89
|
+
},
|
|
90
|
+
"./bisect": {
|
|
91
|
+
"import": "./bisect.js"
|
|
92
|
+
},
|
|
93
|
+
"./checks": {
|
|
94
|
+
"import": "./checks.js"
|
|
95
|
+
},
|
|
96
|
+
"./debounce": {
|
|
97
|
+
"import": "./debounce.js"
|
|
98
|
+
},
|
|
99
|
+
"./defworker": {
|
|
100
|
+
"import": "./defworker.js"
|
|
101
|
+
},
|
|
102
|
+
"./event": {
|
|
103
|
+
"import": "./event.js"
|
|
104
|
+
},
|
|
105
|
+
"./forkjoin": {
|
|
106
|
+
"import": "./forkjoin.js"
|
|
107
|
+
},
|
|
108
|
+
"./idgen": {
|
|
109
|
+
"import": "./idgen.js"
|
|
110
|
+
},
|
|
111
|
+
"./interval": {
|
|
112
|
+
"import": "./interval.js"
|
|
113
|
+
},
|
|
114
|
+
"./iterable": {
|
|
115
|
+
"import": "./iterable.js"
|
|
116
|
+
},
|
|
117
|
+
"./logger": {
|
|
118
|
+
"import": "./logger.js"
|
|
119
|
+
},
|
|
120
|
+
"./merge": {
|
|
121
|
+
"import": "./merge.js"
|
|
122
|
+
},
|
|
123
|
+
"./metastream": {
|
|
124
|
+
"import": "./metastream.js"
|
|
125
|
+
},
|
|
126
|
+
"./object": {
|
|
127
|
+
"import": "./object.js"
|
|
128
|
+
},
|
|
129
|
+
"./post-worker": {
|
|
130
|
+
"import": "./post-worker.js"
|
|
131
|
+
},
|
|
132
|
+
"./promise": {
|
|
133
|
+
"import": "./promise.js"
|
|
134
|
+
},
|
|
135
|
+
"./promises": {
|
|
136
|
+
"import": "./promises.js"
|
|
137
|
+
},
|
|
138
|
+
"./pubsub": {
|
|
139
|
+
"import": "./pubsub.js"
|
|
140
|
+
},
|
|
141
|
+
"./raf": {
|
|
142
|
+
"import": "./raf.js"
|
|
143
|
+
},
|
|
144
|
+
"./resolve": {
|
|
145
|
+
"import": "./resolve.js"
|
|
146
|
+
},
|
|
147
|
+
"./sidechain-partition": {
|
|
148
|
+
"import": "./sidechain-partition.js"
|
|
149
|
+
},
|
|
150
|
+
"./sidechain-toggle": {
|
|
151
|
+
"import": "./sidechain-toggle.js"
|
|
152
|
+
},
|
|
153
|
+
"./stream": {
|
|
154
|
+
"import": "./stream.js"
|
|
155
|
+
},
|
|
156
|
+
"./subscription": {
|
|
157
|
+
"import": "./subscription.js"
|
|
158
|
+
},
|
|
159
|
+
"./sync": {
|
|
160
|
+
"import": "./sync.js"
|
|
161
|
+
},
|
|
162
|
+
"./timeout": {
|
|
163
|
+
"import": "./timeout.js"
|
|
164
|
+
},
|
|
165
|
+
"./trace": {
|
|
166
|
+
"import": "./trace.js"
|
|
167
|
+
},
|
|
168
|
+
"./transduce": {
|
|
169
|
+
"import": "./transduce.js"
|
|
170
|
+
},
|
|
171
|
+
"./trigger": {
|
|
172
|
+
"import": "./trigger.js"
|
|
173
|
+
},
|
|
174
|
+
"./tunnel": {
|
|
175
|
+
"import": "./tunnel.js"
|
|
176
|
+
},
|
|
177
|
+
"./tween": {
|
|
178
|
+
"import": "./tween.js"
|
|
179
|
+
},
|
|
180
|
+
"./view": {
|
|
181
|
+
"import": "./view.js"
|
|
182
|
+
},
|
|
183
|
+
"./worker": {
|
|
184
|
+
"import": "./worker.js"
|
|
185
|
+
}
|
|
186
|
+
},
|
|
78
187
|
"thi.ng": {
|
|
79
188
|
"related": [
|
|
80
189
|
"atom",
|
|
@@ -84,5 +193,5 @@
|
|
|
84
193
|
],
|
|
85
194
|
"year": 2017
|
|
86
195
|
},
|
|
87
|
-
"gitHead": "
|
|
196
|
+
"gitHead": "9ff00a103f76cc4917ef3f244132e218f2300a05"
|
|
88
197
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { isTransferable
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { isTransferable } from "@thi.ng/checks/is-transferable";
|
|
2
|
+
import { isTypedArray } from "@thi.ng/checks/is-typedarray";
|
|
3
|
+
import { LOGGER } from "./logger.js";
|
|
4
|
+
import { defWorker } from "./defworker.js";
|
|
4
5
|
/**
|
|
5
6
|
* Creates a {@link ISubscriber | subscriber} which forwards received
|
|
6
7
|
* values to given worker.
|
|
@@ -36,7 +37,7 @@ import { makeWorker } from "../utils/worker";
|
|
|
36
37
|
* @param terminate - worker termination delay (ms)
|
|
37
38
|
*/
|
|
38
39
|
export const postWorker = (worker, transfer = false, terminate = 0) => {
|
|
39
|
-
const _worker =
|
|
40
|
+
const _worker = defWorker(worker);
|
|
40
41
|
return {
|
|
41
42
|
next(x) {
|
|
42
43
|
if (x instanceof Promise) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { WithErrorHandlerOpts } from "
|
|
2
|
-
import { Stream } from "../stream";
|
|
1
|
+
import { WithErrorHandlerOpts } from "./api.js";
|
|
3
2
|
/**
|
|
4
3
|
* Yields a single-value {@link Stream} of the resolved promise and then
|
|
5
4
|
* automatically marks itself done.
|
|
@@ -11,5 +10,5 @@ import { Stream } from "../stream";
|
|
|
11
10
|
* @param src -
|
|
12
11
|
* @param opts -
|
|
13
12
|
*/
|
|
14
|
-
export declare const fromPromise: <T>(src: Promise<T>, opts?: Partial<WithErrorHandlerOpts> | undefined) => Stream<T>;
|
|
13
|
+
export declare const fromPromise: <T>(src: Promise<T>, opts?: Partial<WithErrorHandlerOpts> | undefined) => import("./stream.js").Stream<T>;
|
|
15
14
|
//# sourceMappingURL=promise.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CloseMode, State } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { CloseMode, State } from "./api.js";
|
|
2
|
+
import { __optsWithID } from "./idgen.js";
|
|
3
|
+
import { stream } from "./stream.js";
|
|
4
4
|
/**
|
|
5
5
|
* Yields a single-value {@link Stream} of the resolved promise and then
|
|
6
6
|
* automatically marks itself done.
|
|
@@ -20,7 +20,7 @@ export const fromPromise = (src, opts) => {
|
|
|
20
20
|
err = e;
|
|
21
21
|
isError = true;
|
|
22
22
|
});
|
|
23
|
-
return
|
|
23
|
+
return stream((stream) => {
|
|
24
24
|
src.then((x) => {
|
|
25
25
|
if (!canceled && stream.getState() < State.DONE) {
|
|
26
26
|
if (isError) {
|
|
@@ -36,5 +36,5 @@ export const fromPromise = (src, opts) => {
|
|
|
36
36
|
return () => {
|
|
37
37
|
canceled = true;
|
|
38
38
|
};
|
|
39
|
-
},
|
|
39
|
+
}, __optsWithID("promise", opts));
|
|
40
40
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { mapcat } from "@thi.ng/transducers";
|
|
2
|
-
import {
|
|
3
|
-
import { fromPromise } from "./promise";
|
|
1
|
+
import { mapcat } from "@thi.ng/transducers/mapcat";
|
|
2
|
+
import { __optsWithID } from "./idgen.js";
|
|
3
|
+
import { fromPromise } from "./promise.js";
|
|
4
4
|
/**
|
|
5
5
|
* Wraps given iterable in `Promise.all()` to yield {@link Stream} of
|
|
6
6
|
* results in same order as arguments, then closes.
|
|
@@ -38,4 +38,4 @@ import { fromPromise } from "./promise";
|
|
|
38
38
|
* @param promises -
|
|
39
39
|
* @param opts -
|
|
40
40
|
*/
|
|
41
|
-
export const fromPromises = (promises, opts) => fromPromise(Promise.all(promises),
|
|
41
|
+
export const fromPromises = (promises, opts) => fromPromise(Promise.all(promises), __optsWithID("promises", opts)).transform(mapcat((x) => x));
|
package/pubsub.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Fn, Predicate2 } from "@thi.ng/api";
|
|
2
|
-
import { EquivMap } from "@thi.ng/associative";
|
|
2
|
+
import { EquivMap } from "@thi.ng/associative/equiv-map";
|
|
3
3
|
import type { Transducer } from "@thi.ng/transducers";
|
|
4
|
-
import { ISubscriber, ISubscription, TransformableOpts, WithErrorHandlerOpts } from "./api";
|
|
5
|
-
import { Subscription } from "./subscription";
|
|
4
|
+
import { ISubscriber, ISubscription, TransformableOpts, WithErrorHandlerOpts } from "./api.js";
|
|
5
|
+
import { Subscription } from "./subscription.js";
|
|
6
6
|
export interface PubSubOpts<A, B, T> {
|
|
7
7
|
/**
|
|
8
8
|
* Topic function. Incoming values will be routed to topic
|