By the way, those regex bugs are now fixed (in cutting edge builds, of 2v07 when released)
I could see a new method, like require("Storage").do
Because of the way Espruino works with Storage, data in storage is actually memory-mapped. If you do a read or readArrayBuffer then you're actually accessing the data directly from flash.
As a result, you can actually do what you want right now using forEach/map/reduce/etc without any extra functions:
var s = require("Storage");
// for every element
new Uint8Array(s.readArrayBuffer("z")).forEach(print)
// count newlines
new Uint8Array(s.readArrayBuffer("z")).reduce((a,b)=>a+(b==10),0)
If you want to iterate over just part of the data, you can use the Uint8Array constructor to choose an offset and length :)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
By the way, those regex bugs are now fixed (in cutting edge builds, of 2v07 when released)
Because of the way Espruino works with Storage, data in storage is actually memory-mapped. If you do a read or readArrayBuffer then you're actually accessing the data directly from flash.
As a result, you can actually do what you want right now using
forEach/map/reduce/etc
without any extra functions:If you want to iterate over just part of the data, you can use the
Uint8Array
constructor to choose an offset and length :)