# @hbauer/local-cache

> ## Install

Latest version **0.3.0** (published 2023-05-29) · 0 weekly downloads

## Install

```sh
npm install @hbauer/local-cache
pnpm add @hbauer/local-cache
yarn add @hbauer/local-cache
bun add @hbauer/local-cache
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2023-05-29 |
| First published | 2023-05-23 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | * |
| Dependencies | 5 |
| Unpacked size | 49.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Donald Geddes |
| Maintainers | hbauer |

## Links

- npm: https://www.npmjs.com/package/@hbauer/local-cache
- Repository: https://github.com/handlebauer/local-cache
- npm.io page: https://npm.io/package/@hbauer/local-cache

## Dependencies (5)

- [zod](https://npm.io/package/zod.md) ^3.21.4
- [immer](https://npm.io/package/immer.md) ^10.0.2
- [remeda](https://npm.io/package/remeda.md) ^1.14.0
- [@hbauer/local-file](https://npm.io/package/@hbauer/local-file.md) ^0.5.0
- [@hbauer/convenience-functions](https://npm.io/package/@hbauer/convenience-functions.md) ^0.33.1

## Recent versions

- 0.3.0 (latest) — 2023-05-29
- 0.1.14 — 2023-05-28
- 0.1.13 — 2023-05-27
- 0.1.12 — 2023-05-26
- 0.1.11 — 2023-05-26
- 0.1.10 — 2023-05-26
- 0.1.9 — 2023-05-26
- 0.1.8 — 2023-05-26
- 0.1.7 — 2023-05-25
- 0.1.6 — 2023-05-25
- 0.1.5 — 2023-05-23
- 0.1.4 — 2023-05-23
- 0.1.3 — 2023-05-23
- 0.1.2 — 2023-05-23
- 0.1.1 — 2023-05-23
- … 1 more at https://npm.io/package/@hbauer/local-cache/versions

## README

# @hbauer/local-cache

## Install

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

## Usage

```js
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
```

---
_Source: https://npm.io/package/@hbauer/local-cache · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
