@thi.ng/axidraw 1.1.39 → 1.1.40
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 +9 -19
- package/axidraw.js +376 -367
- package/commands.js +52 -88
- package/control.js +26 -31
- package/dip.js +13 -48
- package/package.json +16 -13
- package/palettes.js +68 -132
- package/polyline.js +25 -35
- package/registration.js +24 -31
- package/serial.js +31 -37
package/serial.js
CHANGED
|
@@ -1,42 +1,36 @@
|
|
|
1
1
|
import { illegalState } from "@thi.ng/errors/illegal-state";
|
|
2
2
|
import { SerialPort } from "serialport";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const SERIAL_PORT = {
|
|
7
|
-
list: () => SerialPort.list(),
|
|
8
|
-
ctor: (path, baudRate) => new SerialPort({ path, baudRate }),
|
|
3
|
+
const SERIAL_PORT = {
|
|
4
|
+
list: () => SerialPort.list(),
|
|
5
|
+
ctor: (path, baudRate) => new SerialPort({ path, baudRate })
|
|
9
6
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
export const MOCK_SERIAL = {
|
|
15
|
-
list: async (path) => [{ path }],
|
|
16
|
-
ctor: () => new MockSerial(),
|
|
7
|
+
const MOCK_SERIAL = {
|
|
8
|
+
list: async (path) => [{ path }],
|
|
9
|
+
ctor: () => new MockSerial()
|
|
17
10
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
write(msg) {
|
|
39
|
-
this.isClosed && illegalState("connection already closed");
|
|
40
|
-
this.sent.push(msg);
|
|
41
|
-
}
|
|
11
|
+
class MockSerial {
|
|
12
|
+
sent = [];
|
|
13
|
+
isClosed = false;
|
|
14
|
+
/**
|
|
15
|
+
* Clears internal log of "sent" message.
|
|
16
|
+
*/
|
|
17
|
+
clear() {
|
|
18
|
+
this.sent = [];
|
|
19
|
+
}
|
|
20
|
+
close() {
|
|
21
|
+
this.isClosed = true;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Appends
|
|
25
|
+
* @param msg
|
|
26
|
+
*/
|
|
27
|
+
write(msg) {
|
|
28
|
+
this.isClosed && illegalState("connection already closed");
|
|
29
|
+
this.sent.push(msg);
|
|
30
|
+
}
|
|
42
31
|
}
|
|
32
|
+
export {
|
|
33
|
+
MOCK_SERIAL,
|
|
34
|
+
MockSerial,
|
|
35
|
+
SERIAL_PORT
|
|
36
|
+
};
|