Socket
Socket
Sign inDemoInstall

then-read-stream

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

then-read-stream

Read from a readable stream just like a file


Version published
Weekly downloads
7.5K
increased by12.41%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status NPM version npm downloads Dependencies Coverage Status

A promise based asynchronous stream reader.

Allows to read from a Readable Stream similar as you would read from a file.

Usage

The then-read-stream contains one class: StreamReader. The constructor of the StreamReader if provided with the stream.Readable you want to read from.

TypeScript:
import {StreamReader} from "then-read-stream";

const readThisStream = ... // Some stream of type stream.Readable
const streamReader = new StreamReader(readThisStream);

const buf = new Buffer(16);
  
return streamReader.read(buf, 0, 16).then((bytesRead) => {
    // If all went well, buf contains the promised 16 bytes of data read
  }).catch((err) => {
    if(err === StreamReader.EndOfStream) {
      // Rejected, bacause end of the stream has been reached
    }
  })
JavaScript:
var stream_reader = require("then-read-stream");

var readThisStream = ... // Some stream of type stream.Readable
var streamReader = new stream_reader.StreamReader(readThisStream);

return streamReader.read(buf, 0, 16).then( function(bytesRead) {
    // If all went well, buf contains the promised 16 bytes of data read
  }).catch( function(err) {
    if(err === stream_reader.StreamReader.EndOfStream) {
      // Rejected, bacause end of the stream has been reached
    }
  })

Keywords

FAQs

Package last updated on 12 Aug 2017

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