Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
lru-memoize
Advanced tools
Readme
lru-memoize
is a utility to provide simple memoization for any pure javascript function, using an LRU cache that prioritizes the most recently accessed values, and discards the "least recently used" (LRU) items when the size limit is reached. If your function has side effects or relies on some external state to generate its result, it should not be memoized.
npm install --save lru-memoize
Let's look at an example where we want to memoize a function that multiplies three numbers together, and we want to keep the last ten arguments -> value
mappings in memory.
var memoize = require('lru-memoize');
var multiply = function(a, b, c) {
return a * b * c;
}
multiply = memoize(10)(multiply);
module.exports = multiply;
import memoize from 'lru-memoize';
let multiply = (a, b, c) => a * b * c;
multiply = memoize(10)(multiply);
export default multiply;
memoize(limit:Integer?, equals:Function?, deepObjects:Boolean?)
Returns (Function) => Function
.
limit
: Integer [optional]The number of
arguments -> value
mappings to keep in memory. Defaults to1
.
equals
: Function [optional]A function to compare two values for equality. Defaults to
===
.
deepObjects
: Boolean [optional]Whether or not to perform a deep equals on Object values. Defaults to
false
.
FAQs
A utility to provide lru memoization for any js function
The npm package lru-memoize receives a total of 8,348 weekly downloads. As such, lru-memoize popularity was classified as popular.
We found that lru-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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.