Skip to content

Commit

Permalink
Fix IE11 'findIndex' error (#89)
Browse files Browse the repository at this point in the history
* Use custom 'findIndex' function rather than instance method

* install npm@5

* I prefer to up the version, thanks. :-)
  • Loading branch information
franjohn21 authored and erikras committed Feb 12, 2019
1 parent a9b4b3d commit 8ef91af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js

before_install:
- npm install -g npm@latest
- npm install -g npm@5

node_js:
- "6"
Expand All @@ -15,4 +15,4 @@ script:

after_success:
- npm run test:cov
- npm run test:codecov
- npm run test:codecov
13 changes: 12 additions & 1 deletion src/lruCache.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
const findIndex = (arr, fn) => {
for (let i = 0; i < arr.length; i++) {
if (fn(arr[i])) {
return i;
}
}

return -1;
}

export default function lruCache(limit, equals) {
const entries = []

function get(key) {
const cacheIndex = entries.findIndex(entry => equals(key, entry.key))
entries
const cacheIndex = findIndex(entries, entry => equals(key, entry.key))

// We found a cached entry
if (cacheIndex > -1) {
Expand Down

0 comments on commit 8ef91af

Please sign in to comment.