@thi.ng/transducers-async 0.3.11 → 0.4.1
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 +7 -1
- package/README.md +2 -2
- package/delayed.d.ts +4 -2
- package/package.json +11 -12
- package/pubsub.d.ts +10 -0
- package/pubsub.js +20 -1
- package/raf.d.ts +6 -6
- package/source.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2025-
|
|
3
|
+
- **Last updated**: 2025-02-13T16:03: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.
|
|
@@ -11,6 +11,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
11
11
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
12
12
|
and/or version bumps of transitive dependencies.
|
|
13
13
|
|
|
14
|
+
## [0.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers-async@0.4.0) (2025-01-29)
|
|
15
|
+
|
|
16
|
+
#### 🚀 Features
|
|
17
|
+
|
|
18
|
+
- add PubSub.subscribeOnce(), add tests ([34beec5](https://github.com/thi-ng/umbrella/commit/34beec5))
|
|
19
|
+
|
|
14
20
|
### [0.3.8](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers-async@0.3.8) (2025-01-14)
|
|
15
21
|
|
|
16
22
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 201 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -116,7 +116,7 @@ For Node.js REPL:
|
|
|
116
116
|
const txa = await import("@thi.ng/transducers-async");
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 3.
|
|
119
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 3.25 KB
|
|
120
120
|
|
|
121
121
|
## Dependencies
|
|
122
122
|
|
package/delayed.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Same as [thi.ng/compose
|
|
3
|
-
* `
|
|
2
|
+
* Same as [thi.ng/compose
|
|
3
|
+
* `delayed()`](https://docs.thi.ng/umbrella/compose/functions/delayed.html).
|
|
4
|
+
* Re-exported for convenience. Yields `x` as promise which only resolves after
|
|
5
|
+
* `delay` milliseconds.
|
|
4
6
|
*
|
|
5
7
|
* @remarks
|
|
6
8
|
* Also see {@link wait}.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/transducers-async",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Async versions of various highly composable transducers, reducers and iterators",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -33,24 +33,23 @@
|
|
|
33
33
|
"build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
|
|
34
34
|
"clean": "bun ../../tools/src/clean-package.ts",
|
|
35
35
|
"doc": "typedoc --options ../../typedoc.json --out doc src/index.ts",
|
|
36
|
-
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
37
36
|
"doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
|
|
38
37
|
"pub": "yarn npm publish --access public",
|
|
39
38
|
"test": "bun test",
|
|
40
39
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
41
40
|
},
|
|
42
41
|
"dependencies": {
|
|
43
|
-
"@thi.ng/api": "^8.11.
|
|
44
|
-
"@thi.ng/buffers": "^1.0.
|
|
45
|
-
"@thi.ng/checks": "^3.6.
|
|
46
|
-
"@thi.ng/compose": "^3.0.
|
|
47
|
-
"@thi.ng/errors": "^2.5.
|
|
48
|
-
"@thi.ng/timestamp": "^1.1.
|
|
49
|
-
"@thi.ng/transducers": "^9.2.
|
|
42
|
+
"@thi.ng/api": "^8.11.20",
|
|
43
|
+
"@thi.ng/buffers": "^1.0.5",
|
|
44
|
+
"@thi.ng/checks": "^3.6.23",
|
|
45
|
+
"@thi.ng/compose": "^3.0.23",
|
|
46
|
+
"@thi.ng/errors": "^2.5.26",
|
|
47
|
+
"@thi.ng/timestamp": "^1.1.5",
|
|
48
|
+
"@thi.ng/transducers": "^9.2.18"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
|
-
"esbuild": "^0.
|
|
53
|
-
"typedoc": "^0.27.
|
|
51
|
+
"esbuild": "^0.25.0",
|
|
52
|
+
"typedoc": "^0.27.7",
|
|
54
53
|
"typescript": "^5.7.3"
|
|
55
54
|
},
|
|
56
55
|
"keywords": [
|
|
@@ -212,5 +211,5 @@
|
|
|
212
211
|
"status": "alpha",
|
|
213
212
|
"year": 2018
|
|
214
213
|
},
|
|
215
|
-
"gitHead": "
|
|
214
|
+
"gitHead": "9a0b33253fef092aaf301decf6ecd54317874d4c\n"
|
|
216
215
|
}
|
package/pubsub.d.ts
CHANGED
|
@@ -14,6 +14,16 @@ export declare class PubSub<K, V> {
|
|
|
14
14
|
* {@link PubSub.unsubscribeTopic}.
|
|
15
15
|
*/
|
|
16
16
|
subscribeTopic(id: K): AsyncIterable<V>;
|
|
17
|
+
/**
|
|
18
|
+
* Similar to {@link PubSub.subscribeTopic}, but for one-off event handling.
|
|
19
|
+
* Creates a new subscription for topic `id` and waits for next value. Once
|
|
20
|
+
* received, it immediately unsubscribes again and then calls `fn` with
|
|
21
|
+
* value.
|
|
22
|
+
*
|
|
23
|
+
* @param id
|
|
24
|
+
* @param fn
|
|
25
|
+
*/
|
|
26
|
+
subscribeOnce(id: K, fn: Fn<V, void>): void;
|
|
17
27
|
/**
|
|
18
28
|
* Attempts to remove given child subscription (presumably created via
|
|
19
29
|
* {@link PubSub.subscribeTopic}). Returns true if removal was successful.
|
package/pubsub.js
CHANGED
|
@@ -26,6 +26,25 @@ class PubSub {
|
|
|
26
26
|
}
|
|
27
27
|
return sub;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Similar to {@link PubSub.subscribeTopic}, but for one-off event handling.
|
|
31
|
+
* Creates a new subscription for topic `id` and waits for next value. Once
|
|
32
|
+
* received, it immediately unsubscribes again and then calls `fn` with
|
|
33
|
+
* value.
|
|
34
|
+
*
|
|
35
|
+
* @param id
|
|
36
|
+
* @param fn
|
|
37
|
+
*/
|
|
38
|
+
subscribeOnce(id, fn) {
|
|
39
|
+
const sub = this.subscribeTopic(id);
|
|
40
|
+
const $this = this;
|
|
41
|
+
(async () => {
|
|
42
|
+
for await (let x of sub) {
|
|
43
|
+
$this.unsubscribeTopic(id, sub);
|
|
44
|
+
fn(x);
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
47
|
+
}
|
|
29
48
|
/**
|
|
30
49
|
* Attempts to remove given child subscription (presumably created via
|
|
31
50
|
* {@link PubSub.subscribeTopic}). Returns true if removal was successful.
|
|
@@ -35,7 +54,7 @@ class PubSub {
|
|
|
35
54
|
unsubscribeTopic(id, sub) {
|
|
36
55
|
const subs = this.topics.get(id);
|
|
37
56
|
if (!subs) return false;
|
|
38
|
-
const idx = subs.findIndex((x) => x === sub)
|
|
57
|
+
const idx = subs.findIndex((x) => x === sub);
|
|
39
58
|
if (idx >= 0) {
|
|
40
59
|
subs.splice(idx, 1);
|
|
41
60
|
sub.resolve(void 0);
|
package/raf.d.ts
CHANGED
|
@@ -4,17 +4,17 @@ export interface RAFOpts {
|
|
|
4
4
|
/**
|
|
5
5
|
* If true (default: false), passes the timestamps received
|
|
6
6
|
* via `requestAnimationFrame()` as iterator values. If false, a simple
|
|
7
|
-
* counter [0
|
|
7
|
+
* counter `[0,∞)` will be emitted.
|
|
8
8
|
*
|
|
9
9
|
* @defaultValue false
|
|
10
10
|
*/
|
|
11
11
|
timestamp: boolean;
|
|
12
12
|
/**
|
|
13
|
-
* Only used if {@link RAFOpts.timestamp} is enabled. If given as
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* Only used if {@link RAFOpts.timestamp} is enabled. If given as number,
|
|
14
|
+
* the value will be subtracted from all emitted timestamps. If this option
|
|
15
|
+
* is set to true, the timestamps will be automatically zero-adjusted such
|
|
16
|
+
* that the first emitted value will be zero. If undefined (default), the
|
|
17
|
+
* browser supplied timestamps will be used as is.
|
|
18
18
|
*/
|
|
19
19
|
t0: number | boolean;
|
|
20
20
|
}
|
package/source.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export interface Source<T> extends ClosableAsyncGenerator<T>, IDeref<Maybe<T>> {
|
|
|
48
48
|
* @remarks
|
|
49
49
|
* See [thi.ng/buffers](https://thi.ng/buffers) for available buffer
|
|
50
50
|
* implementations. By default a
|
|
51
|
-
* [`fifo
|
|
51
|
+
* [`fifo`](https://docs.thi.ng/umbrella/buffers/functions/fifo.html) buffer
|
|
52
52
|
* with capacity=1 is used.
|
|
53
53
|
*
|
|
54
54
|
* If `initial` is given, the source will immediately deliver this value once a
|