@thi.ng/transducers-async 0.3.10 → 0.4.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 +9 -1
- package/README.md +2 -2
- package/package.json +10 -12
- package/pubsub.d.ts +10 -0
- package/pubsub.js +20 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2025-01-
|
|
3
|
+
- **Last updated**: 2025-01-29T16:25:48Z
|
|
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.
|
|
7
|
+
Only versions published since **2022-01-01** are listed here.
|
|
8
|
+
Please consult the Git history for older version information.
|
|
7
9
|
See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
|
|
8
10
|
|
|
9
11
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
12
|
and/or version bumps of transitive dependencies.
|
|
11
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
|
+
|
|
12
20
|
### [0.3.8](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers-async@0.3.8) (2025-01-14)
|
|
13
21
|
|
|
14
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/transducers-async",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Async versions of various highly composable transducers, reducers and iterators",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -33,26 +33,24 @@
|
|
|
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.19",
|
|
43
|
+
"@thi.ng/buffers": "^1.0.4",
|
|
44
|
+
"@thi.ng/checks": "^3.6.22",
|
|
45
|
+
"@thi.ng/compose": "^3.0.22",
|
|
46
|
+
"@thi.ng/errors": "^2.5.25",
|
|
47
|
+
"@thi.ng/timestamp": "^1.1.4",
|
|
48
|
+
"@thi.ng/transducers": "^9.2.17"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
|
-
"@microsoft/api-extractor": "^7.48.1",
|
|
53
51
|
"esbuild": "^0.24.2",
|
|
54
52
|
"typedoc": "^0.27.6",
|
|
55
|
-
"typescript": "^5.7.
|
|
53
|
+
"typescript": "^5.7.3"
|
|
56
54
|
},
|
|
57
55
|
"keywords": [
|
|
58
56
|
"async",
|
|
@@ -213,5 +211,5 @@
|
|
|
213
211
|
"status": "alpha",
|
|
214
212
|
"year": 2018
|
|
215
213
|
},
|
|
216
|
-
"gitHead": "
|
|
214
|
+
"gitHead": "fc1d498e8d4b690db873c30cc594352a804e7a65\n"
|
|
217
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);
|