Yomguithereal / mnemonist

Curated collection of data structures for the JavaScript/TypeScript language.
https://yomguithereal.github.io/mnemonist
MIT License
2.24k stars 92 forks source link

Use modern JavaScript syntax for code examples #215

Closed atombrenner closed 6 months ago

atombrenner commented 6 months ago

The goal of this PR is to use common modern JavaScript syntax in the code examples of the documentation. This will increase the readability of the examples by being more familiar syntax. I should also help spread best practices with modern, as people tend to copy paste examples.

There are only two types of changes:

  1. Using const instead of var I found no examples that need a let. Sometimes a code example declared the same variable multiple times, usually to explain overloads. In this case I splitted the example.
  2. Using arrow functions instead of anonymous functions This mainly improves readability by reducing some noise. Formatting is by Prettier conventions.

While doing those changes I stumbled over two potential bugs, please review the commits

Yomguithereal commented 6 months ago

Thanks @atombrenner, I will review your PR shortly. Regarding the search-index I think you can safely drop the file since the structure was indeed renamed to InvertedIndex. The inverted-index also has a typo where I wrote Index instead of InvertedIndex.

Yomguithereal commented 6 months ago

Thanks @atombrenner. Will merge now.