@thi.ng/csp 2.1.81 → 2.1.82
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 +1 -1
- package/api.js +0 -1
- package/buffer.js +59 -54
- package/channel.js +485 -485
- package/mult.js +95 -95
- package/package.json +12 -9
- package/pubsub.js +84 -81
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/api.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/buffer.js
CHANGED
|
@@ -1,62 +1,67 @@
|
|
|
1
1
|
import { DCons } from "@thi.ng/dcons/dcons";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
class FixedBuffer {
|
|
3
|
+
buf;
|
|
4
|
+
limit;
|
|
5
|
+
constructor(limit = 1) {
|
|
6
|
+
this.buf = new DCons();
|
|
7
|
+
this.limit = limit;
|
|
8
|
+
}
|
|
9
|
+
get length() {
|
|
10
|
+
return this.buf.length;
|
|
11
|
+
}
|
|
12
|
+
isEmpty() {
|
|
13
|
+
return this.buf.length === 0;
|
|
14
|
+
}
|
|
15
|
+
isFull() {
|
|
16
|
+
return this.buf.length >= this.limit;
|
|
17
|
+
}
|
|
18
|
+
release() {
|
|
19
|
+
return this.buf.release();
|
|
20
|
+
}
|
|
21
|
+
push(x) {
|
|
22
|
+
if (!this.isFull()) {
|
|
23
|
+
this.buf.push(x);
|
|
24
|
+
return true;
|
|
8
25
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
isEmpty() {
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
isFull() {
|
|
16
|
-
return this.buf.length >= this.limit;
|
|
17
|
-
}
|
|
18
|
-
release() {
|
|
19
|
-
return this.buf.release();
|
|
20
|
-
}
|
|
21
|
-
push(x) {
|
|
22
|
-
if (!this.isFull()) {
|
|
23
|
-
this.buf.push(x);
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
drop() {
|
|
29
|
-
if (!this.isEmpty()) {
|
|
30
|
-
return this.buf.drop();
|
|
31
|
-
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
drop() {
|
|
29
|
+
if (!this.isEmpty()) {
|
|
30
|
+
return this.buf.drop();
|
|
32
31
|
}
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
34
|
+
class DroppingBuffer extends FixedBuffer {
|
|
35
|
+
constructor(limit = 1) {
|
|
36
|
+
super(limit);
|
|
37
|
+
}
|
|
38
|
+
isFull() {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
push(x) {
|
|
42
|
+
if (this.buf.length < this.limit) {
|
|
43
|
+
this.buf.push(x);
|
|
46
44
|
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
this.buf.push(x);
|
|
60
|
-
return true;
|
|
48
|
+
class SlidingBuffer extends FixedBuffer {
|
|
49
|
+
constructor(limit = 1) {
|
|
50
|
+
super(limit);
|
|
51
|
+
}
|
|
52
|
+
isFull() {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
push(x) {
|
|
56
|
+
if (this.buf.length >= this.limit) {
|
|
57
|
+
this.buf.drop();
|
|
61
58
|
}
|
|
59
|
+
this.buf.push(x);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
62
|
}
|
|
63
|
+
export {
|
|
64
|
+
DroppingBuffer,
|
|
65
|
+
FixedBuffer,
|
|
66
|
+
SlidingBuffer
|
|
67
|
+
};
|