@thi.ng/csp 2.1.30 → 2.1.32
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 +1 -1
- package/README.md +9 -12
- package/api.d.ts +2 -2
- package/channel.js +56 -56
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
|
|
3
|
-
# 
|
|
3
|
+
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/csp)
|
|
6
6
|

|
|
7
|
-
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
This project is part of the
|
|
10
10
|
[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
|
|
@@ -23,7 +23,7 @@ This project is part of the
|
|
|
23
23
|
|
|
24
24
|
## About
|
|
25
25
|
|
|
26
|
-
ES6 promise based CSP primitives & operations
|
|
26
|
+
ES6 promise based CSP primitives & operations
|
|
27
27
|
|
|
28
28
|
- `Channel` with/without buffering and/or
|
|
29
29
|
[transducers](https://github.com/thi-ng/umbrella/blob/develop/packages/transducers)
|
|
@@ -43,7 +43,7 @@ ES6 promise based CSP primitives & operations.
|
|
|
43
43
|
|
|
44
44
|
## Status
|
|
45
45
|
|
|
46
|
-
**DEPRECATED** -
|
|
46
|
+
**DEPRECATED** - superseded by other package(s)
|
|
47
47
|
|
|
48
48
|
[Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Bcsp%5D+in%3Atitle)
|
|
49
49
|
|
|
@@ -71,14 +71,11 @@ ES module import:
|
|
|
71
71
|
|
|
72
72
|
For Node.js REPL:
|
|
73
73
|
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
node --experimental-repl-await
|
|
77
|
-
|
|
78
|
-
> const csp = await import("@thi.ng/csp");
|
|
74
|
+
```js
|
|
75
|
+
const csp = await import("@thi.ng/csp");
|
|
79
76
|
```
|
|
80
77
|
|
|
81
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 2.
|
|
78
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 2.42 KB
|
|
82
79
|
|
|
83
80
|
## Dependencies
|
|
84
81
|
|
|
@@ -253,7 +250,7 @@ pub.channel().into(["alice", "bert", "bella", "charlie", "arthur"]);
|
|
|
253
250
|
|
|
254
251
|
## Authors
|
|
255
252
|
|
|
256
|
-
Karsten Schmidt
|
|
253
|
+
- [Karsten Schmidt](https://thi.ng)
|
|
257
254
|
|
|
258
255
|
If this project contributes to an academic publication, please cite it as:
|
|
259
256
|
|
|
@@ -268,4 +265,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
268
265
|
|
|
269
266
|
## License
|
|
270
267
|
|
|
271
|
-
© 2016 - 2022 Karsten Schmidt // Apache
|
|
268
|
+
© 2016 - 2022 Karsten Schmidt // Apache License 2.0
|
package/api.d.ts
CHANGED
|
@@ -22,6 +22,6 @@ export interface IWriteableChannel<T> extends IChannel<T> {
|
|
|
22
22
|
}
|
|
23
23
|
export interface IReadWriteableChannel<T> extends IReadableChannel<T>, IWriteableChannel<T> {
|
|
24
24
|
}
|
|
25
|
-
export
|
|
26
|
-
export
|
|
25
|
+
export type TopicFn<T> = Fn<T, string>;
|
|
26
|
+
export type ErrorHandler = (e: Error, chan: Channel<any>, val?: any) => void;
|
|
27
27
|
//# sourceMappingURL=api.d.ts.map
|
package/channel.js
CHANGED
|
@@ -8,62 +8,6 @@ import { range } from "@thi.ng/transducers/range";
|
|
|
8
8
|
import { isReduced, unreduced } from "@thi.ng/transducers/reduced";
|
|
9
9
|
import { FixedBuffer } from "./buffer.js";
|
|
10
10
|
export class Channel {
|
|
11
|
-
constructor(...args) {
|
|
12
|
-
let id, buf, tx, err;
|
|
13
|
-
let [a, b] = args;
|
|
14
|
-
switch (args.length) {
|
|
15
|
-
case 0:
|
|
16
|
-
break;
|
|
17
|
-
case 1:
|
|
18
|
-
if (typeof a === "string") {
|
|
19
|
-
id = a;
|
|
20
|
-
}
|
|
21
|
-
else if (maybeBuffer(a)) {
|
|
22
|
-
buf = a;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
tx = a;
|
|
26
|
-
}
|
|
27
|
-
break;
|
|
28
|
-
case 2:
|
|
29
|
-
if (typeof a === "string") {
|
|
30
|
-
id = a;
|
|
31
|
-
if (maybeBuffer(b)) {
|
|
32
|
-
buf = b;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
tx = b;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
[tx, err] = args;
|
|
40
|
-
}
|
|
41
|
-
break;
|
|
42
|
-
case 3:
|
|
43
|
-
if (isFunction(args[1]) && isFunction(args[2])) {
|
|
44
|
-
[id, tx, err] = args;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
[id, buf, tx] = args;
|
|
48
|
-
}
|
|
49
|
-
break;
|
|
50
|
-
case 4:
|
|
51
|
-
[id, buf, tx, err] = args;
|
|
52
|
-
break;
|
|
53
|
-
default:
|
|
54
|
-
illegalArity(args.length);
|
|
55
|
-
}
|
|
56
|
-
this.id = id || `chan-${Channel.NEXT_ID++}`;
|
|
57
|
-
buf = buf || 1;
|
|
58
|
-
this.buf = typeof buf === "number" ? new FixedBuffer(buf) : buf;
|
|
59
|
-
this.writes = new DCons();
|
|
60
|
-
this.reads = new DCons();
|
|
61
|
-
this.txbuf = new DCons();
|
|
62
|
-
this.tx = tx ? tx(Channel.RFN) : null;
|
|
63
|
-
this.onerror = tx && (err || defaultErrorHandler);
|
|
64
|
-
this.state = 0 /* State.OPEN */;
|
|
65
|
-
this.isBusy = false;
|
|
66
|
-
}
|
|
67
11
|
static constantly(x, delay) {
|
|
68
12
|
const chan = new Channel(delay ? delayed(delay) : null);
|
|
69
13
|
chan.produce(() => x);
|
|
@@ -263,6 +207,62 @@ export class Channel {
|
|
|
263
207
|
})();
|
|
264
208
|
return out;
|
|
265
209
|
}
|
|
210
|
+
constructor(...args) {
|
|
211
|
+
let id, buf, tx, err;
|
|
212
|
+
let [a, b] = args;
|
|
213
|
+
switch (args.length) {
|
|
214
|
+
case 0:
|
|
215
|
+
break;
|
|
216
|
+
case 1:
|
|
217
|
+
if (typeof a === "string") {
|
|
218
|
+
id = a;
|
|
219
|
+
}
|
|
220
|
+
else if (maybeBuffer(a)) {
|
|
221
|
+
buf = a;
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
tx = a;
|
|
225
|
+
}
|
|
226
|
+
break;
|
|
227
|
+
case 2:
|
|
228
|
+
if (typeof a === "string") {
|
|
229
|
+
id = a;
|
|
230
|
+
if (maybeBuffer(b)) {
|
|
231
|
+
buf = b;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
tx = b;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
[tx, err] = args;
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
case 3:
|
|
242
|
+
if (isFunction(args[1]) && isFunction(args[2])) {
|
|
243
|
+
[id, tx, err] = args;
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
[id, buf, tx] = args;
|
|
247
|
+
}
|
|
248
|
+
break;
|
|
249
|
+
case 4:
|
|
250
|
+
[id, buf, tx, err] = args;
|
|
251
|
+
break;
|
|
252
|
+
default:
|
|
253
|
+
illegalArity(args.length);
|
|
254
|
+
}
|
|
255
|
+
this.id = id || `chan-${Channel.NEXT_ID++}`;
|
|
256
|
+
buf = buf || 1;
|
|
257
|
+
this.buf = typeof buf === "number" ? new FixedBuffer(buf) : buf;
|
|
258
|
+
this.writes = new DCons();
|
|
259
|
+
this.reads = new DCons();
|
|
260
|
+
this.txbuf = new DCons();
|
|
261
|
+
this.tx = tx ? tx(Channel.RFN) : null;
|
|
262
|
+
this.onerror = tx && (err || defaultErrorHandler);
|
|
263
|
+
this.state = 0 /* State.OPEN */;
|
|
264
|
+
this.isBusy = false;
|
|
265
|
+
}
|
|
266
266
|
channel() {
|
|
267
267
|
return this;
|
|
268
268
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/csp",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.32",
|
|
4
4
|
"description": "ES6 promise based CSP primitives & operations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://patreon.com/thing_umbrella"
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
"author": "Karsten Schmidt
|
|
24
|
+
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "yarn clean && tsc --declaration",
|
|
@@ -38,20 +38,20 @@
|
|
|
38
38
|
"testnode": "tsc -p test && node build/test/node.js"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@thi.ng/api": "^8.
|
|
42
|
-
"@thi.ng/arrays": "^2.4.
|
|
43
|
-
"@thi.ng/checks": "^3.3.
|
|
44
|
-
"@thi.ng/dcons": "^3.2.
|
|
45
|
-
"@thi.ng/errors": "^2.2.
|
|
46
|
-
"@thi.ng/transducers": "^8.3.
|
|
41
|
+
"@thi.ng/api": "^8.6.1",
|
|
42
|
+
"@thi.ng/arrays": "^2.4.6",
|
|
43
|
+
"@thi.ng/checks": "^3.3.5",
|
|
44
|
+
"@thi.ng/dcons": "^3.2.27",
|
|
45
|
+
"@thi.ng/errors": "^2.2.6",
|
|
46
|
+
"@thi.ng/transducers": "^8.3.27"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@microsoft/api-extractor": "^7.33.
|
|
50
|
-
"@thi.ng/testament": "^0.3.
|
|
49
|
+
"@microsoft/api-extractor": "^7.33.7",
|
|
50
|
+
"@thi.ng/testament": "^0.3.7",
|
|
51
51
|
"rimraf": "^3.0.2",
|
|
52
52
|
"tools": "^0.0.1",
|
|
53
|
-
"typedoc": "^0.23.
|
|
54
|
-
"typescript": "^4.
|
|
53
|
+
"typedoc": "^0.23.22",
|
|
54
|
+
"typescript": "^4.9.4"
|
|
55
55
|
},
|
|
56
56
|
"keywords": [
|
|
57
57
|
"async",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"status": "deprecated",
|
|
103
103
|
"year": 2016
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n"
|
|
106
106
|
}
|