0.0.3 • Published 2 years ago

async-cache-fn v0.0.3

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

async-cache-fn

NPM version

Usage

import { asyncCacheFn } from 'async-cache-fn'

export const getData = asyncCacheFn(async (url) => {
  const data = await fetch(url)
  return await data.json()
})
const users = await getData('/users')
const posts = await getData('/posts')

// in other place, `/users` will only be requested once and the result will be cached.
const users2 = await getData('/users')

Sponsors

License

MIT License © 2022 Anthony Fu

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago