Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

stream-expect

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-expect

Interact with streams using expect

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
1
-93.33%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

node-stream-expect

stream-expect is a tool for controlling interactive streams.

Installation

$ npm install stream-expect

Usage

Checkout the examples for some sample usage.

expect.createExpect(ReadStream, WriteStream, [options])

Returns a new Expect object.

  • ReadStream - Object - A readable stream
  • WriteStream - Object - A writeable stream
  • options - Object
    • timeout - Number - Sets how long to wait before timing out, defaults to 10000

expect.createExpect(DuplexStream, [options])

Similar to above, but stream is both readable and writeable.

expect.spawn(command, [args], [options])

Convenience method for spawning a process, creating an Expect object, and using stdin and stdout for the read and write streams.

In other words this:

var child = require('child_process').spawn(command)
var exp = expect.createExpect(child.stdin, child.stdout)

Could optionally be replaced with this:

var exp = expect.spawn(command)

.expect(regex, callback)

Watch stream for data matching regex. Here are the callback's arguments:

  • err - Error|null - An error object will be returned if expect times out
  • output - String - The output of the stream since method was called
  • match - Array - The results of the successful regex

It's worth noting that regex matches will be non-greedy.

.send(string)

Write to the writeable stream

License

MIT

Keywords

expect

FAQs

Package last updated on 03 Jan 2013

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