with-localstorage-cache
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

with-localstorage-cache

Wrap any method, sync or async with a local storage cache.

Usage

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

const myID = await withFsCache(
  // Can be anything
  "my-id",
  async () => {
    await sleep(500);
    functionCallCount += 1;
    return { someData: "1" };
  }
);

// If called again it will return without waiting.

Readme

Keywords

none

Package Sidebar

Install

npm i with-localstorage-cache

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

10.3 kB

Total Files

10

Last publish

Collaborators

  • rakannimer