0.3.0 • Published 11 months ago

@hbauer/local-cache v0.3.0

Weekly downloads
-
License
-
Repository
github
Last release
11 months 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

11 months ago

0.1.14

11 months ago

0.1.13

11 months ago

0.1.12

11 months ago

0.1.11

11 months ago

0.1.10

11 months ago

0.1.9

11 months ago

0.1.8

11 months ago

0.1.7

12 months ago

0.1.6

12 months ago

0.1.5

12 months ago

0.1.4

12 months ago

0.1.3

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago