0.3.0 • Published 3 years ago

@hbauer/local-cache v0.3.0

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

@hbauer/local-cache

Install

$ yarn add @hbauer/local-cache
$ npm install @hbauer/local-cache

Usage

import { LocalHTTPCache } from '@hbauer/local-cache'

const rootDirectory = '__cache' // writes to $PROJECT_ROOT/__cache/...
const name = 'movies' // writes to $PROJECT_ROOT/__cache/movies/...

const cache = new LocalHTTPCache('https://imdb.com', 'html', {
  rootDirectory,
  name,
})

const href = `${baseURL}/title/${movieId}` // i.e. https://imdb.com/title/...'
const data = await fetch(href).then(response => response.text())
const file = await cache.set(href, data)

assert.equal(file instanceof LocalFile === true)
assert.equal(file.filename, movieId)
assert.deepEqual(file.data, data)
assert.deepEqual(file.data, await cache.get(href))

const { filename, fullPath } = cache.getPaths(href)

assert.equal(file.filename, filename)
assert.equal(file.path.endsWith(fullPath) === true)

// TODO: finish readme
0.3.0

3 years ago

0.1.14

3 years ago

0.1.13

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago