Compare commits

...

2 commits

Author SHA1 Message Date
Melissa LeBlanc-Williams
5e768c19d0 Stop modifying the event data in onSerialReceive 2023-06-10 14:39:36 -07:00
Melissa LeBlanc-Williams
3b0652ccce Update Package Version and display error instead of log 2023-06-10 11:55:15 -07:00
3 changed files with 9 additions and 7 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "@adafruit/circuitpython-repl-js",
"version": "1.0.0",
"version": "1.2.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@adafruit/circuitpython-repl-js",
"version": "1.0.0",
"version": "1.2.3",
"license": "MIT",
"devDependencies": {}
}

View file

@ -3,7 +3,7 @@
"publishConfig": {
"registry": "https://npm.pkg.github.com"
},
"version": "1.0.0",
"version": "1.2.3",
"description": "A JavaScript Module to help with interfacing to the REPL on CircuitPython Devices over serial",
"main": "repl.js",
"dependencies": {

10
repl.js
View file

@ -83,7 +83,7 @@ export class REPL {
}, this.promptTimeout
);
} catch (error) {
console.log("Awaiting prompt timed out.");
console.error("Awaiting prompt timed out.");
return false;
}
return true;
@ -102,15 +102,17 @@ export class REPL {
}
async onSerialReceive(e) {
// Prepend a partial token if it exists
// We don't want to modify e.data, so we make a copy of it
let data = e.data;
// Prepend a partial token if it exists
if (this._partialToken) {
e.data = this._partialToken + e.data;
data = this._partialToken + data;
this._partialToken = null;
}
// Tokenize the larger string and send to the parent
let tokens = this._tokenize(e.data);
let tokens = this._tokenize(data);
// Remove any partial tokens and store for the next serial data receive
if (tokens.length && this._hasPartialToken(tokens.slice(-1))) {