You've been asked to refactor the function deterministicPartitionKey
in dpk.js
to make it easier to read and understand without changing its functionality. For this task, you should:
- Write unit tests to cover the existing functionality and ensure that your refactor doesn't break it. We typically use
jest
, but if you have another library you prefer, feel free to use it. - Refactor the function to be as "clean" and "readable" as possible. There are many valid ways to define those words - use your own personal definitions, but be prepared to defend them. Note that we do like to use the latest JS language features when applicable.
- Write up a brief (~1 paragraph) explanation of why you made the choices you did and why specifically your version is more "readable" than the original.
You will be graded on the exhaustiveness and quality of your unit tests, the depth of your refactor, and the level of insight into your thought process provided by the written explanation.