@thi.ng/rstream 8.2.24 → 8.3.0

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-01-30T15:21:31Z
3
+ - **Last updated**: 2024-02-06T23:18:11Z
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.
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [8.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream@8.3.0) (2024-02-06)
13
+
14
+ #### 🚀 Features
15
+
16
+ - update fromRAF() & opts ([27f4cde](https://github.com/thi-ng/umbrella/commit/27f4cde))
17
+ - update timestamp handling/opts
18
+
12
19
  ### [8.2.8](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream@8.2.8) (2023-11-09)
13
20
 
14
21
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -203,7 +203,7 @@ For Node.js REPL:
203
203
  const rstream = await import("@thi.ng/rstream");
204
204
  ```
205
205
 
206
- Package sizes (brotli'd, pre-treeshake): ESM: 6.13 KB
206
+ Package sizes (brotli'd, pre-treeshake): ESM: 6.15 KB
207
207
 
208
208
  ## Dependencies
209
209
 
@@ -264,6 +264,7 @@ directory are using this package:
264
264
  | | 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) |
265
265
  | <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) |
266
266
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rstream-sync.png" width="240"/> | Minimal rstream sync() example using rdom | [Demo](https://demo.thi.ng/umbrella/rstream-sync/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-sync) |
267
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rstream-system-bus.png" width="240"/> | Declarative component-based system with central rstream-based pubsub event bus | [Demo](https://demo.thi.ng/umbrella/rstream-system-bus/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-system-bus) |
267
268
  | <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) |
268
269
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/simd-plot.png" width="240"/> | Fitting, transforming & plotting 10k data points per frame using SIMD | [Demo](https://demo.thi.ng/umbrella/simd-plot/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/simd-plot) |
269
270
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/stacked-layout.png" width="240"/> | Responsive & reactively computed stacked column layout | [Demo](https://demo.thi.ng/umbrella/stacked-layout/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/stacked-layout) |
package/metastream.d.ts CHANGED
@@ -40,7 +40,7 @@ export interface MetaStreamOpts extends CommonOpts {
40
40
  * // transform each received odd number into a stream
41
41
  * // producing 3 copies of that number in the metastream
42
42
  * // even numbers are ignored
43
- * a = metastream(
43
+ * a = metaStream(
44
44
  * (x) => (x & 1)
45
45
  * ? fromIterable(tx.repeat(x, 3), { delay: 100 })
46
46
  * : null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/rstream",
3
- "version": "8.2.24",
3
+ "version": "8.3.0",
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.21",
43
- "@thi.ng/arrays": "^2.7.18",
44
- "@thi.ng/associative": "^6.3.34",
45
- "@thi.ng/atom": "^5.2.27",
46
- "@thi.ng/checks": "^3.4.21",
47
- "@thi.ng/errors": "^2.4.14",
48
- "@thi.ng/logger": "^2.1.7",
49
- "@thi.ng/transducers": "^8.8.25"
42
+ "@thi.ng/api": "^8.9.22",
43
+ "@thi.ng/arrays": "^2.7.19",
44
+ "@thi.ng/associative": "^6.3.36",
45
+ "@thi.ng/atom": "^5.2.29",
46
+ "@thi.ng/checks": "^3.4.22",
47
+ "@thi.ng/errors": "^2.4.15",
48
+ "@thi.ng/logger": "^2.1.9",
49
+ "@thi.ng/transducers": "^8.9.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@microsoft/api-extractor": "^7.39.0",
@@ -214,5 +214,5 @@
214
214
  ],
215
215
  "year": 2017
216
216
  },
217
- "gitHead": "ded7c5e87ebc7f6279c24f183c24ff348db8f304\n"
217
+ "gitHead": "ce8202c237a367c4038d41919a8acf75e1122507\n"
218
218
  }
package/raf.d.ts CHANGED
@@ -8,6 +8,14 @@ export interface FromRAFOpts extends CommonOpts {
8
8
  * @defaultValue false
9
9
  */
10
10
  timestamp: boolean;
11
+ /**
12
+ * Only used if {@link FromRAFOpts.timestamp} is enabled. If given as
13
+ * number, the value will be subtracted from all emitted timestamps. If this
14
+ * option is set to true, the timestamps will be automatically zero-adjusted
15
+ * such that the first emitted value will be zero. If undefined (default),
16
+ * the browser supplied timestamps will be used as is.
17
+ */
18
+ t0: number | boolean;
11
19
  }
12
20
  /**
13
21
  * Yields {@link Stream} of a monotonically increasing counter (or timestamps),
package/raf.js CHANGED
@@ -1,11 +1,18 @@
1
1
  import { isNode } from "@thi.ng/checks/is-node";
2
+ import { isNumber } from "@thi.ng/checks/is-number";
2
3
  import { __optsWithID } from "./idgen.js";
3
4
  import { fromInterval } from "./interval.js";
4
5
  import { stream } from "./stream.js";
5
6
  const fromRAF = (opts = {}) => isNode() ? fromInterval(16, opts) : stream((stream2) => {
6
7
  let i = 0;
7
8
  let isActive = true;
9
+ let t0 = isNumber(opts.t0) ? opts.t0 : void 0;
8
10
  const loop = (time) => {
11
+ if (opts.timestamp && opts.t0) {
12
+ if (t0 === void 0)
13
+ t0 = time;
14
+ time -= t0;
15
+ }
9
16
  isActive && stream2.next(opts.timestamp ? time : i++);
10
17
  isActive && (id = requestAnimationFrame(loop));
11
18
  };