universal-memoize

1.0.4 • Public • Published

universal-memoize

A library of universal memoization for sync/async function. For async function, this library can just memoize the successful response of async request.

Installation

npm install universal-memoize --save

Usage

import memoize from 'universal-memoize'

// sync
const addOne = memoize(x => x + 1)
addOne(5).then(res => console.log(res)) // 6

//async
const fetchData = memoize(asyncFunc) //asyncFunc is your async function as 'uri => fetch(uri)'
fetchData(yourArgs).then(res => console.log(res))

Readme

Keywords

Package Sidebar

Install

npm i universal-memoize

Weekly Downloads

1

Version

1.0.4

License

MIT

Last publish

Collaborators

  • yuruiyin