The idea behind speedy is slightly different.
forEach is running with one callbackFn only.
Idea is to combine different functions with a default function.
Thats close to your changes to shiftOut.
in this example we combine a simple console.log with pin.set/reset
function fill(){
arr = [];
arr.push({callback:en.reset.bind(en)});
arr.push({callback:console.log.bind(console,"qwertz\n")});
arr.push({callback:en.set.bind(en)});
arr.push({callback:console.log.bind(console,"asdf\n")});
arr.push([1,3,5]);
arr.push("abc");
}
x = console.log.bind(console,"z:");
function speed(n){
fill();
if(!n) n = 100;
var t = getTime();
for(var i = 0; i < n; i++) E.speedy(x,arr);
console.log(getTime() -t);
}
I would not say, this is standard Javascript ;-), it could be helpful, but is it worth it ?
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.
The idea behind speedy is slightly different.
forEach is running with one callbackFn only.
Idea is to combine different functions with a default function.
Thats close to your changes to shiftOut.
in this example we combine a simple console.log with pin.set/reset
I would not say, this is standard Javascript ;-), it could be helpful, but is it worth it ?