You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • 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")).forEa­ch(print)
    // count newlines
    new Uint8Array(s.readArrayBuffer("z")).reduc­e((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 :)

About

Avatar for Gordon @Gordon started