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

@tejp/testing-streams

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tejp/testing-streams

Streams for test cases

  • 0.2.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

testing-streams

Streams for test cases.

The streams read/write predefined data and errors.

API

new ChunkReader(chunks, [options])

A readable stream that produces the given chunks of data when sombody tries to read from the stream.

chunks is an array that contains data objects, but it can also contain Error instances if the stream should emit errors. Additionally chunks can contain functions that are called as callbacks and can implement more complicated custom behavior.

For each read() the stream processes the next items in chunks.

function readHandler(stream) {
    // We could push some data
    stream.push("some data");

    // We could also emit an error
    stream.emit('error', new Error("some error"));

    // If we return a truthy value, the ChunkReader immediately processes
    // the next chunk. If it's falsy ChunkReader instead waits for the
    // next read.
    return true;
}

const reader = new ChunkReader(["plain data", readHandler, new Error("a failure")])
// calls to reader.read() will return "plain data" and "some data" and then raise
// errors "some error" and "a failure".

new NullWriter()

A writable stream that accepts and ignores anything that is written to it .

FAQs

Package last updated on 18 Jun 2021

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