Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
these are small change in preparation of my feature adding, all explained here with there rational. - FilterItems.ts refactor of `getFiltered` and `getFilteredOut` so they share the same logic code for filtering. this prevent error code duplication and error going with it. also added some doc comment to better distinguish both function. I also maked these two function a bit purer by moving the searchTerm to an optional parameter instead of passing by a shared object. this is a better coding practice and permit to get filtered with a different search term without changing the options small refactor of `shuffle`. there was no reason to call `getFiltered` twice, since `getFiltered` return a new array each time same for the call of `slice()`, since a map alway return a new array. the do-while was followed by a call to "shuffle" in an empty block, so you checked if the new shuffle is different from the last, but shuffled one last time after that. I removed it. the `shouldBeFiltered` function have a misleading name, depending what a "filtered" element mean for you (it is the element that are kept, or the element that are removed?). I refactored it to use typescript "guard" feature, removing the need of using explicit casting (that is error prone). I also checked for "all" direcly in it, so we cannot forget to check for it before calling the function. - utils/shuffle.ts I added typescript generic to keep the type information of the return type the same as the one of the parameter. I also corrected a small comment error. array.slice() do a shallow clone, not a deep clone, and this is what we want. - Filterizr.ts and Filterizr.test.ts updated with the change of parameter of getFiltered - tsconfig.json added "lib" : ["es2016", "esnext", "dom"] to compiler option. this removed some error found by my VisualStudio code intellisence of element not found. by default, lib is only es2015+dom, and the library use some 2016 and next feature.
- Loading branch information
d378a96
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job on this one, I left some line notes for now, there's a couple more things. Code review will be finished a bit more slowly because I'm on holidays atm unfortunately.