@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.
Files changed (85) hide show
  1. package/CHANGELOG.md +49 -620
  2. package/README.md +70 -52
  3. package/api.d.ts +2 -4
  4. package/api.js +0 -3
  5. package/{subs/asidechain.d.ts → asidechain.d.ts} +2 -2
  6. package/{subs/asidechain.js → asidechain.js} +1 -1
  7. package/{from/atom.d.ts → atom.d.ts} +2 -3
  8. package/{from/atom.js → atom.js} +8 -4
  9. package/{subs/bisect.d.ts → bisect.d.ts} +2 -2
  10. package/{subs/bisect.js → bisect.js} +3 -3
  11. package/{utils/checks.d.ts → checks.d.ts} +2 -1
  12. package/{utils/checks.js → checks.js} +3 -1
  13. package/{subs/debounce.d.ts → debounce.d.ts} +2 -2
  14. package/{subs/debounce.js → debounce.js} +7 -4
  15. package/defworker.d.ts +3 -0
  16. package/defworker.js +4 -0
  17. package/{from/event.d.ts → event.d.ts} +2 -2
  18. package/{from/event.js → event.js} +4 -4
  19. package/forkjoin.d.ts +2 -2
  20. package/forkjoin.js +8 -3
  21. package/idgen.d.ts +10 -0
  22. package/idgen.js +9 -0
  23. package/index.d.ts +35 -33
  24. package/index.js +35 -33
  25. package/internal/remove.d.ts +4 -0
  26. package/internal/remove.js +7 -0
  27. package/{from/interval.d.ts → interval.d.ts} +2 -3
  28. package/{from/interval.js → interval.js} +8 -5
  29. package/{from/iterable.d.ts → iterable.d.ts} +3 -4
  30. package/{from/iterable.js → iterable.js} +7 -7
  31. package/logger.d.ts +4 -0
  32. package/logger.js +3 -0
  33. package/{stream-merge.d.ts → merge.d.ts} +3 -3
  34. package/{stream-merge.js → merge.js} +7 -10
  35. package/metastream.d.ts +3 -3
  36. package/metastream.js +5 -5
  37. package/{from/object.d.ts → object.d.ts} +2 -2
  38. package/{from/object.js → object.js} +13 -6
  39. package/package.json +140 -31
  40. package/{subs/post-worker.d.ts → post-worker.d.ts} +1 -1
  41. package/{subs/post-worker.js → post-worker.js} +5 -4
  42. package/{from/promise.d.ts → promise.d.ts} +2 -3
  43. package/{from/promise.js → promise.js} +5 -5
  44. package/{from/promises.d.ts → promises.d.ts} +1 -1
  45. package/{from/promises.js → promises.js} +4 -4
  46. package/pubsub.d.ts +3 -3
  47. package/pubsub.js +12 -8
  48. package/{from/raf.d.ts → raf.d.ts} +2 -3
  49. package/{from/raf.js → raf.js} +6 -6
  50. package/{subs/resolve.d.ts → resolve.d.ts} +1 -1
  51. package/{subs/resolve.js → resolve.js} +5 -4
  52. package/{subs/sidechain-partition.d.ts → sidechain-partition.d.ts} +4 -4
  53. package/{subs/sidechain-partition.js → sidechain-partition.js} +7 -7
  54. package/{subs/sidechain-toggle.d.ts → sidechain-toggle.d.ts} +3 -3
  55. package/{subs/sidechain-toggle.js → sidechain-toggle.js} +4 -4
  56. package/stream.d.ts +2 -2
  57. package/stream.js +6 -5
  58. package/subscription.d.ts +4 -3
  59. package/subscription.js +26 -12
  60. package/{stream-sync.d.ts → sync.d.ts} +4 -4
  61. package/{stream-sync.js → sync.js} +15 -12
  62. package/{subs/timeout.d.ts → timeout.d.ts} +2 -2
  63. package/{subs/timeout.js → timeout.js} +4 -4
  64. package/{subs/trace.d.ts → trace.d.ts} +1 -1
  65. package/{subs/trace.js → trace.js} +0 -0
  66. package/{subs/transduce.d.ts → transduce.d.ts} +1 -1
  67. package/{subs/transduce.js → transduce.js} +1 -1
  68. package/trigger.d.ts +2 -2
  69. package/trigger.js +3 -3
  70. package/{subs/tunnel.d.ts → tunnel.d.ts} +1 -1
  71. package/{subs/tunnel.js → tunnel.js} +7 -6
  72. package/tween.d.ts +5 -5
  73. package/tween.js +8 -6
  74. package/{from/view.d.ts → view.d.ts} +3 -3
  75. package/{from/view.js → view.js} +4 -4
  76. package/{from/worker.d.ts → worker.d.ts} +2 -3
  77. package/{from/worker.js → worker.js} +7 -7
  78. package/lib/index.js +0 -1148
  79. package/lib/index.js.map +0 -1
  80. package/lib/index.umd.js +0 -1
  81. package/lib/index.umd.js.map +0 -1
  82. package/utils/idgen.d.ts +0 -4
  83. package/utils/idgen.js +0 -3
  84. package/utils/worker.d.ts +0 -3
  85. package/utils/worker.js +0 -4
