@thi.ng/csp 3.2.0 → 3.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-04-28T14:28:17Z
3
+ - **Last updated**: 2024-05-08T18:24:31Z
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.
package/README.md CHANGED
@@ -157,7 +157,7 @@ For Node.js REPL:
157
157
  const csp = await import("@thi.ng/csp");
158
158
  ```
159
159
 
160
- Package sizes (brotli'd, pre-treeshake): ESM: 1.79 KB
160
+ Package sizes (brotli'd, pre-treeshake): ESM: 1.81 KB
161
161
 
162
162
  ## Dependencies
163
163
 
package/channel.js CHANGED
@@ -23,10 +23,8 @@ class Channel {
23
23
  let opts;
24
24
  switch (args.length) {
25
25
  case 1:
26
- if (isPlainObject(args[0]))
27
- opts = args[0];
28
- else
29
- buf = args[0];
26
+ if (isPlainObject(args[0])) opts = args[0];
27
+ else buf = args[0];
30
28
  break;
31
29
  case 2:
32
30
  [buf, opts] = args;
@@ -68,8 +66,7 @@ class Channel {
68
66
  async *[Symbol.asyncIterator]() {
69
67
  while (this.state < STATE_CLOSED) {
70
68
  const x = await this.read();
71
- if (x !== void 0)
72
- yield x;
69
+ if (x !== void 0) yield x;
73
70
  }
74
71
  }
75
72
  /**
@@ -100,8 +97,7 @@ class Channel {
100
97
  resolve(void 0);
101
98
  }
102
99
  }
103
- if (this.writes.readable())
104
- this.deliver();
100
+ if (this.writes.readable()) this.deliver();
105
101
  });
106
102
  }
107
103
  /**
@@ -208,19 +204,15 @@ class Channel {
208
204
  * still "closing", not yet fully "closed".
209
205
  */
210
206
  close() {
211
- if (this.state >= STATE_CLOSING)
212
- return;
207
+ if (this.state >= STATE_CLOSING) return;
213
208
  const { reads, writes, races } = this;
214
209
  this.state = reads.length || writes.readable() ? STATE_CLOSING : STATE_CLOSED;
215
- while (reads.length && writes.readable())
216
- this.deliver();
210
+ while (reads.length && writes.readable()) this.deliver();
217
211
  if (!writes.readable()) {
218
- while (reads.length)
219
- reads.shift()(void 0);
212
+ while (reads.length) reads.shift()(void 0);
220
213
  }
221
214
  this.state = writes.readable() ? STATE_CLOSING : STATE_CLOSED;
222
- while (races.length)
223
- races.shift()(this);
215
+ while (races.length) races.shift()(this);
224
216
  }
225
217
  /**
226
218
  * Returns true if the channel is principally readable (i.e. not yet
package/mult.js CHANGED
@@ -83,8 +83,7 @@ class Mult {
83
83
  */
84
84
  unsubscribeAll(close = true) {
85
85
  if (close) {
86
- for (let t of this.taps)
87
- t.close();
86
+ for (let t of this.taps) t.close();
88
87
  }
89
88
  this.taps.length = 0;
90
89
  }
package/ops.js CHANGED
@@ -2,12 +2,10 @@ import { assert } from "@thi.ng/errors/assert";
2
2
  import { Channel } from "./channel.js";
3
3
  const broadcast = async (src, dest, close = true) => {
4
4
  for await (let x of src) {
5
- for (let chan of dest)
6
- chan.write(x);
5
+ for (let chan of dest) chan.write(x);
7
6
  }
8
7
  if (close) {
9
- for (let chan of dest)
10
- chan.close();
8
+ for (let chan of dest) chan.close();
11
9
  }
12
10
  };
13
11
  const concat = async (dest, chans, close = true) => {
@@ -21,8 +19,7 @@ const concat = async (dest, chans, close = true) => {
21
19
  const consume = async (chan, res = [], num = Infinity) => {
22
20
  for (let n = 0; !chan.closed() && n < num; n++) {
23
21
  const x = await chan.read();
24
- if (x == void 0)
25
- break;
22
+ if (x == void 0) break;
26
23
  res.push(x);
27
24
  }
28
25
  return res;
@@ -30,8 +27,7 @@ const consume = async (chan, res = [], num = Infinity) => {
30
27
  const consumeWith = async (chan, fn, num = Infinity) => {
31
28
  for (let n = 0; !chan.closed() && n < num; n++) {
32
29
  const x = await chan.read();
33
- if (x == void 0)
34
- break;
30
+ if (x == void 0) break;
35
31
  fn(x, chan);
36
32
  }
37
33
  };
@@ -47,8 +43,7 @@ const fromAsyncIterable = (src, close = true) => {
47
43
  (async () => {
48
44
  for await (let x of src) {
49
45
  await chan.write(x);
50
- if (!chan.writable())
51
- break;
46
+ if (!chan.writable()) break;
52
47
  }
53
48
  close && chan.close();
54
49
  })();
@@ -75,8 +70,7 @@ const merge = (src, dest, close = true) => {
75
70
  };
76
71
  const into = async (chan, src, close = false) => {
77
72
  for await (let x of src) {
78
- if (!chan.writable())
79
- break;
73
+ if (!chan.writable()) break;
80
74
  await chan.write(x);
81
75
  }
82
76
  close && chan.close();
@@ -85,8 +79,7 @@ const pipe = (src, dest, close = true) => {
85
79
  (async () => {
86
80
  for await (let x of src) {
87
81
  await dest.write(x);
88
- if (!dest.writable())
89
- break;
82
+ if (!dest.writable()) break;
90
83
  }
91
84
  close && dest.close();
92
85
  })();
@@ -96,8 +89,7 @@ const select = async (input, ...xs) => {
96
89
  const inputs = [input, ...xs];
97
90
  const sel = await Promise.race(inputs.map((x) => x.race()));
98
91
  for (let chan of inputs) {
99
- if (chan !== sel)
100
- chan.races.shift();
92
+ if (chan !== sel) chan.races.shift();
101
93
  }
102
94
  if (sel.writes.readable()) {
103
95
  const [msg, write] = sel.writes.read();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/csp",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
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",
@@ -40,16 +40,16 @@
40
40
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@thi.ng/api": "^8.11.1",
44
- "@thi.ng/buffers": "^0.1.2",
45
- "@thi.ng/checks": "^3.6.3",
46
- "@thi.ng/errors": "^2.5.6"
43
+ "@thi.ng/api": "^8.11.2",
44
+ "@thi.ng/buffers": "^0.1.3",
45
+ "@thi.ng/checks": "^3.6.4",
46
+ "@thi.ng/errors": "^2.5.7"
47
47
  },
48
48
  "devDependencies": {
49
- "@microsoft/api-extractor": "^7.43.0",
50
- "esbuild": "^0.20.2",
51
- "typedoc": "^0.25.12",
52
- "typescript": "^5.4.3"
49
+ "@microsoft/api-extractor": "^7.43.2",
50
+ "esbuild": "^0.21.1",
51
+ "typedoc": "^0.25.13",
52
+ "typescript": "^5.4.5"
53
53
  },
54
54
  "keywords": [
55
55
  "async",
@@ -106,5 +106,5 @@
106
106
  "status": "beta",
107
107
  "year": 2016
108
108
  },
109
- "gitHead": "85861eb5760fd5c145dbd2d032b6f03400d6653e\n"
109
+ "gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
110
110
  }