@thi.ng/csp 3.2.44 → 3.3.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/README.md +2 -1
- package/ops.d.ts +5 -1
- package/ops.js +2 -1
- package/package.json +112 -111
- package/CHANGELOG.md +0 -107
package/README.md
CHANGED
|
@@ -158,11 +158,12 @@ For Node.js REPL:
|
|
|
158
158
|
const csp = await import("@thi.ng/csp");
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 1.
|
|
161
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 1.80 KB
|
|
162
162
|
|
|
163
163
|
## Dependencies
|
|
164
164
|
|
|
165
165
|
- [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
|
|
166
|
+
- [@thi.ng/arrays](https://github.com/thi-ng/umbrella/tree/develop/packages/arrays)
|
|
166
167
|
- [@thi.ng/buffers](https://github.com/thi-ng/umbrella/tree/develop/packages/buffers)
|
|
167
168
|
- [@thi.ng/checks](https://github.com/thi-ng/umbrella/tree/develop/packages/checks)
|
|
168
169
|
- [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/develop/packages/errors)
|
package/ops.d.ts
CHANGED
|
@@ -69,7 +69,11 @@ export declare const pipe: <T, DEST extends IWriteable<T> & IClosable>(src: Asyn
|
|
|
69
69
|
* Takes one or more input channels and attempts to read from all of them at
|
|
70
70
|
* once (via {@link Channel.race}, a blocking op). Returns a promise which
|
|
71
71
|
* resolves once one of the inputs becomes available or was closed, selects that
|
|
72
|
-
* channel to read from it and returns tuple of `[value, channel]`.
|
|
72
|
+
* channel to read from it and returns tuple of `[value, channel]`. If the
|
|
73
|
+
* selected channel already is closed, returns `[undefined, channel]`.
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* Since v3.3.0 inputs are automatically shuffled to avoid selection bias.
|
|
73
77
|
*
|
|
74
78
|
* @param input - first input
|
|
75
79
|
* @param rest - other inputs
|
package/ops.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { shuffle } from "@thi.ng/arrays/shuffle";
|
|
1
2
|
import { assert } from "@thi.ng/errors/assert";
|
|
2
3
|
import { Channel } from "./channel.js";
|
|
3
4
|
const broadcast = async (src, dest, close = true) => {
|
|
@@ -70,7 +71,7 @@ const pipe = (src, dest, close = true) => {
|
|
|
70
71
|
return dest;
|
|
71
72
|
};
|
|
72
73
|
const select = async (input, ...rest) => {
|
|
73
|
-
const inputs = [input, ...rest];
|
|
74
|
+
const inputs = shuffle([input, ...rest]);
|
|
74
75
|
const sel = await Promise.race(inputs.map((x) => x.race()));
|
|
75
76
|
for (let chan of inputs) {
|
|
76
77
|
if (chan !== sel) chan.races.shift();
|
package/package.json
CHANGED
|
@@ -1,112 +1,113 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
2
|
+
"name": "@thi.ng/csp",
|
|
3
|
+
"version": "3.3.4",
|
|
4
|
+
"description": "Primitives & operators for Communicating Sequential Processes based on async/await and async iterables",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"typings": "./index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://thi.ng/csp",
|
|
14
|
+
"funding": [
|
|
15
|
+
{
|
|
16
|
+
"type": "github",
|
|
17
|
+
"url": "https://github.com/sponsors/postspectacular"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "patreon",
|
|
21
|
+
"url": "https://patreon.com/thing_umbrella"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"type": "liberapay",
|
|
25
|
+
"url": "https://liberapay.com/thi.ng"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"author": "Karsten Schmidt (https://thi.ng)",
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "yarn build:esbuild && yarn build:decl",
|
|
32
|
+
"build:decl": "tsc --declaration --emitDeclarationOnly",
|
|
33
|
+
"build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
|
|
34
|
+
"clean": "bun ../../tools/src/clean-package.ts",
|
|
35
|
+
"doc": "typedoc --options ../../typedoc.json --out doc src/index.ts",
|
|
36
|
+
"doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
|
|
37
|
+
"pub": "npm publish --access public",
|
|
38
|
+
"test": "bun test",
|
|
39
|
+
"testasync": "tsc -p test && node build/test/async.js",
|
|
40
|
+
"testfile": "tsc -p test && node build/test/file.js",
|
|
41
|
+
"testgraph": "tsc -p test && node build/test/graph.js",
|
|
42
|
+
"testnode": "tsc -p test && node build/test/node.js",
|
|
43
|
+
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@thi.ng/api": "^8.12.6",
|
|
47
|
+
"@thi.ng/arrays": "^2.13.15",
|
|
48
|
+
"@thi.ng/buffers": "^1.0.25",
|
|
49
|
+
"@thi.ng/checks": "^3.7.22",
|
|
50
|
+
"@thi.ng/errors": "^2.5.46"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"esbuild": "^0.25.11",
|
|
54
|
+
"typedoc": "^0.28.14",
|
|
55
|
+
"typescript": "^5.9.3"
|
|
56
|
+
},
|
|
57
|
+
"keywords": [
|
|
58
|
+
"async",
|
|
59
|
+
"blocking",
|
|
60
|
+
"channel",
|
|
61
|
+
"communication",
|
|
62
|
+
"csp",
|
|
63
|
+
"datastructure",
|
|
64
|
+
"iterator",
|
|
65
|
+
"merge",
|
|
66
|
+
"multiplex",
|
|
67
|
+
"multitasking",
|
|
68
|
+
"pipeline",
|
|
69
|
+
"promise",
|
|
70
|
+
"pubsub",
|
|
71
|
+
"typescript"
|
|
72
|
+
],
|
|
73
|
+
"publishConfig": {
|
|
74
|
+
"access": "public"
|
|
75
|
+
},
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=18"
|
|
78
|
+
},
|
|
79
|
+
"files": [
|
|
80
|
+
"./*.js",
|
|
81
|
+
"./*.d.ts"
|
|
82
|
+
],
|
|
83
|
+
"exports": {
|
|
84
|
+
".": {
|
|
85
|
+
"default": "./index.js"
|
|
86
|
+
},
|
|
87
|
+
"./api": {
|
|
88
|
+
"default": "./api.js"
|
|
89
|
+
},
|
|
90
|
+
"./channel": {
|
|
91
|
+
"default": "./channel.js"
|
|
92
|
+
},
|
|
93
|
+
"./mult": {
|
|
94
|
+
"default": "./mult.js"
|
|
95
|
+
},
|
|
96
|
+
"./ops": {
|
|
97
|
+
"default": "./ops.js"
|
|
98
|
+
},
|
|
99
|
+
"./pubsub": {
|
|
100
|
+
"default": "./pubsub.js"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"thi.ng": {
|
|
104
|
+
"related": [
|
|
105
|
+
"fibers",
|
|
106
|
+
"rstream",
|
|
107
|
+
"transducers-async"
|
|
108
|
+
],
|
|
109
|
+
"status": "beta",
|
|
110
|
+
"year": 2016
|
|
111
|
+
},
|
|
112
|
+
"gitHead": "136a5e5ef0b69e82329db00d806c3c4e8f1aa063\n"
|
|
113
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
- **Last updated**: 2025-09-01T16:38:35Z
|
|
4
|
-
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
|
-
|
|
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.
|
|
9
|
-
See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
|
|
10
|
-
|
|
11
|
-
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
12
|
-
and/or version bumps of transitive dependencies.
|
|
13
|
-
|
|
14
|
-
### [3.2.13](https://github.com/thi-ng/umbrella/tree/@thi.ng/csp@3.2.13) (2024-10-17)
|
|
15
|
-
|
|
16
|
-
#### ♻️ Refactoring
|
|
17
|
-
|
|
18
|
-
- undeprecate `into()`, refactor `pipe()` ([c8788d9](https://github.com/thi-ng/umbrella/commit/c8788d9))
|
|
19
|
-
- update docstrings
|
|
20
|
-
|
|
21
|
-
### [3.2.2](https://github.com/thi-ng/umbrella/tree/@thi.ng/csp@3.2.2) (2024-06-21)
|
|
22
|
-
|
|
23
|
-
#### ♻️ Refactoring
|
|
24
|
-
|
|
25
|
-
- rename various rest args to be more semantically meaningful ([8088a56](https://github.com/thi-ng/umbrella/commit/8088a56))
|
|
26
|
-
- dedupe pipe() logic, deprecate into() ([5979527](https://github.com/thi-ng/umbrella/commit/5979527))
|
|
27
|
-
- update fromAsyncIterable()
|
|
28
|
-
- add docstrings
|
|
29
|
-
|
|
30
|
-
## [3.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/csp@3.2.0) (2024-04-28)
|
|
31
|
-
|
|
32
|
-
#### 🚀 Features
|
|
33
|
-
|
|
34
|
-
- update Mult/PubSub unsub handling, add docs ([32ad70e](https://github.com/thi-ng/umbrella/commit/32ad70e))
|
|
35
|
-
- add optional auto-closing for Mult.unsubscribe(), PubSub.unsubscribeTopic()
|
|
36
|
-
- add docs
|
|
37
|
-
|
|
38
|
-
#### 🩹 Bug fixes
|
|
39
|
-
|
|
40
|
-
- update select() ([5e87c8d](https://github.com/thi-ng/umbrella/commit/5e87c8d))
|
|
41
|
-
- update select(), ensure write queue of selected channel is being updated
|
|
42
|
-
- mark Channel.updateQueue() as internal
|
|
43
|
-
|
|
44
|
-
## [3.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/csp@3.1.0) (2024-04-26)
|
|
45
|
-
|
|
46
|
-
#### 🚀 Features
|
|
47
|
-
|
|
48
|
-
- add opt. generics for PubSub.subscribe()/unsubscribe() ([b4e9d20](https://github.com/thi-ng/umbrella/commit/b4e9d20))
|
|
49
|
-
- add into() to feed (async) iterables into a channel ([c7c1f6d](https://github.com/thi-ng/umbrella/commit/c7c1f6d))
|
|
50
|
-
|
|
51
|
-
# [3.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/csp@3.0.0) (2024-04-25)
|
|
52
|
-
|
|
53
|
-
#### 🛑 Breaking changes
|
|
54
|
-
|
|
55
|
-
- complete rewrite of Channel, Mult, PubSub, remove deps, add new operators ([2cf7431](https://github.com/thi-ng/umbrella/commit/2cf7431))
|
|
56
|
-
- BREAKING CHANGES: complete rewrite of Channel, Mult, PubSub, remove deps, add new operators
|
|
57
|
-
- remove/replace types
|
|
58
|
-
- remove buffer impls (now using [@thi.ng/buffers](https://github.com/thi-ng/umbrella/tree/main/packages/buffers))
|
|
59
|
-
- remove transducer handling (now done externally, e.g. via [@thi.ng/transducers-async](https://github.com/thi-ng/umbrella/tree/main/packages/transducers-async))
|
|
60
|
-
- replace Channel, Mult, PubSub
|
|
61
|
-
- remove obsolete dependencies
|
|
62
|
-
- add/update channel operators:
|
|
63
|
-
- broadcast()
|
|
64
|
-
- concat()
|
|
65
|
-
- consume() / consumeWith()
|
|
66
|
-
- drain()
|
|
67
|
-
- fromAsyncIterable()
|
|
68
|
-
- merge()
|
|
69
|
-
- pipe()
|
|
70
|
-
- select()
|
|
71
|
-
- timeout()
|
|
72
|
-
- add/update tests, remove old/obsolete ones
|
|
73
|
-
|
|
74
|
-
#### 🚀 Features
|
|
75
|
-
|
|
76
|
-
- update consume() to accept opt. limit ([164d1dd](https://github.com/thi-ng/umbrella/commit/164d1dd))
|
|
77
|
-
- add write queue, update tests ([f201401](https://github.com/thi-ng/umbrella/commit/f201401))
|
|
78
|
-
|
|
79
|
-
### [2.1.115](https://github.com/thi-ng/umbrella/tree/@thi.ng/csp@2.1.115) (2024-04-20)
|
|
80
|
-
|
|
81
|
-
#### ♻️ Refactoring
|
|
82
|
-
|
|
83
|
-
- update type usage ([749b24c](https://github.com/thi-ng/umbrella/commit/749b24c))
|
|
84
|
-
|
|
85
|
-
### [2.1.114](https://github.com/thi-ng/umbrella/tree/@thi.ng/csp@2.1.114) (2024-04-11)
|
|
86
|
-
|
|
87
|
-
#### 🚀 Features
|
|
88
|
-
|
|
89
|
-
- add initial new Channel impl & related ops/tests ([edddf61](https://github.com/thi-ng/umbrella/commit/edddf61))
|
|
90
|
-
|
|
91
|
-
### [2.1.113](https://github.com/thi-ng/umbrella/tree/@thi.ng/csp@2.1.113) (2024-04-08)
|
|
92
|
-
|
|
93
|
-
#### ♻️ Refactoring
|
|
94
|
-
|
|
95
|
-
- update reducer handling due to updates in [@thi.ng/transducers](https://github.com/thi-ng/umbrella/tree/main/packages/transducers) pkg ([5af4868](https://github.com/thi-ng/umbrella/commit/5af4868))
|
|
96
|
-
|
|
97
|
-
### [2.1.99](https://github.com/thi-ng/umbrella/tree/@thi.ng/csp@2.1.99) (2024-02-22)
|
|
98
|
-
|
|
99
|
-
#### ♻️ Refactoring
|
|
100
|
-
|
|
101
|
-
- update all `node:*` imports ([c71a526](https://github.com/thi-ng/umbrella/commit/c71a526))
|
|
102
|
-
|
|
103
|
-
### [2.1.76](https://github.com/thi-ng/umbrella/tree/@thi.ng/csp@2.1.76) (2023-11-09)
|
|
104
|
-
|
|
105
|
-
#### ♻️ Refactoring
|
|
106
|
-
|
|
107
|
-
- update all tests (packages A-S) ([e3085e4](https://github.com/thi-ng/umbrella/commit/e3085e4))
|