This mainly to enforce that the underlying grid isn't modifiable, technically we return a new array anyway, so there is little point. #activeState
is also always replaced so we can freeze it when it's created, but this felt more flexible
Type hints are here since I can see them in my IDE and make things slightly easier to work with, hence why I've put them everywhere but with no actual docs
This is mostly personal preference, since an "industry standard" way would be key => action enum => (action transform) => action function. I find this a bit easier to read. If I'd bring in a library for the matching I'd have used cond
from lodash https://lodash.com/docs/4.17.15#cond
Switched .forEach
to for of
loop for performance (recommended practice, but honestly, it’s not a big deal - I'd even call it a nitpick)
A lot of these me
proxies aren't necessary with the arrow functions you're using, they're removed in the modified version
I ran Biome.js over this, and I'm a ;
hater (my default config), that's why they're not here
I'd normally use a @property for this but it wasn't working the initial value so I did this instead