package/pubsub.js CHANGED
@@ -1,8 +1,9 @@
1
- import { EquivMap } from "@thi.ng/associative";
2
- import { unsupported } from "@thi.ng/errors";
3
- import { CloseMode, LOGGER, } from "./api";
4
- import { Subscription, subscription } from "./subscription";
5
- import { optsWithID } from "./utils/idgen";
1
+ import { EquivMap } from "@thi.ng/associative/equiv-map";
2
+ import { unsupported } from "@thi.ng/errors/unsupported";
3
+ import { CloseMode, } from "./api.js";
4
+ import { __optsWithID } from "./idgen.js";
5
+ import { LOGGER } from "./logger.js";
6
+ import { Subscription, subscription } from "./subscription.js";
6
7
  /**
7
8
  * Topic based stream splitter. Applies `topic` function to each received value
8
9
  * and only forwards it to the child subscriptions of the returned topic.
@@ -35,7 +36,7 @@ export const pubsub = (opts) => new PubSub(opts);
35
36
  */
36
37
  export class PubSub extends Subscription {
37
38
  constructor(opts) {
38
- super(undefined, optsWithID("pubsub", {
39
+ super(undefined, __optsWithID("pubsub", {
39
40
  xform: opts.xform,
40
41
  }));
41
42
  this.topicfn = opts.topic;
@@ -58,13 +59,16 @@ export class PubSub extends Subscription {
58
59
  subscribeTopic(topicID, sub, opts) {
59
60
  let t = this.topics.get(topicID);
60
61
  !t &&
61
- this.topics.set(topicID, (t = subscription(undefined, optsWithID("topic", {
62
+ this.topics.set(topicID, (t = subscription(undefined, __optsWithID("topic", {
62
63
  closeOut: CloseMode.NEVER,
63
64
  }))));
64
65
  return t.subscribe(sub, opts);
65
66
  }
66
67
  transformTopic(topicID, xform, opts = {}) {
67
- return this.subscribeTopic(topicID, { error: opts.error }, Object.assign(Object.assign({}, opts), { xform }));
68
+ return this.subscribeTopic(topicID, { error: opts.error }, {
69
+ ...opts,
70
+ xform,
71
+ });
68
72
  }
69
73
  unsubscribeTopic(topicID, sub) {
70
74
  const t = this.topics.get(topicID);
@@ -1,5 +1,4 @@
1
- import type { CommonOpts } from "../api";
2
- import { Stream } from "../stream";
1
+ import type { CommonOpts } from "./api.js";
3
2
  /**
4
3
  * Yields {@link Stream} of a monotonically increasing counter,
5
4
  * triggered by a `requestAnimationFrame()` loop (only available in
@@ -12,5 +11,5 @@ import { Stream } from "../stream";
12
11
  * All subscribers to this stream will be processed during that same
13
12
  * loop iteration.
14
13
  */
15
- export declare const fromRAF: (opts?: Partial<CommonOpts> | undefined) => Stream<number>;
14
+ export declare const fromRAF: (opts?: Partial<CommonOpts> | undefined) => import("./stream.js").Stream<number>;
16
15
  //# sourceMappingURL=raf.d.ts.map
@@ -1,7 +1,7 @@
1
- import { isNode } from "@thi.ng/checks";
2
- import { Stream } from "../stream";
3
- import { optsWithID } from "../utils/idgen";
4
- import { fromInterval } from "./interval";
1
+ import { isNode } from "@thi.ng/checks/is-node";
2
+ import { __optsWithID } from "./idgen.js";
3
+ import { fromInterval } from "./interval.js";
4
+ import { stream } from "./stream.js";
5
5
  /**
6
6
  * Yields {@link Stream} of a monotonically increasing counter,
7
7
  * triggered by a `requestAnimationFrame()` loop (only available in
@@ -16,7 +16,7 @@ import { fromInterval } from "./interval";
16
16
  */
17
17
  export const fromRAF = (opts) => isNode()
18
18
  ? fromInterval(16, opts)
19
- : new Stream((stream) => {
19
+ : stream((stream) => {
20
20
  let i = 0;
21
21
  let isActive = true;
22
22
  const loop = () => {
@@ -28,4 +28,4 @@ export const fromRAF = (opts) => isNode()
28
28
  isActive = false;
29
29
  cancelAnimationFrame(id);
30
30
  };
31
- }, optsWithID("raf", opts));
31
+ }, __optsWithID("raf", opts));
@@ -1,5 +1,5 @@
1
1
  import type { Fn, IID } from "@thi.ng/api";
2
- import { Subscription } from "../subscription";
2
+ import { Subscription } from "./subscription.js";
3
3
  export interface ResolverOpts extends IID<string> {
4
4
  /**
5
5
  * Error handler for failed promises.
@@ -1,6 +1,7 @@
1
- import { LOGGER, State } from "../api";
2
- import { Subscription } from "../subscription";
3
- import { optsWithID } from "../utils/idgen";
1
+ import { State } from "./api.js";
2
+ import { __optsWithID } from "./idgen.js";
3
+ import { LOGGER } from "./logger.js";
4
+ import { Subscription } from "./subscription.js";
4
5
  /**
5
6
  * Creates a {@link Subscription} which receives promises, buffers them
6
7
  * and then passes their resolved values downstream.
@@ -28,7 +29,7 @@ import { optsWithID } from "../utils/idgen";
28
29
  export const resolve = (opts) => new Resolver(opts);
29
30
  export class Resolver extends Subscription {
30
31
  constructor(opts = {}) {
31
- super(undefined, optsWithID("resolve"));
32
+ super(undefined, __optsWithID("resolve"));
32
33
  this.outstanding = 0;
33
34
  this.fail = opts.fail;
34
35
  }
@@ -1,7 +1,7 @@
1
1
  import type { Predicate } from "@thi.ng/api";
2
- import { CommonOpts, ISubscribable } from "../api";
3
- import type { Subscription } from "../subscription";
4
- import { ASidechain } from "./asidechain";
2
+ import { CommonOpts, ISubscribable } from "./api.js";
3
+ import { ASidechain } from "./asidechain.js";
4
+ import type { Subscription } from "./subscription.js";
5
5
  export interface SidechainPartitionOpts<T> extends CommonOpts {
6
6
  pred: Predicate<T>;
7
7
  }
@@ -43,7 +43,7 @@ export declare const sidechainPartition: <A, B>(side: ISubscribable<B>, opts?: P
43
43
  * @param src
44
44
  * @returns
45
45
  */
46
- export declare const sidechainPartitionRAF: <T>(src: ISubscribable<T>) => import("../api").ISubscription<T[], T>;
46
+ export declare const sidechainPartitionRAF: <T>(src: ISubscribable<T>) => import("./api.js").ISubscription<T[], T>;
47
47
  export declare class SidechainPartition<T, S> extends ASidechain<T, S, T[]> {
48
48
  buf: T[];
49
49
  constructor(side: ISubscribable<S>, opts?: Partial<SidechainPartitionOpts<S>>);
@@ -1,9 +1,9 @@
1
- import { peek } from "@thi.ng/arrays";
2
- import { map } from "@thi.ng/transducers";
3
- import { State } from "../api";
4
- import { fromRAF } from "../from/raf";
5
- import { optsWithID } from "../utils/idgen";
6
- import { ASidechain } from "./asidechain";
1
+ import { peek } from "@thi.ng/arrays/peek";
2
+ import { map } from "@thi.ng/transducers/map";
3
+ import { State } from "./api.js";
4
+ import { ASidechain } from "./asidechain.js";
5
+ import { __optsWithID } from "./idgen.js";
6
+ import { fromRAF } from "./raf.js";
7
7
  /**
8
8
  * Returns a {@link Subscription} which buffers values from `src` until
9
9
  * side chain fires, then emits buffer (unless empty) and repeats
@@ -47,7 +47,7 @@ export const sidechainPartitionRAF = (src) => src
47
47
  .transform(map(peek));
48
48
  export class SidechainPartition extends ASidechain {
49
49
  constructor(side, opts) {
50
- opts = optsWithID("sidepart", opts);
50
+ opts = __optsWithID("sidepart", opts);
51
51
  super(opts);
52
52
  this.buf = [];
53
53
  const pred = opts.pred || (() => true);
@@ -1,7 +1,7 @@
1
1
  import type { Predicate } from "@thi.ng/api";
2
- import { CommonOpts, ISubscribable } from "../api";
3
- import type { Subscription } from "../subscription";
4
- import { ASidechain } from "./asidechain";
2
+ import { CommonOpts, ISubscribable } from "./api.js";
3
+ import { ASidechain } from "./asidechain.js";
4
+ import type { Subscription } from "./subscription.js";
5
5
  export interface SidechainToggleOpts<T> extends CommonOpts {
6
6
  pred: Predicate<T>;
7
7
  initial: boolean;
@@ -1,6 +1,6 @@
1
- import { State } from "../api";
2
- import { optsWithID } from "../utils/idgen";
3
- import { ASidechain } from "./asidechain";
1
+ import { State } from "./api.js";
2
+ import { ASidechain } from "./asidechain.js";
3
+ import { __optsWithID } from "./idgen.js";
4
4
  /**
5
5
  * Returns {@link Subscription} which filters values from input based on
6
6
  * values received from side chain.
@@ -32,7 +32,7 @@ import { ASidechain } from "./asidechain";
32
32
  export const sidechainToggle = (side, opts) => new SidechainToggle(side, opts);
33
33
  export class SidechainToggle extends ASidechain {
34
34
  constructor(side, opts) {
35
- opts = optsWithID("sidetoggle", opts);
35
+ opts = __optsWithID("sidetoggle", opts);
36
36
  super(opts);
37
37
  this.isActive = !!opts.initial;
38
38
  const pred = opts.pred || (() => true);
package/stream.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { CommonOpts, IStream, ISubscriber, ISubscription, StreamCancel, StreamSource, TransformableOpts, WithErrorHandlerOpts } from "./api";
2
- import { Subscription } from "./subscription";
1
+ import { CommonOpts, IStream, ISubscriber, ISubscription, StreamCancel, StreamSource, TransformableOpts, WithErrorHandlerOpts } from "./api.js";
2
+ import { Subscription } from "./subscription.js";
3
3
  /**
4
4
  * Creates a new {@link Stream} instance, optionally with given
5
5
  * `StreamSource` function and / or options.
package/stream.js CHANGED
@@ -1,7 +1,8 @@
1
- import { isFunction } from "@thi.ng/checks";
2
- import { CloseMode, LOGGER, } from "./api";
3
- import { Subscription } from "./subscription";
4
- import { optsWithID } from "./utils/idgen";
1
+ import { isFunction } from "@thi.ng/checks/is-function";
2
+ import { CloseMode, } from "./api.js";
3
+ import { __optsWithID } from "./idgen.js";
4
+ import { LOGGER } from "./logger.js";
5
+ import { Subscription } from "./subscription.js";
5
6
  export function stream(src, opts) {
6
7
  return new Stream(src, opts);
7
8
  }
@@ -26,7 +27,7 @@ export class Stream extends Subscription {
26
27
  const [_src, _opts] = isFunction(src)
27
28
  ? [src, opts || {}]
28
29
  : [undefined, src || {}];
29
- super(_opts.error ? { error: _opts.error } : undefined, optsWithID("stream", _opts));
30
+ super(_opts.error ? { error: _opts.error } : undefined, __optsWithID("stream", _opts));
30
31
  this.src = _src;
31
32
  this._inited = false;
32
33
  }
package/subscription.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Fn } from "@thi.ng/api";
2
- import { Reduced, Reducer, Transducer } from "@thi.ng/transducers";
3
- import { CloseMode, CommonOpts, ISubscriber, ISubscription, State, SubscriptionOpts, TransformableOpts, WithErrorHandlerOpts, WithTransform } from "./api";
1
+ import type { Fn } from "@thi.ng/api";
2
+ import type { Reducer, Transducer } from "@thi.ng/transducers";
3
+ import { Reduced } from "@thi.ng/transducers/reduced";
4
+ import { CloseMode, CommonOpts, ISubscriber, ISubscription, State, SubscriptionOpts, TransformableOpts, WithErrorHandlerOpts, WithTransform } from "./api.js";
4
5
  /**
5
6
  * Creates a new {@link Subscription} instance, the fundamental datatype
6
7
  * and building block provided by this package.
package/subscription.js CHANGED
@@ -1,10 +1,16 @@
1
- import { assert, NULL_LOGGER, SEMAPHORE } from "@thi.ng/api";
2
- import { peek } from "@thi.ng/arrays";
3
- import { isPlainObject } from "@thi.ng/checks";
4
- import { illegalState } from "@thi.ng/errors";
5
- import { comp, isReduced, map, push, unreduced, } from "@thi.ng/transducers";
6
- import { CloseMode, LOGGER, State, } from "./api";
7
- import { optsWithID } from "./utils/idgen";
1
+ import { SEMAPHORE } from "@thi.ng/api/api";
2
+ import { peek } from "@thi.ng/arrays/peek";
3
+ import { isPlainObject } from "@thi.ng/checks/is-plain-object";
4
+ import { assert } from "@thi.ng/errors/assert";
5
+ import { illegalState } from "@thi.ng/errors/illegal-state";
6
+ import { NULL_LOGGER } from "@thi.ng/logger/null";
7
+ import { comp } from "@thi.ng/transducers/comp";
8
+ import { map } from "@thi.ng/transducers/map";
9
+ import { push } from "@thi.ng/transducers/push";
10
+ import { isReduced, unreduced } from "@thi.ng/transducers/reduced";
11
+ import { CloseMode, State, } from "./api.js";
12
+ import { __optsWithID } from "./idgen.js";
13
+ import { LOGGER } from "./logger.js";
8
14
  /**
9
15
  * Creates a new {@link Subscription} instance, the fundamental datatype
10
16
  * and building block provided by this package.
@@ -61,7 +67,12 @@ export class Subscription {
61
67
  this.last = SEMAPHORE;
62
68
  this.state = State.IDLE;
63
69
  this.subs = [];
64
- opts = optsWithID(`sub`, Object.assign({ closeIn: CloseMode.LAST, closeOut: CloseMode.LAST, cache: true }, opts));
70
+ opts = __optsWithID(`sub`, {
71
+ closeIn: CloseMode.LAST,
72
+ closeOut: CloseMode.LAST,
73
+ cache: true,
74
+ ...opts,
75
+ });
65
76
  this.parent = opts.parent;
66
77
  this.id = opts.id;
67
78
  this.closeIn = opts.closeIn;
@@ -89,7 +100,7 @@ export class Subscription {
89
100
  $sub = sub;
90
101
  }
91
102
  else {
92
- $sub = new Subscription(sub, Object.assign(Object.assign({}, opts), { parent: this }));
103
+ $sub = new Subscription(sub, { ...opts, parent: this });
93
104
  }
94
105
  this.subs.push($sub);
95
106
  this.setState(State.ACTIVE);
@@ -104,10 +115,13 @@ export class Subscription {
104
115
  opts = args.pop();
105
116
  sub = { error: opts.error };
106
117
  }
107
- return this.subscribe(sub, optsWithID("xform", args.length > 0
108
- ? Object.assign(Object.assign({}, opts), {
118
+ return this.subscribe(sub, __optsWithID("xform", args.length > 0
119
+ ? {
120
+ ...opts,
109
121
  // @ts-ignore
110
- xform: comp(...args) }) : opts));
122
+ xform: comp(...args),
123
+ }
124
+ : opts));
111
125
  }
112
126
  /**
113
127
  * Syntax sugar for {@link Subscription.transform} when using a
@@ -1,7 +1,7 @@
1
1
  import type { Always, Derefed, IObjectOf } from "@thi.ng/api";
2
- import { PartitionSync } from "@thi.ng/transducers";
3
- import { ISubscribable, ISubscription, TransformableOpts } from "./api";
4
- import { Subscription } from "./subscription";
2
+ import { PartitionSync } from "@thi.ng/transducers/partition-sync";
3
+ import type { ISubscribable, ISubscription, TransformableOpts } from "./api.js";
4
+ import { Subscription } from "./subscription.js";
5
5
  export declare type SyncTuple<T extends IObjectOf<ISubscribable<any>>> = {
6
6
  [id in keyof T]: Always<Derefed<T[id]>>;
7
7
  };
@@ -140,4 +140,4 @@ export declare class StreamSync<A extends IObjectOf<ISubscribable<any>>, B = Syn
140
140
  unsubscribe(sub?: ISubscription<B, any>): boolean;
141
141
  protected markDone(src: ISubscribable<any>): void;
142
142
  }
143
- //# sourceMappingURL=stream-sync.d.ts.map
143
+ //# sourceMappingURL=sync.d.ts.map
@@ -1,8 +1,12 @@
1
- import { comp, labeled, mapVals, partitionSync, } from "@thi.ng/transducers";
2
- import { LOGGER } from "./api";
3
- import { Subscription } from "./subscription";
4
- import { isFirstOrLastInput } from "./utils/checks";
5
- import { optsWithID } from "./utils/idgen";
1
+ import { comp } from "@thi.ng/transducers/comp";
2
+ import { labeled } from "@thi.ng/transducers/labeled";
3
+ import { mapVals } from "@thi.ng/transducers/map-vals";
4
+ import { partitionSync, } from "@thi.ng/transducers/partition-sync";
5
+ import { isFirstOrLastInput } from "./checks.js";
6
+ import { __optsWithID } from "./idgen.js";
7
+ import { __removeAllIDs } from "./internal/remove.js";
8
+ import { LOGGER } from "./logger.js";
9
+ import { Subscription } from "./subscription.js";
6
10
  /**
7
11
  * Similar to {@link StreamMerge}, but with extra synchronization of inputs.
8
12
  * Before emitting any new values, {@link StreamSync} collects values until at
@@ -67,9 +71,12 @@ export class StreamSync extends Subscription {
67
71
  backPressure: opts.backPressure || 0,
68
72
  });
69
73
  const mapv = mapVals((x) => x[1]);
70
- super(undefined, optsWithID("streamsync", Object.assign(Object.assign({}, opts), { xform: opts.xform
74
+ super(undefined, __optsWithID("streamsync", {
75
+ ...opts,
76
+ xform: opts.xform
71
77
  ? comp(psync, mapv, opts.xform)
72
- : comp(psync, mapv) })));
78
+ : comp(psync, mapv),
79
+ }));
73
80
  this.sources = new Map();
74
81
  this.realSourceIDs = new Map();
75
82
  this.invRealSourceIDs = new Map();
@@ -135,11 +142,7 @@ export class StreamSync extends Subscription {
135
142
  return ok;
136
143
  }
137
144
  removeAllIDs(ids) {
138
- let ok = true;
139
- for (let id of ids) {
140
- ok = this.removeID(id) && ok;
141
- }
142
- return ok;
145
+ return __removeAllIDs(this, ids);
143
146
  }
144
147
  getSourceForID(id) {
145
148
  return this.idSources.get(this.realSourceIDs.get(id));
@@ -1,5 +1,5 @@
1
- import { CommonOpts } from "../api";
2
- import { Subscription } from "../subscription";
1
+ import { CommonOpts } from "./api.js";
2
+ import { Subscription } from "./subscription.js";
3
3
  export interface TimeoutOpts extends CommonOpts {
4
4
  /**
5
5
  * Error object.
@@ -1,6 +1,6 @@
1
- import { State } from "../api";
2
- import { Subscription } from "../subscription";
3
- import { optsWithID } from "../utils/idgen";
1
+ import { State } from "./api.js";
2
+ import { __optsWithID } from "./idgen.js";
3
+ import { Subscription } from "./subscription.js";
4
4
  /**
5
5
  * Returns a {@link Subscription} that calls the
6
6
  * {@link ISubscriber.error} handlers of all child subscriptions with an
@@ -22,7 +22,7 @@ export const timeout = (timeoutMs, opts) => new Timeout(timeoutMs, opts);
22
22
  */
23
23
  class Timeout extends Subscription {
24
24
  constructor(timeoutMs, opts) {
25
- opts = optsWithID("timeout", opts);
25
+ opts = __optsWithID("timeout", opts);
26
26
  super(undefined, opts);
27
27
  this.timeoutMs = timeoutMs;
28
28
  this.errorObj = opts.error;
@@ -1,4 +1,4 @@
1
- import type { ISubscriber } from "../api";
1
+ import type { ISubscriber } from "./api.js";
2
2
  /**
3
3
  * Helper {@link ISubscriber} for inspection / debugging purposes.
4
4
  * Simply logs received values to console, optionally with given
File without changes
@@ -1,5 +1,5 @@
1
1
  import type { Reducer, Transducer } from "@thi.ng/transducers";
2
- import type { Subscription } from "../subscription";
2
+ import type { Subscription } from "./subscription.js";
3
3
  /**
4
4
  * Returns a promise which subscribes to given input and transforms
5
5
  * incoming values using given transducer `xform` and reducer `rfn`.
@@ -1,4 +1,4 @@
1
- import { isReduced } from "@thi.ng/transducers";
1
+ import { isReduced } from "@thi.ng/transducers/reduced";
2
2
  /**
3
3
  * Returns a promise which subscribes to given input and transforms
4
4
  * incoming values using given transducer `xform` and reducer `rfn`.
package/trigger.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { CommonOpts } from "./api";
2
- import type { Stream } from "./stream";
1
+ import type { CommonOpts } from "./api.js";
2
+ import type { Stream } from "./stream.js";
3
3
  /**
4
4
  * Utility stream. Returns a new stream which emits a single value `x` (if
5
5
  * given) and then closes. If no arg is provided, the stream emits a single
package/trigger.js CHANGED
@@ -1,5 +1,5 @@
1
- import { fromIterableSync } from "./from/iterable";
2
- import { optsWithID } from "./utils/idgen";
1
+ import { __optsWithID } from "./idgen.js";
2
+ import { fromIterableSync } from "./iterable.js";
3
3
  export function trigger(x = true, opts) {
4
- return fromIterableSync([x], optsWithID("trigger", opts));
4
+ return fromIterableSync([x], __optsWithID("trigger", opts));
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import type { Fn } from "@thi.ng/api";
2
- import { Subscription } from "../subscription";
2
+ import { Subscription } from "./subscription.js";
3
3
  export interface TunnelOpts<A> {
4
4
  /**
5
5
  * Tunnelled worker instance, source blob or script URL.
@@ -1,7 +1,8 @@
1
- import { LOGGER, State } from "../api";
2
- import { Subscription } from "../subscription";
3
- import { nextID } from "../utils/idgen";
4
- import { makeWorker } from "../utils/worker";
1
+ import { State } from "./api.js";
2
+ import { __nextID } from "./idgen.js";
3
+ import { LOGGER } from "./logger.js";
4
+ import { Subscription } from "./subscription.js";
5
+ import { defWorker } from "./defworker.js";
5
6
  /**
6
7
  * Returns a {@link Subscription} which processes received values via
7
8
  * the configured worker(s) and then passes values received back from
@@ -22,7 +23,7 @@ export const tunnel = (opts) => new Tunnel(opts);
22
23
  */
23
24
  export class Tunnel extends Subscription {
24
25
  constructor(opts) {
25
- super(undefined, { id: opts.id || `tunnel-${nextID()}` });
26
+ super(undefined, { id: opts.id || `tunnel-${__nextID()}` });
26
27
  this.src = opts.src;
27
28
  this.workers = new Array(opts.maxWorkers || 1);
28
29
  this.transferables = opts.transferables;
@@ -42,7 +43,7 @@ export class Tunnel extends Subscription {
42
43
  worker = null;
43
44
  }
44
45
  if (!worker) {
45
- this.workers[this.index++] = worker = makeWorker(this.src);
46
+ this.workers[this.index++] = worker = defWorker(this.src);
46
47
  this.index %= this.workers.length;
47
48
  worker.addEventListener("message", (e) => this.dispatch(e.data));
48
49
  worker.addEventListener("error", (e) => this.error(e));
package/tween.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Fn2 } from "@thi.ng/api";
2
- import { ISubscribable } from "./api";
2
+ import { ISubscribable } from "./api.js";
3
3
  /**
4
4
  * Takes an existing stream/subscription `src` and attaches new
5
5
  * subscription which interpolates between incoming values from `src`
@@ -54,9 +54,9 @@ import { ISubscribable } from "./api";
54
54
  * @param stop -
55
55
  * @param clock -
56
56
  */
57
- export declare const tween: <T>(src: ISubscribable<T>, initial: T, mix: Fn2<T, T, T>, stop?: Fn2<T, T, boolean> | undefined, clock?: number | ISubscribable<any> | undefined) => import("./api").ISubscription<import("./stream-sync").SyncTuple<{
57
+ export declare const tween: <T>(src: ISubscribable<T>, initial: T, mix: Fn2<T, T, T>, stop?: Fn2<T, T, boolean> | undefined, clock?: number | ISubscribable<any> | undefined) => import("./api.js").ISubscription<import("./sync.js").SyncTuple<{
58
58
  src: ISubscribable<T>;
59
- _: ISubscribable<any> | import("./stream").Stream<number>;
59
+ _: ISubscribable<any> | import("./stream.js").Stream<number>;
60
60
  }>, T>;
61
61
  /**
62
62
  * Convenience version of {@link tween} for its most common use case, tweening
@@ -68,8 +68,8 @@ export declare const tween: <T>(src: ISubscribable<T>, initial: T, mix: Fn2<T, T
68
68
  * @param eps -
69
69
  * @param clock -
70
70
  */
71
- export declare const tweenNumber: (src: ISubscribable<number>, init?: number, speed?: number, eps?: number, clock?: number | ISubscribable<any> | undefined) => import("./api").ISubscription<import("./stream-sync").SyncTuple<{
71
+ export declare const tweenNumber: (src: ISubscribable<number>, init?: number, speed?: number, eps?: number, clock?: number | ISubscribable<any> | undefined) => import("./api.js").ISubscription<import("./sync.js").SyncTuple<{
72
72
  src: ISubscribable<number>;
73
- _: ISubscribable<any> | import("./stream").Stream<number>;
73
+ _: ISubscribable<any> | import("./stream.js").Stream<number>;
74
74
  }>, number>;
75
75
  //# sourceMappingURL=tween.d.ts.map
package/tween.js CHANGED
@@ -1,9 +1,11 @@
1
- import { isNumber } from "@thi.ng/checks";
2
- import { dedupe, reducer, scan } from "@thi.ng/transducers";
3
- import { CloseMode } from "./api";
4
- import { fromInterval } from "./from/interval";
5
- import { fromRAF } from "./from/raf";
6
- import { sync } from "./stream-sync";
1
+ import { isNumber } from "@thi.ng/checks/is-number";
2
+ import { dedupe } from "@thi.ng/transducers/dedupe";
3
+ import { reducer } from "@thi.ng/transducers/reduce";
4
+ import { scan } from "@thi.ng/transducers/scan";
5
+ import { CloseMode } from "./api.js";
6
+ import { fromInterval } from "./interval.js";
7
+ import { fromRAF } from "./raf.js";
8
+ import { sync } from "./sync.js";
7
9
  /**
8
10
  * Takes an existing stream/subscription `src` and attaches new
9
11
  * subscription which interpolates between incoming values from `src`
@@ -1,7 +1,7 @@
1
1
  import type { DeepPath, Fn, OptPathVal, Path, Path0, Path1, Path2, Path3, Path4, Path5, Path6, Path7, Path8, Predicate2 } from "@thi.ng/api";
2
- import { ReadonlyAtom } from "@thi.ng/atom";
3
- import type { CommonOpts } from "../api";
4
- import { Stream } from "../stream";
2
+ import type { ReadonlyAtom } from "@thi.ng/atom";
3
+ import type { CommonOpts } from "./api.js";
4
+ import { Stream } from "./stream.js";
5
5
  export interface FromViewOpts<P, A, B> extends Partial<CommonOpts> {
6
6
  path: P;
7
7
  tx?: Fn<A, B>;
@@ -1,6 +1,6 @@
1
- import { View } from "@thi.ng/atom";
2
- import { Stream } from "../stream";
3
- import { optsWithID } from "../utils/idgen";
1
+ import { View } from "@thi.ng/atom/view";
2
+ import { __optsWithID } from "./idgen.js";
3
+ import { Stream } from "./stream.js";
4
4
  /**
5
5
  * Unchecked version of {@link fromView}. Paths can be given as string
6
6
  * or tuple.
@@ -32,7 +32,7 @@ import { optsWithID } from "../utils/idgen";
32
32
  */
33
33
  export const fromViewUnsafe = (atom, opts) => fromView(atom, opts);
34
34
  export function fromView(atom, opts) {
35
- opts = optsWithID("view", opts);
35
+ opts = __optsWithID("view", opts);
36
36
  return new Stream((stream) => {
37
37
  let isActive = true;
38
38
  const tx = opts.tx;
@@ -1,5 +1,4 @@
1
- import { WithErrorHandlerOpts } from "../api";
2
- import { Stream } from "../stream";
1
+ import type { WithErrorHandlerOpts } from "./api.js";
3
2
  export interface FromWorkerOpts extends WithErrorHandlerOpts {
4
3
  /**
5
4
  * If true, the worker will be terminated when the stream
@@ -32,5 +31,5 @@ export interface FromWorkerOpts extends WithErrorHandlerOpts {
32
31
  * @param worker -
33
32
  * @param opts -
34
33
  */
35
- export declare const fromWorker: <T>(worker: Worker | Blob | string, opts?: Partial<FromWorkerOpts> | undefined) => Stream<T>;
34
+ export declare const fromWorker: <T>(worker: Worker | Blob | string, opts?: Partial<FromWorkerOpts> | undefined) => import("./stream.js").Stream<T>;
36
35
  //# sourceMappingURL=worker.d.ts.map
@@ -1,7 +1,7 @@
1
- import { LOGGER } from "../api";
2
- import { Stream } from "../stream";
3
- import { optsWithID } from "../utils/idgen";
4
- import { makeWorker } from "../utils/worker";
1
+ import { defWorker } from "./defworker.js";
2
+ import { __optsWithID } from "./idgen.js";
3
+ import { LOGGER } from "./logger.js";
4
+ import { stream } from "./stream.js";
5
5
  /**
6
6
  * Returns a {@link Stream} which adds `message` and `error` event
7
7
  * listeners to given `worker` and then emits received values.
@@ -26,9 +26,9 @@ import { makeWorker } from "../utils/worker";
26
26
  * @param opts -
27
27
  */
28
28
  export const fromWorker = (worker, opts) => {
29
- const _worker = makeWorker(worker);
30
- opts = optsWithID("worker", opts);
31
- return new Stream((stream) => {
29
+ const _worker = defWorker(worker);
30
+ opts = __optsWithID("worker", opts);
31
+ return stream((stream) => {
32
32
  const msgListener = (e) => {
33
33
  stream.next(e.data);
34
34
  };