@thi.ng/rstream 8.3.7 → 8.3.8

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,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-02-22T11:59:16Z
3
+ - **Last updated**: 2024-02-25T14:07:53Z
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.
package/atom.d.ts CHANGED
@@ -33,8 +33,11 @@ export interface FromAtomOpts<T> extends CommonOpts {
33
33
  *
34
34
  * @example
35
35
  * ```ts
36
- * db = new Atom({ a: 23, b: 88 });
37
- * cursor = new Cursor(db, "a")
36
+ * import { defAtom, defCursor } from "@thi.ng/atom";
37
+ * import { fromCursor } from "@thi.ng/rstream";
38
+ *
39
+ * db = defAtom({ a: 23, b: 88 });
40
+ * cursor = defCursor(db, "a")
38
41
  *
39
42
  * rs.fromAtom(cursor).subscribe(rs.trace("cursor val:"))
40
43
  * // cursor val: 23
package/bisect.d.ts CHANGED
@@ -13,6 +13,8 @@ import { PubSub } from "./pubsub.js";
13
13
  *
14
14
  * @example
15
15
  * ```ts
16
+ * import { bisect, fromIterable, trace } from "@thi.ng/rstream";
17
+ *
16
18
  * fromIterable([1, 2, 3, 4]).subscribe(
17
19
  * bisect(
18
20
  * (x) => !!(x & 1),
@@ -30,10 +32,13 @@ import { PubSub } from "./pubsub.js";
30
32
  *
31
33
  * @example
32
34
  * ```ts
35
+ * import { bisect, subscription, trace } from "@thi.ng/rstream";
36
+ * import { map } from "@thi.ng/transducers";
37
+ *
33
38
  * const odd = subscription();
34
39
  * const even = subscription();
35
40
  * odd.subscribe(trace("odd"));
36
- * odd.subscribe(trace("odd x10"), map((x) => x * 10));
41
+ * odd.subscribe(trace("odd x10"), { xform: map((x) => x * 10) });
37
42
  * even.subscribe(trace("even"));
38
43
  *
39
44
  * fromIterable([1, 2, 3, 4]).subscribe(
package/debounce.d.ts CHANGED
@@ -6,6 +6,8 @@ import { type MetaStreamOpts } from "./metastream.js";
6
6
  *
7
7
  * @example
8
8
  * ```ts
9
+ * import { debounce, fromIterable } from "@thi.ng/rstream";
10
+ *
9
11
  * const src = fromIterable([1, 2, 3], { delay: 10 })
10
12
  * src.subscribe(debounce(20)).subscribe({ next: console.log });
11
13
  * // 3
package/event.d.ts CHANGED
@@ -26,6 +26,8 @@ export declare const fromEvent: (src: EventTarget, name: string, listenerOpts?:
26
26
  *
27
27
  * @example
28
28
  * ```ts
29
+ * import { fromDOMEvent, fromEvent } from "@thi.ng/rstream";
30
+ *
29
31
  * fromDOMEvent(document.body, "mousemove"); // Stream<MouseEvent>
30
32
  * fromEvent(document.body, "mousemove"); // Stream<Event>
31
33
  * ```
package/forkjoin.d.ts CHANGED
@@ -132,6 +132,8 @@ export type Sliceable<T> = ArrayLike<T> & {
132
132
  *
133
133
  * @example
134
134
  * ```ts
135
+ * import { forkBuffer, forkJoin, joinBuffer } from "@thi.ng/rstream";
136
+ *
135
137
  * forkJoin<number[], number[], number[], number[]>({
136
138
  * src,
137
139
  * // job definition / split buffer into chunks (min size 256 values)
package/merge.d.ts CHANGED
@@ -18,6 +18,8 @@ export interface StreamMergeOpts<A, B> extends TransformableOpts<A, B> {
18
18
  *
19
19
  * @example
20
20
  * ```ts
21
+ * import { fromIterable, merge, trace } from "@thi.ng/rstream";
22
+ *
21
23
  * merge({
22
24
  * // input streams w/ different frequencies
23
25
  * src: [
@@ -45,6 +47,8 @@ export interface StreamMergeOpts<A, B> extends TransformableOpts<A, B> {
45
47
  *
46
48
  * @example
47
49
  * ```ts
50
+ * import { fromIterable, merge } from "@thi.ng/rstream";
51
+ *
48
52
  * merge({
49
53
  * src: [
50
54
  * fromIterable([1, 2, 3]).transform(tx.labeled("a")),
package/metastream.d.ts CHANGED
@@ -37,12 +37,15 @@ export interface MetaStreamOpts extends CommonOpts {
37
37
  *
38
38
  * @example
39
39
  * ```ts
40
+ * import { fromIterable, metaStream, trace } from "@thi.ng/rstream";
41
+ * import { repeat } from "@thi.ng/transducers";
42
+ *
40
43
  * // transform each received odd number into a stream
41
44
  * // producing 3 copies of that number in the metastream
42
45
  * // even numbers are ignored
43
46
  * a = metaStream(
44
47
  * (x) => (x & 1)
45
- * ? fromIterable(tx.repeat(x, 3), { delay: 100 })
48
+ * ? fromIterable(repeat(x, 3), { delay: 100 })
46
49
  * : null
47
50
  * );
48
51
  *
@@ -63,13 +66,16 @@ export interface MetaStreamOpts extends CommonOpts {
63
66
  *
64
67
  * @example
65
68
  * ```ts
69
+ * import { fromIterable, metaStream, trace, CloseMode } from "@thi.ng/rstream";
70
+ * import { repeat } from "@thi.ng/transducers";
71
+ *
66
72
  * // infinite inputs
67
73
  * a = fromIterable(
68
- * tx.repeat("a"),
74
+ * repeat("a"),
69
75
  * { delay: 1000, closeOut: CloseMode.NEVER }
70
76
  * );
71
77
  * b = fromIterable(
72
- * tx.repeat("b"),
78
+ * repeat("b"),
73
79
  * { delay: 1000, closeOut: CloseMode.NEVER }
74
80
  * );
75
81
  *
package/object.d.ts CHANGED
@@ -91,6 +91,8 @@ export interface StreamObjOpts<T, K extends Keys<T>> extends CommonOpts {
91
91
  *
92
92
  * @example
93
93
  * ```ts
94
+ * import { fromObject } from "@thi.ng/rstream";
95
+ *
94
96
  * type Foo = { a?: number; b: string; };
95
97
  *
96
98
  * const obj = fromObject(<Foo>{ a: 1, b: "foo" })
@@ -107,6 +109,8 @@ export interface StreamObjOpts<T, K extends Keys<T>> extends CommonOpts {
107
109
  *
108
110
  * @example
109
111
  * ```ts
112
+ * import { fromObject, trace } from "@thi.ng/rstream";
113
+ *
110
114
  * const obj = fromObject(<Foo>{}, ["a", "b"], { initial: false });
111
115
  * obj.streams.a.subscribe(trace("a"));
112
116
  * obj.streams.b.subscribe(trace("b"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/rstream",
3
- "version": "8.3.7",
3
+ "version": "8.3.8",
4
4
  "description": "Reactive streams & subscription primitives for constructing dataflow graphs / pipelines",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -39,14 +39,14 @@
39
39
  "test": "bun test"
40
40
  },
41
41
  "dependencies": {
42
- "@thi.ng/api": "^8.9.25",
43
- "@thi.ng/arrays": "^2.8.2",
44
- "@thi.ng/associative": "^6.3.42",
45
- "@thi.ng/atom": "^5.2.32",
42
+ "@thi.ng/api": "^8.9.26",
43
+ "@thi.ng/arrays": "^2.8.3",
44
+ "@thi.ng/associative": "^6.3.43",
45
+ "@thi.ng/atom": "^5.2.33",
46
46
  "@thi.ng/checks": "^3.5.0",
47
47
  "@thi.ng/errors": "^2.4.18",
48
- "@thi.ng/logger": "^3.0.2",
49
- "@thi.ng/transducers": "^8.9.6"
48
+ "@thi.ng/logger": "^3.0.3",
49
+ "@thi.ng/transducers": "^8.9.7"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@microsoft/api-extractor": "^7.40.1",
@@ -214,5 +214,5 @@
214
214
  ],
215
215
  "year": 2017
216
216
  },
217
- "gitHead": "16f2b92b5410bd35dcde6c2971c8e62783ebc472\n"
217
+ "gitHead": "6e20f80dd9df1c8055ffa3c1e4d6f7598add0c0b\n"
218
218
  }
package/post-worker.d.ts CHANGED
@@ -17,6 +17,8 @@ import type { ISubscriber } from "./api.js";
17
17
  *
18
18
  * @example
19
19
  * ```ts
20
+ * import { postWorker, stream } from "@thi.ng/rstream";
21
+ *
20
22
  * // worker source code
21
23
  * src = `self.onmessage = (e) => console.log("worker", e.data);`;
22
24
  *
package/promises.d.ts CHANGED
@@ -7,11 +7,12 @@ import type { ISubscription, WithErrorHandlerOpts } from "./api.js";
7
7
  * If any of the promises rejects, all others will do so too. In this case the
8
8
  * stream calls {@link ISubscriber.error} in all of its subscribers.
9
9
  *
10
- * Type signature updated to use `Awaited<T>`, a new core type introduced in
11
- * TypeScript 4.5.
10
+ * Also see {@link fromPromise}, {@link resolve}.
12
11
  *
13
12
  * @example
14
13
  * ```ts
14
+ * import { fromPromises } from "@thi.ng/rstream";
15
+ *
15
16
  * fromPromises([
16
17
  * Promise.resolve(1),
17
18
  * Promise.resolve(2),
@@ -28,6 +29,8 @@ import type { ISubscription, WithErrorHandlerOpts } from "./api.js";
28
29
  * (however this approach provides no ordering guarantees):
29
30
  *
30
31
  * ```ts
32
+ * import { fromIterable, resolve, trace } from "@thi.ng/rstream";
33
+ *
31
34
  * fromIterable([
32
35
  * Promise.resolve(1),
33
36
  * new Promise(() => setTimeout(() => { throw new Error("eeek"); }, 10)),
package/resolve.d.ts CHANGED
@@ -18,8 +18,11 @@ export interface ResolverOpts extends IID<string> {
18
18
  *
19
19
  * @example
20
20
  * ```ts
21
+ * import { fromIterable, resolve, trace } from "@thi.ng/rstream";
22
+ * import { delayed } from "@thi.ng/transducers";
23
+ *
21
24
  * fromIterable([1, 2, 3], 100)
22
- * .transform(tx.delayed(1000))
25
+ * .transform(delayed(1000))
23
26
  * .subscribe(resolve())
24
27
  * .subscribe(trace("result"))
25
28
  * // result 1
@@ -18,6 +18,8 @@ export interface SidechainPartitionOpts<T> extends CommonOpts {
18
18
  *
19
19
  * @example
20
20
  * ```ts
21
+ * import { fromEvent, fromRAF, merge, sidechainPartition, trace } from "@thi.ng/rstream";
22
+ *
21
23
  * // merge various event streams
22
24
  * events = merge([
23
25
  * fromEvent(document,"mousemove"),
@@ -50,6 +52,9 @@ export declare const sidechainPartition: <T, S>(src: ISubscribable<T>, side: ISu
50
52
  *
51
53
  * @example
52
54
  * ```ts
55
+ * import { defAtom } from "@thi.ng/atom";
56
+ * import { sideChainPartitionRAF } from "@thi.ng/rstream";
57
+ *
53
58
  * const atom = defAtom("alice");
54
59
  *
55
60
  * // any change to the atom will only be applied during next RAF update
@@ -18,6 +18,8 @@ export interface SidechainToggleOpts<T> extends CommonOpts {
18
18
  *
19
19
  * @example
20
20
  * ```ts
21
+ * import { fromInterval, sidechainToggle, trace } from "@thi.ng/rstream";
22
+ *
21
23
  * // use slower interval stream to toggle faster main stream on/off
22
24
  * sidechainToggle(fromInterval(500), fromInterval(1000)).subscribe(trace());
23
25
  * // 0
@@ -19,6 +19,8 @@ export interface SidechainTriggerOpts<T> extends CommonOpts {
19
19
  *
20
20
  * @example
21
21
  * ```ts
22
+ * import { reactive, stream, sidechainTrigger, trace } from "@thi.ng/rstream";
23
+ *
22
24
  * const src = reactive("payload");
23
25
  *
24
26
  * const side = stream();
package/stream.d.ts CHANGED
@@ -27,6 +27,8 @@ import { Subscription } from "./subscription.js";
27
27
  *
28
28
  * @example
29
29
  * ```ts
30
+ * import { stream, subscription, trace } from "@thi.ng/rstream";
31
+ *
30
32
  * a = stream((s) => {
31
33
  * s.next(1);
32
34
  * s.next(2);
package/subscription.d.ts CHANGED
@@ -33,10 +33,13 @@ import { CloseMode, State, type CommonOpts, type ISubscriber, type ISubscription
33
33
  *
34
34
  * @example
35
35
  * ```ts
36
+ * import { subscription, trace } from "@thi.ng/rstream";
37
+ * import { filter } from "@thi.ng/transducers";
38
+ *
36
39
  * // as reactive value mechanism (same as with stream() above)
37
40
  * s = subscription();
38
41
  * s.subscribe(trace("s1"));
39
- * s.subscribe(trace("s2"), { xform: tx.filter((x) => x > 25) });
42
+ * s.subscribe(trace("s2"), { xform: filter((x) => x > 25) });
40
43
  *
41
44
  * // external trigger
42
45
  * s.next(23);
package/sync-raf.d.ts CHANGED
@@ -14,6 +14,9 @@ import { Subscription } from "./subscription.js";
14
14
  *
15
15
  * @example
16
16
  * ```ts
17
+ * import { defAtom } from "@thi.ng/atom";
18
+ * import { fromAtom, syncRAF } from "@thi.ng/rstream";
19
+ *
17
20
  * const atom = defAtom("alice");
18
21
  *
19
22
  * // any changes to the atom will only be received by this subscription
package/sync.d.ts CHANGED
@@ -93,6 +93,8 @@ export interface StreamSyncOpts<A extends IObjectOf<ISubscribable<any>>, B = Syn
93
93
  *
94
94
  * @example
95
95
  * ```ts
96
+ * import { stream, sync, trace } from "@thi.ng/rstream";
97
+ *
96
98
  * const a = stream();
97
99
  * const b = stream();
98
100
  * s = sync({ src: { a, b } }).subscribe(trace("result: "));
package/toggle.d.ts CHANGED
@@ -7,6 +7,8 @@ import { Subscription } from "./subscription.js";
7
7
  *
8
8
  * @examples
9
9
  * ```ts
10
+ * import { toggle, trace } from "@thi.ng/rstream";
11
+ *
10
12
  * const mute = toggle(false);
11
13
  *
12
14
  * mute.subscribe(trace("mute"));
package/transduce.d.ts CHANGED
@@ -10,10 +10,13 @@ import type { Subscription } from "./subscription.js";
10
10
  *
11
11
  * @example
12
12
  * ```ts
13
+ * import { fromIterable, transduce } from "@thi.ng/rstream";
14
+ * import { add, map, range } from "@thi.ng/transducers";
15
+ *
13
16
  * transduce(
14
- * fromIterable(tx.range(10)),
15
- * tx.map((x) => x * 10),
16
- * tx.add()
17
+ * fromIterable(range(10)),
18
+ * map((x) => x * 10),
19
+ * add()
17
20
  * ).then((x) => console.log("result", x))
18
21
  *
19
22
  * // result 450
package/tween.d.ts CHANGED
@@ -22,6 +22,8 @@ import { type ISubscribable } from "./api.js";
22
22
  *
23
23
  * @example
24
24
  * ```ts
25
+ * import { stream, tween } from "@thi.ng/rstream";
26
+ *
25
27
  * val = stream();
26
28
  *
27
29
  * tween(
package/view.d.ts CHANGED
@@ -14,6 +14,9 @@ export type FromViewUnsafeOpts<T> = FromViewOpts<Path, any, T>;
14
14
 
15
15
  * @example
16
16
  * ```ts
17
+ * import { defAtom } from "@thi.ng/atom";
18
+ * import { fromViewUnsafe, trace } from "@thi.ng/rstream";
19
+ *
17
20
  * const db = defAtom<any>({ a: 1, b: { c: 2 }});
18
21
  *
19
22
  * // create stream of `c` value changes
@@ -67,6 +70,9 @@ export declare const fromViewUnsafe: <T>(atom: ReadonlyAtom<any>, opts: FromView
67
70
  *
68
71
  * @example
69
72
  * ```ts
73
+ * import { defAtom } from "@thi.ng/atom";
74
+ * import { fromView, trace } from "@thi.ng/rstream";
75
+ *
70
76
  * const db = defAtom<any>({ a: 1, b: { c: 2 }});
71
77
  *
72
78
  * fromView(