You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • @Gordon, nice play with the +1 on the -1 when not found for ending the loop.

    Since there is obviously a need for operating on potentially 'large' strings in storage, I could see a new method, like require("Storage").do(fn,fnct,optStartPo­s,optEndPosOrLength), where function can be JS function - plain or compiled - or inline C function. The function accepts byte and - when second argument provided -the byte's position. Function is called one more time with undefined when on 'end of file' with byte position equal to file/string length. The function is also called just once when out of bound with undefined and -1 as byte position. The function returning something else than undefined breaks 'the loop' and .do() returns that value.

    .do() is kind of modeled after forEach / map / reduce / filter. For something similar to reduced, the 'accumulator' is though still missing in the function's argument list as is the decision whether .do() 's optEndPos or optLength should be used. .do(...)needs some more thoughts... ;-)

About

Avatar for allObjects @allObjects started