Add optional callback to SerialPort.list

This commit is contained in:
Ondrej Slinták
2018-10-29 18:47:59 +01:00
parent 42b2226022
commit 7860e82467
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ declare class SerialPort extends Stream.Duplex {
static Binding: SerialPort.BaseBinding;
static list(): Promise<any>;
static list(callback?: SerialPort.ListCallback): Promise<any>;
}
declare namespace SerialPort {
+11
View File
@@ -126,3 +126,14 @@ function test_properties() {
const isOpen: boolean = port.isOpen;
const path: string = port.path;
}
function test_list_ports_promise() {
const ports = SerialPort
.list()
.then((ports: any) => {})
.catch((err: Error) => {});
}
function test_list_ports_callback() {
const ports = SerialPort.list((error: Error, port: any[]) => {});
}