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)

'unadvance': first(lig_unadvance, ligature_default.unadvance, info.unadvance, defaultInfo.unadvance, 0),

AHHHHHH

I like my bitmap borders like I like my ass: cached

I don't understand node.js/npm and don't know why this function is named LineBreaker in the source but once I installed it, it turned into $557adaaeb0c7885f$var$LineBreaker and now I can't import it because that name is horribly wrong

I think this maybe has something to do with module resolution? like require vs import. I'm using import, but it's expecting require

I think it's parcel, which is used by the build system for this npm module?

ugh.

import linebreak from 'linebreak'

linebreak.LineBreaker(text)

this works. why does this work? I have no idea

now I have a completely different problem: I'm getting error messages with paths like:
parse (dist/lib/linesplitting/Snippet.js:132:28)

except that filename and line number are based on the JS output of the typescript source, so it doesn't tell me where the error actually originates in my source

there has to be a way to fix this (I have sourcemaps and shit) but it's not turned on by default for some reasons

changed my launch.json (I'm in VS Code, for some fucking reason) to point the runtimeExecutable at ts-node instead of node

for some reason I still can't ctrl-click on paths in the traceback to open them from the results, but at least I have filenames

Sign in to participate in the conversation
Mauvestodon

Escape ship from centralized social media run by Mauve.