Skip to content

Commit a4f33e2

Browse files
committed
docs: add methods for dealing with cache
1 parent 492261d commit a4f33e2

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
node_modules
2-
*.js.map
32
lcov.info

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ A PokeAPI wrapper intended for browsers. Comes fully asynchronous, zero dependen
1414
- [Example requests](#example-requests)
1515
- [Configuration](#configuration)
1616
- [Caching images](#caching-images)
17+
- [Caching methods](#caching-methods)
1718
- [Tests](#tests)
1819
- [Endpoints](#endpoints)
1920
- [Root Endpoints list](#root-endpoints-list)
@@ -31,7 +32,7 @@ console.log(await pokedex.getPokemonsList())
3132
```html
3233
<!-- Included in some HTML -->
3334
<script type="module">
34-
import {Pokedex} from "https://cdn.jsdelivr.net/gh/pokeapi/pokeapi-js-wrapper@beta/src/index.js"
35+
import {Pokedex} from "https://cdn.jsdelivr.net/gh/pokeapi/pokeapi-js-wrapper@2.0.2/src/index.js"
3536
const pokedex = await Pokedex.init();
3637
const version = await pokedex.getVersionByName(1)
3738
console.log(version)
@@ -65,7 +66,7 @@ pokedex.resource([
6566
## Configuration
6667

6768
Pass an Object to `Pokedex.init()` in order to configure it. Available options: `protocol`, `hostName`, `versionPath`, `cache`, `timeout`(ms), and `cacheImages`.
68-
Any option is optional :smile:. All the default values can be found [here](https://github.com/PokeAPI/pokeapi-js-wrapper/blob/master/src/config.js#L3-L10)
69+
Any option is optional :smile:. All the default values can be found [here](https://github.com/PokeAPI/pokeapi-js-wrapper/blob/master/src/config.js#L3-L11)
6970

7071
```js
7172
const customOptions = {
@@ -95,6 +96,14 @@ It's fundamental that you download the Service Worker [we provide](https://raw.g
9596

9697
A [basic example](https://github.com/PokeAPI/pokeapi-js-wrapper/blob/master/test/example-sw.html) is hosted [here](https://pokeapi.github.io/pokeapi-js-wrapper/test/example-sw.html).
9798

99+
### Caching methods
100+
101+
```js
102+
await P.getCacheLength() // Get how many objects are cached
103+
await P.clearCache() // Remove all entries
104+
await P.invalidateCache() // Remove only stale entries
105+
```
106+
98107
## Tests
99108

100109
`pokeapi-js-wrapper` can be tested using two strategies. One is with Node, since this package works with Node, and the other with a browser.
@@ -103,7 +112,7 @@ A [basic example](https://github.com/PokeAPI/pokeapi-js-wrapper/blob/master/test
103112
npm test
104113
```
105114

106-
Or open `/test/test.html` in your browser. A live version can be found at [`gh-pages`](https://pokeapi.github.io/pokeapi-js-wrapper/test/test.html)
115+
Or open `test/test.html` in your browser after serving the project with `npm run serve`. A live version can be found on the project [`gh-pages`](https://pokeapi.github.io/pokeapi-js-wrapper/test/test.html)
107116

108117
## Endpoints
109118

0 commit comments

Comments
 (0)