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

@samverschueren/stream-to-observable

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@samverschueren/stream-to-observable

Convert Node Streams into ECMAScript-Observables

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5M
decreased by-5.52%
Maintainers
1
Weekly downloads
 
Created

What is @samverschueren/stream-to-observable?

The @samverschueren/stream-to-observable npm package is designed to convert Node.js streams into observables. This allows developers to use reactive programming techniques with streams, making it easier to compose asynchronous or callback-based code in a more readable and expressive way. It supports both readable and writable streams.

What are @samverschueren/stream-to-observable's main functionalities?

Converting a readable stream to an observable

This feature allows you to convert a readable stream, like one returned by `fs.createReadStream`, into an observable. You can then use RxJS operators to process the data events emitted by the stream.

const toObservable = require('@samverschueren/stream-to-observable');
const fs = require('fs');

const stream = fs.createReadStream('file.txt');
const observable = toObservable(stream);

observable.subscribe({
  next(data) { console.log(data.toString()); },
  error(err) { console.error('Something went wrong: ', err); },
  complete() { console.log('Done reading file'); }
});

Converting a writable stream to an observable

This feature enables the conversion of a writable stream into an observable. It is particularly useful for tracking when the stream has finished writing.

const toObservable = require('@samverschueren/stream-to-observable');
const { Writable } = require('stream');

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

const observable = toObservable(writableStream);

observable.subscribe({
  complete() { console.log('Done writing to stream'); }
});

Other packages similar to @samverschueren/stream-to-observable

Keywords

FAQs

Package last updated on 09 Aug 2020

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