0.0.1 • Published 2 years ago

@taystack/lru-async v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

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'