Splice is mutative and as used would result in the item being removed at the given index. Slice is non-mutative and as used does nothing (aside from wasting cycles to create a copy of the array starting at index 1), therefore the cache entry will exist twice in the entries set (since it is not removed, then later prepended to the set).
At this line, I expect you are intending to use
Array#splice
, notArray#slice
:https://github.com/erikras/lru-memoize/blob/86f655e17032e055187f4bb492e0c6937fa48318/src/lruCache.js#L13
Splice is mutative and as used would result in the item being removed at the given index. Slice is non-mutative and as used does nothing (aside from wasting cycles to create a copy of the array starting at index 1), therefore the cache entry will exist twice in the entries set (since it is not removed, then later prepended to the set).