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"
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.
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:
(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)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:Which is what Espruino does.