mirror of https://github.com/espruino/BangleApps
tweaks to allow `appinfo` to work under node.js
parent
28059d51c4
commit
36009ed212
|
@ -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<txt.length;i++) ua[i] = txt.charCodeAt(i);
|
||||
var c = heatshrink.compress(ua);
|
||||
|
|
Loading…
Reference in New Issue