1.2.0 • Published 1 year ago

file-cached v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

file-cached

Simply cache your object in ./cache.json file.

Release

Usage Example

with obj-cached

import { FileCacheObj } from "file-cached";
import { objCachedAsync } from "obj-cached";

const cacheObj = FileCacheObj(import.meta.dir + "/cache.json");

const result = await objCachedAsync(async () => {
  // do sth heavy
}, cacheObj)();

standalone

import { FileCacheObj } from "file-cached";

const cacheObj = FileCacheObj(import.meta.dir + "/cache.json");

console.log(cacheObj["abc"]); // undefined
// "./cache.json" not existed

cacheObj["abc"] = 123;
// "./cache.json" = {abc: 123}

console.log(cacheObj["abc"]); // 123

cacheObj["def"] = "456";
// "./cache.json" = {abc: 123, def: "456"}

console.log(cacheObj["def"]); // 456

Spec

Check spec here ./index.spec.ts

1.2.0

1 year ago

1.0.2

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.14

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

0.0.16

1 year ago

1.0.0

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago