Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cyan33/memoize
A JavaScript function wrapper to memorize / cache result with the same input
https://github.com/cyan33/memoize
cache funcional-programming wrapper
Last synced: 27 days ago
JSON representation
A JavaScript function wrapper to memorize / cache result with the same input
- Host: GitHub
- URL: https://github.com/cyan33/memoize
- Owner: cyan33
- License: mit
- Created: 2017-10-18T19:00:42.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-28T21:04:47.000Z (about 7 years ago)
- Last Synced: 2024-10-02T14:17:48.661Z (about 1 month ago)
- Topics: cache, funcional-programming, wrapper
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# memoize
:beginner: A JavaScript function wrapper to memorize / cache result with the same input# Installation
```
npm install --save @changyan/memoize
```# Basic Usage
```js
import { memoize, memoizeAsync } from '@changyan/memoize'const add = (a, b) => a + b
const memoizedAdd = memoize(add)
memoizedAdd(1, 2) // => 3
memoizedAdd(1, 2) // => return the cached "3"const getFakeAsyncResult = () => new Promise((resolve, reject) => setTimeout(resolve, 1000))
// and it supports caching async functions
const memoizedGetAsyncResult = memoizeAsync(getFakeAsyncResult)
```## Contribution
PRs are welcomed!