me: when I'm bored and trying to find something to do, often I find myself thinking "I should refactor and rewrite my javascript codebase"

doctor: I don't think that means you have a brain tumor, but we can do a check anyway

var? let? consts?

why not combine them, to vaconst!

I also made a fun typo, where I set the description to "Death Generator is a tool to make fake videogame screenshits"

number of times (so far) I've misspelled "number" while working on this refactor:
2 (nunmber and nubmer)

I'm pretty sure the idiot who designed this codebase was specifically trying to make sure it couldn't be easily typescriptified

it's based around a giant object which has no schema, since it's just a raw JSON object, and it handles the existence or non-existence of various parts at runtime.

it also makes heavy use of a "first" function, which works by returning the first argument that isn't undefined

so instead of something like:
const fontScale = 'scale' in fontInfo ? fontInfo['scale'] : 2

it does:

const fontScale = first(fontInfo['scale'], 2)

Follow

@foone would the `??` operator help here?

const foo = bar.baz ?? whateverDefaultVal

it's like a condensed check for `undefined`

Sign in to participate in the conversation
Mauvestodon

Escape ship from centralized social media run by Mauve.