DanHulton@programming.devtoProgramming@programming.dev•[Help] JS array with getter by ID ?English
1·
1 year agoIf you’re not married to functional code, for searching a keyed object by property for the key, you can always write:
for (const key in data) {
if (data[key].firstName === 'Frederic') {
console.log(key);
}
}
No need to transform the whole object with Object.entries, and you could turn that into a function reasonably easy, something like findKey(object, property, value)
or some such.
Not a big, fancy project, but over the past couple days, I put together a configuration file for Karibiner Elements (Mac software that lets you rebind your keys at the OS level) to allow you to type with just your left hand, using spacebar, caps lock, and the touchpad as modifier keys: https://github.com/DanHulton/Karibiner-Carpal-Tunnel-Right
I’ve been experiencing some carpal tunnel in my right hand, and wanted to avoid using it. That’s hard when you have to type all day, but with this config file, I can! (albeit much, much slower.) Since Karibiner config files are just json, editing them directly can get heinous, so I wrote a small Typescript program to take a simple mapping and turn it into a config file in the correct format.
(Why no right-hand config? There’s already an alternative keyboard layout that just mirrors the keyboard, and right right side has more keys – so you can use that mirror config just fine if you want to avoid using your left hand, but trying to avoid using your right hand means you need more modifiers to get even just the basic keys correct.)