Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stream-to-observable

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-to-observable

Convert Node Streams into ECMAScript-Observables

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is stream-to-observable?

The stream-to-observable npm package allows you to convert Node.js streams into observables, which can be particularly useful for handling asynchronous data streams in a more functional and reactive programming style.

What are stream-to-observable's main functionalities?

Convert Readable Stream to Observable

This feature allows you to convert a Node.js Readable stream into an Observable. The code sample demonstrates how to create a Readable stream and convert it into an Observable, which can then be subscribed to for handling data, errors, and completion.

const streamToObservable = require('stream-to-observable');
const { Readable } = require('stream');
const { Observable } = require('rxjs');

const readableStream = new Readable({
  read() {
    this.push('data1');
    this.push('data2');
    this.push(null); // No more data
  }
});

const observable = streamToObservable(readableStream);

observable.subscribe({
  next: data => console.log(data),
  error: err => console.error(err),
  complete: () => console.log('Stream complete')
});

Convert Writable Stream to Observable

This feature allows you to convert a Node.js Writable stream into an Observable. The code sample demonstrates how to create a Writable stream and convert it into an Observable, which can then be subscribed to for handling data, errors, and completion.

const streamToObservable = require('stream-to-observable');
const { Writable } = require('stream');
const { Observable } = require('rxjs');

const writableStream = new Writable({
  write(chunk, encoding, callback) {
    console.log(chunk.toString());
    callback();
  }
});

const observable = streamToObservable(writableStream);

observable.subscribe({
  next: data => console.log(data),
  error: err => console.error(err),
  complete: () => console.log('Stream complete')
});

Other packages similar to stream-to-observable

Keywords

FAQs

Package last updated on 25 Apr 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc