# file-data-cache

> Tiny util to cache data from files. Use case: a small amount of files need to be watched

Latest version **2.1.1** (published 2021-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install file-data-cache
pnpm add file-data-cache
yarn add file-data-cache
bun add file-data-cache
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2021-01-25 |
| First published | 2021-01-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Matt Izoulet |
| Maintainers | matthizou |

## Links

- npm: https://www.npmjs.com/package/file-data-cache
- Repository: https://github.com/matthizou/file-data-cache
- Homepage: https://github.com/matthizou/file-data-cache#readme.md
- Issues: https://github.com/matthizou/file-data-cache/issues
- npm.io page: https://npm.io/package/file-data-cache

## Recent versions

- 2.1.1 (latest) — 2021-01-25
- 2.1.0 — 2021-01-25
- 2.0.0 — 2021-01-24
- 1.0.3 — 2021-01-10
- 1.0.2 — 2021-01-10
- 1.0.1 — 2021-01-10

## README

# file-data-cache

Tiny util to cache data from files.
Use case: a small amount of files need to be watched

```js
const loadFileData = (filePath, fileContent) => {
    const result = ..... // Do something
    return result // This value will be cached
}

const fileCache = new FileDataCache({
  loadFileData,
  checkInterval: 60000,
  readFile: true
})

// 1. Initial load of data
let processedData = fileCache.loadData(SOME_FILE_PATH)

// 2. Second call to `loadData`
// Cached values will be returned if:
// A/ the ellapsed time between this call and the last time the file was loading is smaller than `checkInterval`
// B/ the last modified date of the file hasn't changed

processedData = fileCache.loadData(SOME_FILE_PATH)

```

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