You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Hmm. Well, it won't like having lots of recursion... setTimeout is a great way to avoid it though. The code looks way more complicated than is really needed to do what's required - really, what you're trying to do should work fine in Espruino - it just seems that the async library does some crazy stuff.

    For instance unless I'm misunderstanding, what you're doing could actually be handled using:

    function series(arr,done) {
      var i=0;
      function next(err) {
        if (((err!==undefined) && (err!==null)) || i>=arr.length)
          done(err);
        else
          arr[i++](next);
      }
      next();
    }
    

    (although obviously that would quickly exhaust the stack - although it could be changed to use setTimeout pretty easily)

    The actual bugs with Espruino seem to be:

    • function(){} returns false when cast to a boolean (it should return true)
    • no Array.concat
    • You can't reference built-in functions (this is a big one that I'm planning to fix - but it requires a lot of work)

    I'll see if I can fix the first 2 for 1v59 - the other one's going to need a bit more work :)

    By the way, for (... in ...) works correctly AFAIK. This is the result from jsconsole:

    for (var i in ["a","b","c"]) console.log(i)link
    "0"
    "1"
    "2"
    

    Which is what Espruino does.

About

Avatar for Gordon @Gordon started