Skip to content

Commit df72588

Browse files
committed
feat: add cache deletion
1 parent 68cb29d commit df72588

4 files changed

Lines changed: 145 additions & 116 deletions

File tree

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import { loadResource } from './getter.js'
66
import { installSW } from './installSW.js'
77
import { Config } from './config.js'
88

9+
localForage.config({
10+
name: 'pokeapi-js-wrapper'
11+
})
12+
913
export class Pokedex {
1014

1115
constructor(config) {
1216
this.config = new Config(config)
13-
this.getConfig = function() {
14-
return this.config
15-
}
1617

1718
// add to Pokedex.prototype all our endpoint functions
1819
endpoints.forEach(endpoint => {
@@ -49,15 +50,23 @@ export class Pokedex {
4950
}
5051
})
5152

52-
localForage.config({
53-
name: 'pokeapi-js-wrapper'
54-
})
55-
5653
if (this.config.cacheImages) {
5754
installSW()
5855
}
5956
}
6057

58+
getConfig() {
59+
return this.config
60+
}
61+
62+
getCacheLength() {
63+
return localForage.length()
64+
}
65+
66+
clearCache() {
67+
return localForage.clear()
68+
}
69+
6170
resource(path) {
6271
if (typeof path === 'string') {
6372
return loadResource(this.config, path)

0 commit comments

Comments
 (0)