
Research
/Security News
Intercom’s npm Package Compromised in Ongoing Mini Shai-Hulud Worm Attack
Compromised intercom-client@7.0.4 npm package is tied to the ongoing Mini Shai-Hulud worm attack targeting developer and CI/CD secrets.
trie-memoize
Advanced tools
A memoization algorithm in which each function argument represents a new key, creating a trie of caches as defined by the array in your first argument.
npm i trie-memoize
A memoization algorithm in which each function argument represents a new
key in a mapping, creating a trie of caches - the depth of which defined
by your setup. It is very quick with its O(n arguments) lookup
performance and is memory-efficient, particularly when WeakMaps are used.
This memoization function only works for functions where the exact number of arguments is known and constant.
const m1 = memoize([{}], (v) => v.toUpperCase())
m1('foo') // FOO uncached
m1('foo') // FOO cached
const m2 = memoize([{}, Map], (v1, v2) => `${v1}-${v2}`)
m2('foo', 'bar') // foo-bar, uncached
m2('foo', 'bar') // foo-bar, cached
const m3 = memoize(
[WeakMap, Map, WeakMap],
(v1, v2, v3) =>
`${JSON.stringify(v1)}-${JSON.stringify(v1)}-${JSON.stringify(v3)}`
)
const v1 = {}
const v2 = 'foo'
const v3 = {}
m3(v1, v2, v3) // {}-"foo"-{} uncached
m3(v1, v2, v3) // {}-"foo"-{} cached
memoize(caches, fn)| Argument | Type | Description |
|---|---|---|
| caches | CacheConstructor[] | An array of plain objects or map-like constructors (Map, WeakMap, some custom map w/ get + set methods) used for caching each level of the tree. The first array element will be the cache for the first argument of the function, call, and so on. Therefore, the length of this array must be the same as the length of arguments your memoized function accepts, or at least as deep as you'd like to cache. |
| fn | (...args: T) => U | The function you'd like to memoize |
export type CacheConstructor =
| MapConstructor
| WeakMapConstructor
| MapLike
| Record<any, any>
MIT
FAQs
A memoization algorithm in which each function argument represents a new key, creating a trie of caches as defined by the array in your first argument.
We found that trie-memoize 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.

Research
/Security News
Compromised intercom-client@7.0.4 npm package is tied to the ongoing Mini Shai-Hulud worm attack targeting developer and CI/CD secrets.

Research
Socket detected a malicious supply chain attack on PyPI package lightning versions 2.6.2 and 2.6.3, which execute credential-stealing malware on import.

Research
A brand-squatted TanStack npm package used postinstall scripts to steal .env files and exfiltrate developer secrets to an attacker-controlled endpoint.