Added settings keys sorting - #533
Conversation
seanprashad
left a comment
There was a problem hiding this comment.
Hi @cub-uanic! To sync progress across multiple hosts, you can sign in with your GitHub account:
Does this fit your use case? This was meant to replace the export/import functionality
|
Hi @seanprashad, |
seanprashad
left a comment
There was a problem hiding this comment.
Change makes sense - just one small adjustment to ensure exports won't be malformed
Co-authored-by: Sean Prashad <13009507+seanprashad@users.noreply.github.com> Signed-off-by: Oleh Kostiuk <cub.uanic@gmail.com>
|
Seems we're lost the key point - sorting the entire payload, not just some of its keys: const payload = {
completed: [...completed].sort((a, b) => a - b),
starred: [...starred].sort((a, b) => a - b),
notes, solvedDates, reminders
}.sort();I'm about the last line (untested) |
Sort completed/starred numerically at export time and end the file with a trailing newline, so exports are byte-stable across hosts for users who keep them in version control (#533). Add tests that assert the export round-trips through import, is sorted regardless of completion order, and ends with a newline — the round-trip test also guards against malformed (non-JSON) export payloads. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Make progress export deterministic and cover it with tests Sort completed/starred numerically at export time and end the file with a trailing newline, so exports are byte-stable across hosts for users who keep them in version control (#533). Add tests that assert the export round-trips through import, is sorted regardless of completion order, and ends with a newline — the round-trip test also guards against malformed (non-JSON) export payloads. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Did you see #533 (comment)? There's also instructions to run the website locally: https://github.com/seanprashad/leetcode-patterns#contributing |
|
Was in rush and missed it 🫡 |
I'm using Git to store my progress in dotfiles and share them between several hosts.
Sometimes, on different hosts, I'm getting the keys in json in a different order.
This makes it difficult to understand exactly what was changed (while in reality, it could be just one line), and also makes diffs larger.
As a solution, I suggest always sort the keys of the settings object.
(the idea is the same as I proposed in philc/vimium#4764)