Skip to content

Commit 8ea554a

Browse files
committed
Update CR previous suggestion
1 parent 13dc315 commit 8ea554a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/js/serial.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ class Serial extends EventTarget {
6868

6969
/**
7070
* Selects the appropriate protocol based on port path
71-
* @param {string|null} portPath - Port path to determine protocol
71+
* @param {string|function|null} portPath - Port path or callback function for virtual mode
7272
*/
7373
selectProtocol(portPath) {
7474
// Determine which protocol to use based on port path
75+
const isFn = typeof portPath === "function";
7576
const s = typeof portPath === "string" ? portPath : "";
7677
// Default to webserial for typical serial device identifiers.
77-
if (s === "virtual") {
78+
if (isFn || s === "virtual") {
7879
return this._protocols.find((p) => p.name === "virtual")?.instance;
7980
}
8081
if (s === "manual" || /^(tcp|ws|wss):\/\/[A-Za-z0-9.-]+(?::\d+)?(\/.*)?$/.test(s)) {

0 commit comments

Comments
 (0)