Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@hdsydsvenskan/cached-lookup
Advanced tools
A cached lookup with background refresh
npm install --save @hdsydsvenskan/cached-lookup
Follow Semantic Versioning and use np and a version like patch | minor | major | prepatch | preminor | premajor | prerelease | 1.2.3
np patch
const cachedLookup = require('@hdsydsvenskan/cached-lookup');
// Create a cached lookup...
const getSomeData = cachedLookup(
param1 => doSomethingAsync(param1)
.then(result => processIt(result)),
{
name: 'some-data', // The name that should be used in logs etc to identify this lookup
cacheTime: 60 * 1000, // Cache the returned data for a minute
logger: bunyanCompatibleLogger
}
);
// ...and do the lookup, getting cached lookup back if any has been successfully resolved
getSomeData('foobar')
.catch(...)
.then(...)
cachedLookupMethod = cachedLookup(lookupMethod, options)
To be able to override the caching part of the cacheLookup (for example when
running tests in an application that has a dependency on something that in turn
includes this library with no way to disable it) it will also read from the
environment when running. If it finds the DISABLE_CACHED_LOOKUP
variable and
it's set to "true"
then all calls to cacheLookup will simply return the
lookupCallback
itself, effectively skipping the cache.
The lookup method should return a Promise
that when resolved is cached with the parameters sent into the method as the key and when rejected will trigger a retry according to the defined retry mechanism. After the cache time has expired a new lookup will be made and when successful it will replace the result returned for that set of lookup arguments and when not successful it will be retried until successful.
false
to disable logging.unnamed
.1000
.1000
.errorWait()
method.lookupMethod
and returns the cache key that should be used for that set of arguments.true
for every retrieve that triggers a refresh and false
for every retrieve that don't.FAQs
A cached lookup with background refresh
The npm package @hdsydsvenskan/cached-lookup receives a total of 254 weekly downloads. As such, @hdsydsvenskan/cached-lookup popularity was classified as not popular.
We found that @hdsydsvenskan/cached-lookup demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 open source maintainers 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.