Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
func-cache
Advanced tools
This is the fun and cache.
It stores a map of results of a function and uses arguments as keys, for faster response,
Note that if the function result in different results with the same argument, the cache wouldn't work.
import funcache from "func-cache";
const cachedFibonacci = funcache((num: number) => {
// ... your function here
}, options); // about the options, see below
console.log(cachedFibonacci(1000)); //-- viewing the result
console.log(cachedFibonacci.noCache(1000)); //-- run without caching
console.log(cachedFibonacci.clearCache()); //-- to clear the cache
import funcache, { localStorageCacher, fSCacher, redisCacher, upstashCacher } from "func-cache";
const options = {
// (1 sec) in miliseconds
lifeTime: 1000,
/** debounce time wait to call onDataUpdate, default 1000ms */
debounceTimer: 200,
/** incase the call is async, (sometimes the script doesn't detect it's async and wont run the await for it) default: false */
async: true,
// place to store the cache, incase of restarts (browser only)
...localStorageCacher("_cachePlace_for_fibonacci"),
// place to store the cache, incase of restarts (server only). fs way
...fSCacher("./_cachePlace_for_fibonacci.json"),
// place to store the cache, incase of restarts (server only). redis way
...redisCacher("_cachePlace_for_fibonacci", {
client: redisClient,
}),
// place to store the cache, incase of restarts (server only). upstash way
...upstashCacher("_cachePlace_for_fibonacci", {
client: upstashClient,
}),
};
FAQs
TypeScript library for caching static functions
The npm package func-cache receives a total of 20 weekly downloads. As such, func-cache popularity was classified as not popular.
We found that func-cache 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.