
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@github/memoize
Advanced tools
This is a package which provides a memoize function, as well as a TypeScript
decorator which will memoize a class method.
import memoize from '@github/memoize'
const fn = memoize(function doExpensiveStuff() {
// Here's where you do expensive stuff!
})
const other = memoize(function doExpensiveStuff() {}, {
cache: new Map(), // pass your own cache implementation
hash: JSON.stringify // pass your own hashing implementation
})
hash?: (...args: A) => unknown
Provides a single value to use as the Key for the memoization.
Defaults to JSON.stringify (ish).cache?: Map<unknown, R>
The Cache implementation to provide. Must be a Map or Map-alike. Defaults to a Map.
Useful for replacing the cache with an LRU cache or similar.This package also includes a decorator module which can be used to provide TypeScript Decorator annotations to functions.
Here's an example, showing what you need to do:
import memoize from '@github/memoize/decorator'
// ^ note: add `/decorator` to the import to get decorators
class MyClass {
@memoize() // Memoize the method below
doThings() {
}
}
const cache = new Map()
class MyClass {
@memoize({ cache }) // Pass options just like the memoize function
doThings() {
}
}
Many memoize implementations exist. This one provides all of the utility we need at GitHub and nothing more. We've used a few various implementations in the past, here are some good ones:
npm install
npm test
Distributed under the MIT license. See LICENSE for details.
FAQs
A simple Memoize helper, with TypeScript decorator support!
The npm package @github/memoize receives a total of 7,171 weekly downloads. As such, @github/memoize popularity was classified as popular.
We found that @github/memoize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 17 open source maintainers 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.