@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/README.md
CHANGED
|
@@ -184,15 +184,24 @@ src.transformTopic("foo", map((e) => e.value), { error: handleError })
|
|
|
184
184
|
yarn add @thi.ng/rstream
|
|
185
185
|
```
|
|
186
186
|
|
|
187
|
+
ES module import:
|
|
188
|
+
|
|
187
189
|
```html
|
|
188
|
-
|
|
189
|
-
|
|
190
|
+
<script type="module" src="https://cdn.skypack.dev/@thi.ng/rstream"></script>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
[Skypack documentation](https://docs.skypack.dev/)
|
|
194
|
+
|
|
195
|
+
For Node.js REPL:
|
|
196
|
+
|
|
197
|
+
```text
|
|
198
|
+
# with flag only for < v16
|
|
199
|
+
node --experimental-repl-await
|
|
190
200
|
|
|
191
|
-
|
|
192
|
-
<script src="https://unpkg.com/@thi.ng/rstream/lib/index.umd.js" crossorigin></script>
|
|
201
|
+
> const rstream = await import("@thi.ng/rstream");
|
|
193
202
|
```
|
|
194
203
|
|
|
195
|
-
Package sizes (gzipped, pre-treeshake): ESM: 5.
|
|
204
|
+
Package sizes (gzipped, pre-treeshake): ESM: 5.78 KB
|
|
196
205
|
|
|
197
206
|
## Dependencies
|
|
198
207
|
|
|
@@ -202,6 +211,7 @@ Package sizes (gzipped, pre-treeshake): ESM: 5.56 KB / CJS: 5.75 KB / UMD: 5.71
|
|
|
202
211
|
- [@thi.ng/atom](https://github.com/thi-ng/umbrella/tree/develop/packages/atom)
|
|
203
212
|
- [@thi.ng/checks](https://github.com/thi-ng/umbrella/tree/develop/packages/checks)
|
|
204
213
|
- [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/develop/packages/errors)
|
|
214
|
+
- [@thi.ng/logger](https://github.com/thi-ng/umbrella/tree/develop/packages/logger)
|
|
205
215
|
- [@thi.ng/transducers](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers)
|
|
206
216
|
|
|
207
217
|
## Usage examples
|
|
@@ -212,30 +222,38 @@ directory are using this package.
|
|
|
212
222
|
|
|
213
223
|
A selection:
|
|
214
224
|
|
|
215
|
-
| Screenshot
|
|
216
|
-
|
|
217
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/adaptive-threshold.png" width="240"/>
|
|
218
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/bitmap-font.gif" width="240"/>
|
|
219
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
220
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
221
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
222
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
223
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/
|
|
224
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
225
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
226
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/
|
|
227
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/
|
|
228
|
-
|
|
|
229
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
230
|
-
|
|
|
231
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
232
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
233
|
-
|
|
|
234
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
235
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
236
|
-
|
|
|
237
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
238
|
-
|
|
|
225
|
+
| Screenshot | Description | Live demo | Source |
|
|
226
|
+
|:-------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:----------------------------------------------------------|:---------------------------------------------------------------------------------------|
|
|
227
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/adaptive-threshold.png" width="240"/> | Interactive image processing (adaptive threshold) | [Demo](https://demo.thi.ng/umbrella/adaptive-threshold/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/adaptive-threshold) |
|
|
228
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/bitmap-font.gif" width="240"/> | Figlet-style bitmap font creation with transducers | [Demo](https://demo.thi.ng/umbrella/bitmap-font/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/bitmap-font) |
|
|
229
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/canvas-dial.png" width="240"/> | Canvas based dial widget | [Demo](https://demo.thi.ng/umbrella/canvas-dial/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/canvas-dial) |
|
|
230
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/color-themes.png" width="240"/> | Probabilistic color theme generator | [Demo](https://demo.thi.ng/umbrella/color-themes/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/color-themes) |
|
|
231
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/crypto-chart.png" width="240"/> | Basic crypto-currency candle chart with multiple moving averages plots | [Demo](https://demo.thi.ng/umbrella/crypto-chart/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/crypto-chart) |
|
|
232
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/dominant-colors.png" width="240"/> | Color palette generation via dominant color extraction from uploaded images | [Demo](https://demo.thi.ng/umbrella/dominant-colors/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/dominant-colors) |
|
|
233
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/fft-synth.png" width="240"/> | Interactive inverse FFT toy synth | [Demo](https://demo.thi.ng/umbrella/fft-synth/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/fft-synth) |
|
|
234
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/gesture-analysis.png" width="240"/> | Mouse gesture / stroke analysis, simplification, corner detection | [Demo](https://demo.thi.ng/umbrella/gesture-analysis/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/gesture-analysis) |
|
|
235
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/hdom-canvas-draw.jpg" width="240"/> | Interactive pattern drawing demo using transducers | [Demo](https://demo.thi.ng/umbrella/hdom-canvas-draw/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-canvas-draw) |
|
|
236
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/hdom-canvas/hdom-canvas-shapes-results.png" width="240"/> | Various hdom-canvas shape drawing examples & SVG conversion / export | [Demo](https://demo.thi.ng/umbrella/hdom-canvas-shapes/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-canvas-shapes) |
|
|
237
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/imgui/imgui-all.png" width="240"/> | Canvas based Immediate Mode GUI components | [Demo](https://demo.thi.ng/umbrella/imgui/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/imgui) |
|
|
238
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/mandelbrot.jpg" width="240"/> | Worker based, interactive Mandelbrot visualization | [Demo](https://demo.thi.ng/umbrella/mandelbrot/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/mandelbrot) |
|
|
239
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/markdown-parser.jpg" width="240"/> | Minimal Markdown to Hiccup to HTML parser / transformer | [Demo](https://demo.thi.ng/umbrella/markdown/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/markdown) |
|
|
240
|
+
| | Basic rstream-gestures multi-touch demo | [Demo](https://demo.thi.ng/umbrella/multitouch/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/multitouch) |
|
|
241
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/parse-playground.png" width="240"/> | Parser grammar livecoding editor/playground & codegen | [Demo](https://demo.thi.ng/umbrella/parse-playground/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/parse-playground) |
|
|
242
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/pixel-sorting.png" width="240"/> | Interactive pixel sorting tool using thi.ng/color & thi.ng/pixel | [Demo](https://demo.thi.ng/umbrella/pixel-sorting/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/pixel-sorting) |
|
|
243
|
+
| | Demonstates various rdom usage patterns | [Demo](https://demo.thi.ng/umbrella/rdom-basics/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rdom-basics) |
|
|
244
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rdom-delayed-update.jpg" width="240"/> | Dynamically loaded images w/ preloader state | [Demo](https://demo.thi.ng/umbrella/rdom-delayed-update/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rdom-delayed-update) |
|
|
245
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rdom-lissajous.png" width="240"/> | rdom & hiccup-canvas interop test | [Demo](https://demo.thi.ng/umbrella/rdom-lissajous/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rdom-lissajous) |
|
|
246
|
+
| | Full umbrella repo doc string search w/ paginated results | [Demo](https://demo.thi.ng/umbrella/rdom-search-docs/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rdom-search-docs) |
|
|
247
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rdom-svg-nodes.png" width="240"/> | rdom powered SVG graph with draggable nodes | [Demo](https://demo.thi.ng/umbrella/rdom-svg-nodes/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rdom-svg-nodes) |
|
|
248
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rotating-voronoi.jpg" width="240"/> | Animated Voronoi diagram, cubic splines & SVG download | [Demo](https://demo.thi.ng/umbrella/rotating-voronoi/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rotating-voronoi) |
|
|
249
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rstream-event-loop.png" width="240"/> | Minimal demo of using rstream constructs to form an interceptor-style event loop | [Demo](https://demo.thi.ng/umbrella/rstream-event-loop/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-event-loop) |
|
|
250
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rstream-grid.jpg" width="240"/> | Interactive grid generator, SVG generation & export, undo/redo support | [Demo](https://demo.thi.ng/umbrella/rstream-grid/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-grid) |
|
|
251
|
+
| | rstream based UI updates & state handling | [Demo](https://demo.thi.ng/umbrella/rstream-hdom/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-hdom) |
|
|
252
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rstream-spreadsheet.png" width="240"/> | rstream based spreadsheet w/ S-expression formula DSL | [Demo](https://demo.thi.ng/umbrella/rstream-spreadsheet/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-spreadsheet) |
|
|
253
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/shader-ast-workers.jpg" width="240"/> | Fork-join worker-based raymarch renderer (JS/CPU only) | [Demo](https://demo.thi.ng/umbrella/shader-ast-workers/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-workers) |
|
|
254
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/talk-slides.png" width="240"/> | hdom based slide deck viewer & slides from my ClojureX 2018 keynote | [Demo](https://demo.thi.ng/umbrella/talk-slides/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/talk-slides) |
|
|
255
|
+
| | Transducer & rstream based hdom UI updates | [Demo](https://demo.thi.ng/umbrella/transducers-hdom/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/transducers-hdom) |
|
|
256
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-cubemap.jpg" width="240"/> | WebGL cube maps with async texture loading | [Demo](https://demo.thi.ng/umbrella/webgl-cubemap/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/webgl-cubemap) |
|
|
239
257
|
|
|
240
258
|
## API
|
|
241
259
|
|
|
@@ -331,7 +349,7 @@ b.next(42);
|
|
|
331
349
|
|
|
332
350
|
`Stream` (like all other types of `Subscription`) implements the
|
|
333
351
|
[@thi.ng/api
|
|
334
|
-
`IDeref`](https://
|
|
352
|
+
`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html)
|
|
335
353
|
interface which provides read access to a stream's last received value.
|
|
336
354
|
This is useful for various purposes, e.g. in combination with
|
|
337
355
|
@thi.ng/hdom, which supports direct embedding of streams (i.e. their
|
|
@@ -378,23 +396,23 @@ s.next(42);
|
|
|
378
396
|
#### Other stream creation helpers
|
|
379
397
|
|
|
380
398
|
- [reactive()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/stream.ts) - syntax sugar for `stream()` with initial value
|
|
381
|
-
- [fromAtom()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
399
|
+
- [fromAtom()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/atom.ts) - streams from value changes in atoms/cursors
|
|
382
400
|
- [fromChannel()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream-csp) - CSP channel to stream conversion
|
|
383
|
-
- [fromEvent()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
384
|
-
- [fromDOMEvent()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
385
|
-
- [fromInterval()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
386
|
-
- [fromIterable()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
387
|
-
- [fromObject()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
388
|
-
- [fromPromise()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
389
|
-
- [fromPromises()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
390
|
-
- [fromRAF()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
391
|
-
- [fromView()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
392
|
-
- [fromWorker()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
401
|
+
- [fromEvent()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/event.ts) - events
|
|
402
|
+
- [fromDOMEvent()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/event.ts#L25) - DOM events
|
|
403
|
+
- [fromInterval()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/interval.ts) - interval based counters
|
|
404
|
+
- [fromIterable()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/iterable.ts) - arrays, iterators / generators (async & sync)
|
|
405
|
+
- [fromObject()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/object.ts) - object property streams
|
|
406
|
+
- [fromPromise()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/promise.ts) - single value stream from promise
|
|
407
|
+
- [fromPromises()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/promises.ts) - results from multiple promise
|
|
408
|
+
- [fromRAF()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/raf.ts) - requestAnimationFrame() counter (w/ node fallback)
|
|
409
|
+
- [fromView()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/view.ts) - derived view changes (see [@thi.ng/atom](https://github.com/thi-ng/umbrella/tree/develop/packages/atom))
|
|
410
|
+
- [fromWorker()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/worker.ts) - messages received from worker
|
|
393
411
|
- [trigger()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/trigger.ts) - one-off events
|
|
394
412
|
|
|
395
413
|
### Meta streams
|
|
396
414
|
|
|
397
|
-
Source: [metaStream()](https://github.com/thi-ng/umbrella/
|
|
415
|
+
Source: [metaStream()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/metastream.ts)
|
|
398
416
|
|
|
399
417
|
`MetaStream`s are streams of streams. A `MetaStream` is a subscription
|
|
400
418
|
type which transforms each incoming value into a new stream, subscribes
|
|
@@ -642,7 +660,7 @@ called WITHOUT argument to unsubscribe the entire `PubSub` instance
|
|
|
642
660
|
|
|
643
661
|
#### Splitting via predicate
|
|
644
662
|
|
|
645
|
-
Source: [bisect()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
663
|
+
Source: [bisect()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/bisect.ts)
|
|
646
664
|
|
|
647
665
|
Returns a new `PubSub` instance using given predicate `pred` as boolean
|
|
648
666
|
topic function and `a` & `b` as subscribers for truthy (`a`) and falsy
|
|
@@ -687,7 +705,7 @@ fromIterable([1, 2, 3, 4]).subscribe(bisect((x) => !!(x & 1), odd, even));
|
|
|
687
705
|
|
|
688
706
|
#### Input chunking / buffering, controlled by sidechain
|
|
689
707
|
|
|
690
|
-
Source: [sidechainPartition()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
708
|
+
Source: [sidechainPartition()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/sidechain-partition.ts)
|
|
691
709
|
|
|
692
710
|

|
|
693
711
|
|
|
@@ -712,7 +730,7 @@ merge([
|
|
|
712
730
|
|
|
713
731
|
#### Input toggling, controlled by sidechain
|
|
714
732
|
|
|
715
|
-
Source: [sidechainToggle()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
733
|
+
Source: [sidechainToggle()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/sidechain-toggle.ts)
|
|
716
734
|
|
|
717
735
|

|
|
718
736
|
|
|
@@ -789,26 +807,26 @@ src.next(new Array(16).fill(1));
|
|
|
789
807
|
|
|
790
808
|
#### Stream processing via workers
|
|
791
809
|
|
|
792
|
-
Source: [tunnel()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
810
|
+
Source: [tunnel()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/tunnel.ts)
|
|
793
811
|
|
|
794
812
|
Delegate stream value processing to workers and pass on their responses
|
|
795
813
|
to downstream subscriptions. Supports multiple worker instances and
|
|
796
814
|
worker termination / restart for each new stream value received.
|
|
797
815
|
|
|
798
|
-
Source: [postWorker()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
816
|
+
Source: [postWorker()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/post-worker.ts)
|
|
799
817
|
|
|
800
818
|
Send values to workers (incl. optional (inline) worker instantiation)
|
|
801
819
|
|
|
802
|
-
Source: [fromWorker()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
820
|
+
Source: [fromWorker()](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/worker.ts)
|
|
803
821
|
|
|
804
822
|
Create value stream from worker messages.
|
|
805
823
|
|
|
806
824
|
### Other subscription ops
|
|
807
825
|
|
|
808
|
-
- [debounce](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
809
|
-
- [resolve](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
810
|
-
- [trace](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
811
|
-
- [transduce](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/
|
|
826
|
+
- [debounce](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/debounce.ts) - ignore high frequency interim values
|
|
827
|
+
- [resolve](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/resolve.ts) - resolve on-stream promises
|
|
828
|
+
- [trace](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/trace.ts) - debug helper
|
|
829
|
+
- [transduce](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/transduce.ts) - transduce or just reduce an entire stream into a promise
|
|
812
830
|
- [tween](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream/src/tween.ts) - stream interpolation
|
|
813
831
|
|
|
814
832
|
### Error handling
|
package/api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Fn, Fn0, IDeref, IID
|
|
1
|
+
import type { Fn, Fn0, IDeref, IID } from "@thi.ng/api";
|
|
2
2
|
import type { Transducer } from "@thi.ng/transducers";
|
|
3
|
-
import type { Stream } from "./stream";
|
|
3
|
+
import type { Stream } from "./stream.js";
|
|
4
4
|
export declare enum State {
|
|
5
5
|
IDLE = 0,
|
|
6
6
|
ACTIVE = 1,
|
|
@@ -183,6 +183,4 @@ 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 let LOGGER: ILogger;
|
|
187
|
-
export declare const setLogger: (logger: ILogger) => ILogger;
|
|
188
186
|
//# sourceMappingURL=api.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { NULL_LOGGER } from "@thi.ng/api";
|
|
2
1
|
export var State;
|
|
3
2
|
(function (State) {
|
|
4
3
|
State[State["IDLE"] = 0] = "IDLE";
|
|
@@ -25,5 +24,3 @@ export var CloseMode;
|
|
|
25
24
|
*/
|
|
26
25
|
CloseMode[CloseMode["LAST"] = 2] = "LAST";
|
|
27
26
|
})(CloseMode || (CloseMode = {}));
|
|
28
|
-
export let LOGGER = NULL_LOGGER;
|
|
29
|
-
export const setLogger = (logger) => (LOGGER = logger);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CommonOpts, ISubscription } from "
|
|
2
|
-
import { Subscription } from "
|
|
1
|
+
import type { CommonOpts, ISubscription } from "./api.js";
|
|
2
|
+
import { Subscription } from "./subscription.js";
|
|
3
3
|
/**
|
|
4
4
|
* Abstract base class for sidechained subscription types (e.g.
|
|
5
5
|
* {@link sidechainPartition}, {@link sidechainToggle}).
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Predicate2 } from "@thi.ng/api";
|
|
2
2
|
import type { ReadonlyAtom } from "@thi.ng/atom";
|
|
3
|
-
import type { CommonOpts } from "
|
|
4
|
-
import { Stream } from "../stream";
|
|
3
|
+
import type { CommonOpts } from "./api.js";
|
|
5
4
|
export interface FromAtomOpts<T> extends CommonOpts {
|
|
6
5
|
/**
|
|
7
6
|
* True, if the current atom value should be emitted when the stream
|
|
@@ -49,5 +48,5 @@ export interface FromAtomOpts<T> extends CommonOpts {
|
|
|
49
48
|
* @param atom -
|
|
50
49
|
* @param opts -
|
|
51
50
|
*/
|
|
52
|
-
export declare const fromAtom: <T>(atom: ReadonlyAtom<T>, opts?: Partial<FromAtomOpts<T>> | undefined) => Stream<T>;
|
|
51
|
+
export declare const fromAtom: <T>(atom: ReadonlyAtom<T>, opts?: Partial<FromAtomOpts<T>> | undefined) => import("./stream.js").Stream<T>;
|
|
53
52
|
//# sourceMappingURL=atom.d.ts.map
|
package/{from/atom.js → atom.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __optsWithID } from "./idgen.js";
|
|
2
|
+
import { stream } from "./stream.js";
|
|
3
3
|
/**
|
|
4
4
|
* Yields {@link Stream} of value changes in given
|
|
5
5
|
* {@link @thi.ng/atom# | Atom-like state container}.
|
|
@@ -32,8 +32,12 @@ import { optsWithID } from "../utils/idgen";
|
|
|
32
32
|
* @param opts -
|
|
33
33
|
*/
|
|
34
34
|
export const fromAtom = (atom, opts) => {
|
|
35
|
-
opts =
|
|
36
|
-
|
|
35
|
+
opts = __optsWithID("atom", {
|
|
36
|
+
emitFirst: true,
|
|
37
|
+
changed: (a, b) => a !== b,
|
|
38
|
+
...opts,
|
|
39
|
+
});
|
|
40
|
+
return stream((stream) => {
|
|
37
41
|
atom.addWatch(stream.id, (_, prev, curr) => {
|
|
38
42
|
if (opts.changed(prev, curr)) {
|
|
39
43
|
stream.next(curr);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Predicate } from "@thi.ng/api";
|
|
2
|
-
import type { ISubscriber } from "
|
|
3
|
-
import { PubSub } from "
|
|
2
|
+
import type { ISubscriber } from "./api.js";
|
|
3
|
+
import { PubSub } from "./pubsub.js";
|
|
4
4
|
/**
|
|
5
5
|
* Returns a {@link PubSub} using given predicate `pred` as boolean
|
|
6
6
|
* {@link PubSubOpts.topic | topic function} and `truthy` & `falsey` as
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __nextID } from "./idgen.js";
|
|
2
|
+
import { PubSub } from "./pubsub.js";
|
|
3
3
|
/**
|
|
4
4
|
* Returns a {@link PubSub} using given predicate `pred` as boolean
|
|
5
5
|
* {@link PubSubOpts.topic | topic function} and `truthy` & `falsey` as
|
|
@@ -45,7 +45,7 @@ import { nextID } from "../utils/idgen";
|
|
|
45
45
|
* @param falsy - subscription for falsy branch
|
|
46
46
|
*/
|
|
47
47
|
export const bisect = (pred, truthy, falsy) => {
|
|
48
|
-
const sub = new PubSub({ topic: pred, id: `bisect-${
|
|
48
|
+
const sub = new PubSub({ topic: pred, id: `bisect-${__nextID()}` });
|
|
49
49
|
truthy && sub.subscribeTopic(true, truthy);
|
|
50
50
|
falsy && sub.subscribeTopic(false, falsy);
|
|
51
51
|
return sub;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { implementsFunction } from "@thi.ng/checks/implements-function";
|
|
2
|
+
import { CloseMode } from "./api.js";
|
|
3
|
+
export const isSubscribable = (x) => implementsFunction(x, "subscribe");
|
|
2
4
|
/**
|
|
3
5
|
* Returns true if mode is FIRST, or if mode is LAST *and* `num = 0`.
|
|
4
6
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MetaStreamOpts } from "
|
|
1
|
+
import { MetaStreamOpts } from "./metastream.js";
|
|
2
2
|
/**
|
|
3
3
|
* Returns a subscription which buffers any intermediate inputs arriving faster
|
|
4
4
|
* than given `delay` time period, then emits last received value after `delay`
|
|
@@ -13,5 +13,5 @@ import { MetaStreamOpts } from "../metastream";
|
|
|
13
13
|
*
|
|
14
14
|
* @param delay
|
|
15
15
|
*/
|
|
16
|
-
export declare const debounce: <T>(delay: number, opts?: Partial<MetaStreamOpts> | undefined) => import("
|
|
16
|
+
export declare const debounce: <T>(delay: number, opts?: Partial<MetaStreamOpts> | undefined) => import("./metastream.js").MetaStream<T, T>;
|
|
17
17
|
//# sourceMappingURL=debounce.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { __optsWithID } from "./idgen.js";
|
|
2
|
+
import { fromIterable } from "./iterable.js";
|
|
3
|
+
import { metaStream } from "./metastream.js";
|
|
4
4
|
/**
|
|
5
5
|
* Returns a subscription which buffers any intermediate inputs arriving faster
|
|
6
6
|
* than given `delay` time period, then emits last received value after `delay`
|
|
@@ -15,4 +15,7 @@ import { optsWithID } from "../utils/idgen";
|
|
|
15
15
|
*
|
|
16
16
|
* @param delay
|
|
17
17
|
*/
|
|
18
|
-
export const debounce = (delay, opts) => metaStream((x) => fromIterable([x], { delay }),
|
|
18
|
+
export const debounce = (delay, opts) => metaStream((x) => fromIterable([x], { delay }), __optsWithID("debounce", {
|
|
19
|
+
emitLast: true,
|
|
20
|
+
...opts,
|
|
21
|
+
}));
|
package/defworker.d.ts
ADDED
package/defworker.js
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CommonOpts } from "
|
|
2
|
-
import { Stream } from "
|
|
1
|
+
import type { CommonOpts } from "./api.js";
|
|
2
|
+
import { Stream } from "./stream.js";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a {@link Stream} of events attached to given element / event
|
|
5
5
|
* target and using given event listener options (same as supported by
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __optsWithID } from "./idgen.js";
|
|
2
|
+
import { stream } from "./stream.js";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a {@link Stream} of events attached to given element / event
|
|
5
5
|
* target and using given event listener options (same as supported by
|
|
@@ -10,11 +10,11 @@ import { optsWithID } from "../utils/idgen";
|
|
|
10
10
|
* @param listenerOpts - listener opts
|
|
11
11
|
* @param streamOpts - stream opts
|
|
12
12
|
*/
|
|
13
|
-
export const fromEvent = (src, name, listenerOpts = false, streamOpts) =>
|
|
13
|
+
export const fromEvent = (src, name, listenerOpts = false, streamOpts) => stream((stream) => {
|
|
14
14
|
let listener = (e) => stream.next(e);
|
|
15
15
|
src.addEventListener(name, listener, listenerOpts);
|
|
16
16
|
return () => src.removeEventListener(name, listener, listenerOpts);
|
|
17
|
-
},
|
|
17
|
+
}, __optsWithID(`event-${name}`, streamOpts));
|
|
18
18
|
/**
|
|
19
19
|
* Same as {@link fromEvent}, however only supports well-known DOM event
|
|
20
20
|
* names. Returned stream instance will use corresponding concrete event
|
package/forkjoin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ArrayLikeIterable, Fn, Fn3 } from "@thi.ng/api";
|
|
2
|
-
import type { CommonOpts, ITransformable } from "./api";
|
|
3
|
-
import type { Subscription } from "./subscription";
|
|
2
|
+
import type { CommonOpts, ITransformable } from "./api.js";
|
|
3
|
+
import type { Subscription } from "./subscription.js";
|
|
4
4
|
export interface ForkJoinOpts<IN, MSG, RES, OUT> extends Partial<CommonOpts> {
|
|
5
5
|
/**
|
|
6
6
|
* Input stream to attach to obtain work items from.
|
package/forkjoin.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { assocObj
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { assocObj } from "@thi.ng/transducers/assoc-obj";
|
|
2
|
+
import { comp } from "@thi.ng/transducers/comp";
|
|
3
|
+
import { map } from "@thi.ng/transducers/map";
|
|
4
|
+
import { mapcat } from "@thi.ng/transducers/mapcat";
|
|
5
|
+
import { range } from "@thi.ng/transducers/range";
|
|
6
|
+
import { transduce } from "@thi.ng/transducers/transduce";
|
|
7
|
+
import { sync } from "./sync.js";
|
|
8
|
+
import { tunnel } from "./tunnel.js";
|
|
4
9
|
/**
|
|
5
10
|
* Returns a {@link StreamSync} instance which creates & attaches
|
|
6
11
|
* multiple subscriptions to given `src` input stream, processes each
|
package/idgen.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommonOpts } from "./api.js";
|
|
2
|
+
export declare const __nextID: () => number;
|
|
3
|
+
/**
|
|
4
|
+
* @param prefix
|
|
5
|
+
* @param opts
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare const __optsWithID: <T extends CommonOpts>(prefix: string, opts?: Partial<T> | undefined) => Partial<T>;
|
|
10
|
+
//# sourceMappingURL=idgen.d.ts.map
|
package/idgen.js
ADDED
package/index.d.ts
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
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";
|
|
34
36
|
//# sourceMappingURL=index.d.ts.map
|