Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fetch, rewrite the codebase to TypeScript, use JSON files for static content, etc #22

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NightScript370
Copy link

  • Fetch has been around in the JavaScript standard ever since ES6 (and Chrome since Chrome 42). Although Node got it late, it is easily polyfill-able for those older devices.
    • Adapt API from Request to Fetch
    • Polyfill
  • Import statements have been around for even longer, being in Node since v8.5.0. Although it's been locked behind a flag until relatively recently, it's now replaced Node's legacy module implementation.
  • All of the module.exports could be avoided by using JS's very own format for data-files, called JSON. Although we lose the ability to comment, we end up moving the only file that had the comments (config.js) to the ReadME
  • For arrays/strings, includes means we get to avoid the math and make it instantly obvious what we're trying to do.
  • Do not duplicate Test category maps if it's just always an increase of 100. Instead, since it could just be compressed into a singular object, we switched away from the switch case into its own file, while still maintaining its fallback of "unknown".
  • ToRad is now side-loaded onto the Number Prototype, meaning we could avoid entering a bug where it would get enumerated in the wrong loops.
  • Use TypeScript, the tech that ensures type-safetyness and allows devs to see what would be returned in case anything does. Since Node cannot load TypeScript by default, though, we will pass it through Babel to encode and compress down to a singular .js file, which will either way transpile any code update that we did before.
    • Switch over all the code
    • Make the transpiler
  • Callbacks are really outdated; they make you wrap everything in a function, meaning if you're chaining libraries together, it gets obvious. Async/Await has been the way to go for a while, and the old way is still available (by using .then())

Finally, testing is key. It is quite difficult, though, since I am not in Israel and don't have Google Maps. I hope to get someone to help me out in those specific regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant