
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
memo-async-lru
Advanced tools
Memoize Node.js style callback-last functions, using an in-memory LRU store
Also works in the browser with browserify!
npm install memo-async-lru
const memo = require('memo-async-lru')
function fn (arg, cb) {
t.equal(arg, 'foo')
cb(null, 'bar')
}
const memoFn = memo(fn)
memoFn('foo', (err, result) => {
console.log(result) // prints 'bar'
memoFn('foo', (err, result) => {
console.log(result) // prints 'bar', cached, does not call fn()
})
})
memo(fn, [opts])Memoize the given function fn, using
async-lru, a simple async LRU cache supporting
O(1) set, get and eviction of old keys.
The function must be a Node.js style function, where the last argument is a callback.
function(key: Object, [...], fetch: function(err: Error, value: Object))
So, if you were to do:
const readFile = memo(fs.readFile)
readFile('file.txt', fn)
readFile('file.txt', fn) // <-- this uses the cache
The file would only be read from disk once, it's value cached, and returned anytime the first argument is 'file.txt'.
Repeated calls to the function with the same first argument will return a cached value, rather than re-fetch the data.
Optionally, an opts parameter can be specified with the following properties:
Optional options:
{
max: maxElementsToStore,
maxAge: maxAgeInMilliseconds
}
If you pass max, items will be evicted if the cache is storing more than max items.
If you pass maxAge, items will be evicted if they are older than maxAge when you access them.
MIT. Copyright (c) Feross Aboukhadijeh.
FAQs
Memoize Node.js style callback-last functions, using an in-memory LRU store
The npm package memo-async-lru receives a total of 61 weekly downloads. As such, memo-async-lru popularity was classified as not popular.
We found that memo-async-lru demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.