@thi.ng/csp 3.2.44 → 3.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**: 2025-09-01T16:38:35Z
3
+ - **Last updated**: 2025-10-07T11:51:57Z
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,14 @@ 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
+ ## [3.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/csp@3.3.0) (2025-10-07)
15
+
16
+ #### 🚀 Features
17
+
18
+ - update `select()`, shuffle inputs, update deps ([bbfad51](https://github.com/thi-ng/umbrella/commit/bbfad51))
19
+ - add [@thi.ng/arrays](https://github.com/thi-ng/umbrella/tree/main/packages/arrays) dependency
20
+ - update docs
21
+
14
22
  ### [3.2.13](https://github.com/thi-ng/umbrella/tree/@thi.ng/csp@3.2.13) (2024-10-17)
15
23
 
16
24
  #### ♻️ Refactoring
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/csp",
3
- "version": "3.2.44",
3
+ "version": "3.3.0",
4
4
  "description": "Primitives & operators for Communicating Sequential Processes based on async/await and async iterables",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -44,6 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@thi.ng/api": "^8.12.2",
47
+ "@thi.ng/arrays": "^2.13.11",
47
48
  "@thi.ng/buffers": "^1.0.21",
48
49
  "@thi.ng/checks": "^3.7.18",
49
50
  "@thi.ng/errors": "^2.5.42"
@@ -108,5 +109,5 @@
108
109
  "status": "beta",
109
110
  "year": 2016
110
111
  },
111
- "gitHead": "e215a3e8de3809736ba0042c93bd8703a5a1a337\n"
112
+ "gitHead": "fbf4b46ba8a5ecff8c5423f4c2d158d208d20fc8\n"
112
113
  }