“The convoluted converter”
How to use it
convr.js is a CLI tool that converts different number formats from one base to another. Here is how you can use it:
$ node convr.js -hex 32335 > 0x7e4f $ node convr.js -bin 0x8c > 0b10001100 $ node convr.js -dec 0b1100 > 12
You need NodeJS 10.16.3 (or higher) to run it. If you have Docker (19.03.2 or higher), you can run
make, which will spawn a container that provides the environment in which you can execute the above commands.
Take the current implementation of this app and perform a non-functional refactoring. The goal is to improve code quality without changing behaviour or functionality.
- Add support for octal conversion, i.e. numbers prefixed with
04615. The corresponding target option would be
- Introduce aliasing for options: e.g.
-16for hexadecimal (and equivalent for the other converters)
- Make the program’s output more user-friendly: you could make it echo the input parameters for confirmation or you could syntax-highlight the output to make it easier to tell the prefix apart from the numerical value.
- Introduce aliasing for the prefixes that determine the number format, like the
2rprefix for binary numbers as it is common in Clojure (e.g.
- Experiment with alternative data structures, such as an
java.lang.Optional-equivalent (for initialising variables) or monads (instead of throwing exceptions).