Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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 fSCacher from "func-cache/tools/fs"; // only for server
import redisCacher from "func-cache/tools/redis"; // only for server
import upstashCacher from "func-cache/tools/upstash"; // only for server
import funcache, { localStorageCacher } 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
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.