https://github.com/azer/memoize-async
Async Function Memoizer
https://github.com/azer/memoize-async
Last synced: 11 months ago
JSON representation
Async Function Memoizer
- Host: GitHub
- URL: https://github.com/azer/memoize-async
- Owner: azer
- Created: 2013-03-31T09:35:42.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2014-01-29T12:57:50.000Z (over 12 years ago)
- Last Synced: 2025-04-09T07:52:02.099Z (about 1 year ago)
- Language: JavaScript
- Size: 164 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## memoize-async [](https://travis-ci.org/azer/memoize-async)
Async function memoizer.
### Install
```bash
$ npm install memoize-async
```
### Usage
```js
memoize = require('memoize-async')
readFile = require('fs').readFile
memoized = memoize(readFile)
memoized('docs/readme', console.log)
// doing some work
// => read me first!
memoized('docs/readme', console.log)
// => read me first!
```
### Storage
It stores the values returned in an object by default. You can pass read & write methods to choose your own:
```js
memoized = memoize(fn, { read: read, write: write, hash: ifexists })
function read (key, callback) {
}
function write (key, value, callback) {
}
```