Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
cache-async-fn
Advanced tools
With MobX:
import { observable } from 'mobx';
import { cacheAsyncFactory } from 'cache-async-fn';
function createCache<T>(): { value: Record<string, T> } {
return observable(
{ value: {} },
{
value: observable.ref,
},
);
}
const { cacheAsync } = cacheAsyncFactory(createCache);
With Vue:
import { ref } from 'vue';
import { cacheAsyncFactory } from 'cache-async-fn';
function createCache<T>(): { value: Record<string, T> } {
return ref();
}
const { cacheAsync } = cacheAsyncFactory(createCache);
const myApi = cacheAsync(myApiCall, {
resolver: (params) => [groupKey, cacheKey],
});
// Call from anywhere
async function someAction() {
const response = await myApi(params);
}
// Get the current value anytime
function getValueSync() {
return myApi.get(params);
}
Each groupKey
has its own cache. The cache is invalidated when the cacheKey
changes.
The is the default behavior.
const loadOnceGlobally = cacheAsync(api);
// or
const loadOnceGlobally = cacheAsync(api, {
resolver: () => '',
});
const loadOnParamChange = cacheAsync(api, {
resolver: (params) => ['', JSON.stringify(params)],
});
The data for each tab will be cached in a different group, with the parameters as its cache key.
const loadOnParamChange = cacheAsync(api, {
resolver: (params) => [params.tab, JSON.stringify(params)],
});
FAQs
Cache asynchronous functions where they should be
The npm package cache-async-fn receives a total of 0 weekly downloads. As such, cache-async-fn popularity was classified as not popular.
We found that cache-async-fn 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.