A utility to help nameless mascots and designs get a proper name.
Currently, it is generating indices from a byte pattern. The number of unique possible names here is a 32bit number (Uint32
)
Ideally, you don't want names to overlap, so using random isn't the best of ideas, its better to try and encode the problem as some predictable thing.
Ideally, we want to add some random sequencing over this linear sequence. We don't want to be holding on keys for every possible 32bit number. One thing we want to do is use math functions (id % N, Math.floor(id / N))
to generate the string like so:
https://github.com/dexo568/gfycat-style-urls/blob/master/index.js
TS is pretty good at managing large JS codebases, its good at validating that a change in one part of the codebase hasn't broken some other part (due to the type system) and a lot of the tooling around it is really good (global name refactoring and such)
The dependencies are as typical for any typescript project.
Well, you obviously need the node package manager.
sudo apt-get install npm
Then fetch ts-node and typescript:
# Locally in your project.
npm install -D ts-node
npm install -D typescript
# Or globally with TypeScript.
npm install -g ts-node
npm install -g typescript
# Execute a script as `node` + `tsc`.
ts-node script.ts