Skip to content

Commit

Permalink
style: invert the array in the controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Linkontoask committed Feb 10, 2021
1 parent ad396ca commit 9508495
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ function removeExpired(route: CustomRouter[]) {
const life = 2 * 24 * 60 * 60 * 1000
const heap = 20
// Maximum capacity
const routeTp = uniqBy(clone(route), 'url').slice(-1 * (heap - 1))
// Reverse the array before deduplication
const routeTp = uniqBy(clone(route.reverse()), 'url')
.reverse()
.slice(-1 * (heap - 1))
each(routeTp, value => {
if (Date.now() - value.life > life) {
pull(routeTp, value)
Expand Down

0 comments on commit 9508495

Please sign in to comment.