wokwi / rp2040js

A Raspberry Pi Pico Emulator in JavaScript
MIT License
407 stars 46 forks source link

feat(sio):implemented Spinlocks #40

Closed Turro75 closed 3 years ago

Turro75 commented 3 years ago

I choose to avoid 32 spinlocks cases by inserting if statements in both read/writeUint32

urish commented 3 years ago

And a quick note about ranges for switch in JavaScript: it is possible, but in a weird way. For example:

switch (true) {
   case i === 0: return "zero";
   case i > 0 && i < 10: return "single digit";
   case i < 100: return "two digits";
   default: return "big number!";
}

But I don't think it's a good practice. Using an if statement is probably a better solution, especially in our case.

p.s. there's also a proposal for new JavaScript syntax that will probably able to deal with ranges. But it's just an early stage proposal right now...

urish commented 3 years ago

Thanks!