Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The zen-push npm package provides a simple and efficient way to handle push-based data streams. It is designed to be used in scenarios where you need to manage a sequence of data events, such as in reactive programming or when dealing with asynchronous data flows.
Basic Push Stream
This feature allows you to create a basic push stream where you can push values and subscribe to receive those values. The code sample demonstrates creating a push stream, subscribing to it, and pushing values to the stream.
const Push = require('zen-push');
const push = new Push();
// Subscribe to the stream
push.observable.subscribe({
next: value => console.log('Received:', value),
error: err => console.error('Error:', err),
complete: () => console.log('Stream complete')
});
// Push values to the stream
push.next('Hello');
push.next('World');
push.complete();
Error Handling
This feature demonstrates how to handle errors in the push stream. The code sample shows how to push an error to the stream and handle it in the subscription.
const Push = require('zen-push');
const push = new Push();
// Subscribe to the stream with error handling
push.observable.subscribe({
next: value => console.log('Received:', value),
error: err => console.error('Error:', err),
complete: () => console.log('Stream complete')
});
// Push values and an error to the stream
push.next('Hello');
push.error(new Error('Something went wrong!'));
Completion Handling
This feature shows how to handle the completion of the push stream. The code sample demonstrates pushing values to the stream and then completing it, triggering the completion handler in the subscription.
const Push = require('zen-push');
const push = new Push();
// Subscribe to the stream with completion handling
push.observable.subscribe({
next: value => console.log('Received:', value),
error: err => console.error('Error:', err),
complete: () => console.log('Stream complete')
});
// Push values and complete the stream
push.next('Hello');
push.next('World');
push.complete();
RxJS is a library for reactive programming using Observables, to make it easier to compose asynchronous or callback-based code. It provides a powerful set of operators for transforming, combining, and querying streams of data. Compared to zen-push, RxJS offers a more comprehensive and feature-rich API for working with reactive streams.
Most.js is a high-performance FRP (Functional Reactive Programming) library that focuses on speed and efficiency. It provides a minimalistic API for creating and manipulating streams. While zen-push is simpler and more focused on basic push streams, most.js offers advanced features and optimizations for handling large-scale data streams.
Bacon.js is a small functional reactive programming library for JavaScript. It provides a simple and intuitive API for working with streams and properties. Bacon.js is similar to zen-push in its simplicity but offers additional features like event streams and property streams, making it more versatile for different use cases.
A push stream observable class. (Sometimes called a Subject in Rx-speak.)
npm install zen-push
import PushStream from 'zen-push';
let pushStream = new PushStream();
pushStream.observable.subscribe(value => console.log(`Hello ${value}!`));
pushStream.next('World'); // 'Hello World!'
let pushStream = new PushStream();
Creates a new PushStream
object.
pushStream.observable.subscribe(value => console.log(`Hello ${value}!`));
The instance of Observable used to listen to elements in the push stream.
pushStream.next('World');
Sends the next stream value to all observers.
pushStream.error(new Error('The planet as been destroyed'));
Sends an error to all observers. Calling this method terminates the stream.
pushStream.complete();
Sends a signal to all observers that the stream is finished. Calling this method terminates the stream.
let multicastObservable = PushStream.multicast(observable);
multicastObservable.subscribe(console.log);
multicastObservable.subscribe(console.log);
Uses a PushStream
to send an observable's values to multiple subscribers.
FAQs
An Observable push stream
We found that zen-push 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
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.