
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@monesidn/load-n-cache-rxjs
Advanced tools
Make it easier to use load-n-cache in a rxjs environment.
Ok so you like load 'n' cache but prefer Observables instead of Promises? No problem at all! This small package provides a tiny layer to provide native Observable support. Internally it still uses Promises and async/await
code but you don't need to worry about.
If you can see a reason to fork the project to cut out promises entirely please let me know.
This project provides an rxjs compliant operator that:
These steps can be achieved easily using a ReplaySubject
and the share()
operator but, using this package you can also:
This library provides a one-stop solution to application level resource caching in a rxjs environment. You can achieve a similar result using the rxjs operators and some custom logic but it would be much harder to maintain.
The main class of this project is LoadNCacheObservable
that can be used directly or, in more .pipe()
friendly way, using the loadNCache()
function. Piping any observable through the loadNCache()
function result in caching its last emitted value. Any subsequent subscription will receive the cached value and the inner subscriber is left alone (unless a flush occurs).
When using a LoadNCache instance directly you can call the flush()
method to clear the cache value. For better rxjs integration the loadNCache()
function accepts an option: flushOn
. flushOn
is a function that should return an Observable
that will emit when the value must be flushed.
See the usage section for an example.
Check out https://monesidn.github.io/load-n-cache-rxjs/
npm install --save load-n-cache-rxjs
and then:
import { loadNCache } from "load-n-cache-rxjs";
public randStr$ = new Observable<string>((sub) => {
sub.next(randomStr());
sub.complete();
})
.pipe(loadNCache());
Just pipe you source observable into the loadNCache function to start caching.
public randStr$ = new Observable<string>((sub) => {
sub.next(randomStr());
sub.complete();
})
.pipe(loadNCache({ flushOn: () => timer(1000) }));
The timer(1000)
observable is subscribed after fetching a new value. After 1000ms from the fetching it emits and the value is flushed.
public randStr$ = new Observable<string>((sub) => {
sub.next(randomStr());
sub.complete();
})
.pipe(loadNCache({
persistence: 'localStorage',
persistenceKey: 'my-ls-key'
}));
You can supply a persistence manager or use one of the supported out of the box. See below for more.
LoadNCacheObservable
classLoadNCacheObservable
is a custom subclass of Observable that generates a LoadNCache instance and uses it to cache the last value emitted from the inner observable. This observable is very similar to a ReplaySubject(1)
with a some key differences:
Please don't interact directly with the LoadNCache instance from this class as it may result in undefined behaviour.
To the loadNCache function or to the LoadNCacheObservable constructor you can pass persistence options that work like those from the main project. See https://github.com/monesidn/load-n-cache for details.
FAQs
Make it easier to use load-n-cache in a rxjs environment.
The npm package @monesidn/load-n-cache-rxjs receives a total of 0 weekly downloads. As such, @monesidn/load-n-cache-rxjs popularity was classified as not popular.
We found that @monesidn/load-n-cache-rxjs 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.