From 36009ed212b0379254480cb563fef7daa895de62 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 14 May 2020 11:42:10 +0100 Subject: [PATCH] tweaks to allow `appinfo` to work under node.js --- js/appinfo.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/appinfo.js b/js/appinfo.js index b4d0b5426..ad2611d19 100644 --- a/js/appinfo.js +++ b/js/appinfo.js @@ -1,10 +1,13 @@ +if (typeof btoa==="undefined") + function btoa(d) { return Buffer.from(d).toString('base64'); } + // Converts a string into most efficient way to send to Espruino (either json, base64, or compressed base64) function toJS(txt) { var json = JSON.stringify(txt); var b64 = "atob("+JSON.stringify(btoa(json))+")"; var js = b64.length < json.length ? b64 : json; - if (heatshrink) { + if (typeof heatshrink !== "undefined") { var ua = new Uint8Array(txt.length); for (var i=0;i