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

mock-utf8-stream

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

mock-utf8-stream

Mock readable and writable streams for UTF-8 text.

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
547
increased by5370%
Maintainers
1
Weekly downloads
 
Created
Source

mock-utf8-stream

Mock readable and writable streams for UTF-8 text. Useful for testing command-line programs by mocking stdin, stdout, and stderr.

Example

var assert = require("assert");
var stream = require("mock-utf8-stream");

var stdin = new stream.MockReadableStream();
var stdout = new stream.MockWritableStream();

function example(opts, cb) {
    opts.stdin.on("data", function (data) {
        if (data === "hello") {
            opts.stdout.write("hello\n");
        }
        cb(null);
    });
}

// Begin capturing data events.
// You can read captured data as a UTF-8
// string on the `stdout.capturedData` property.
stdout.startCapture();

example({
    stdin: stdin,
    stdout: stdout
}, function (err) {
    if (err) { throw err; }
    assert.strictEqual(stdout.capturedData, "hello\n");
    console.log("OK");
});

stdin.write("hello");

Author & License

BSD. See LICENSE for details and copyright information.

Keywords

FAQs

Package last updated on 01 Mar 2014

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