LRU Cache
LRU cache for async functions using primitive arguments.
Installation
yarn add @taystack/lru-async
Basic usage
The API for this was inspired by lodash debounce
and throttle
method wrappers.
// async/getUser.ts
import lruasync from '@taystack/lru-async'
import { getDog, Dog } from 'my-async-functions'
const fetchDog: Promise<Dog> = (breed: string) fetch(`/Dogs/${breed}`).then((res) => res.json())
const getDog = lruasync(fetchDog, 10)
export getDog
import { getDog } from 'async/getDog'