How to use duplexer - 2 common examples

To help you get started, we’ve selected a few duplexer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mysticatea / cpx / src / command.js View on Github external
return file => {
          const env = Object.create(process.env, {FILE: {value: file}});
          const parts = parseShellQuote(command, env);
          const child = spawn(parts[0], parts.slice(1), {env});
          const outer = duplexer(child.stdin, child.stdout);
          child.on("exit", function(code) {
            if (code !== 0) {
              outer.emit(
                "error",
                new Error("non-zero exit code in command: " + command));
            }
          });
          child.stderr.pipe(process.stderr);

          return outer;
      };
  });
github axross / tap-diff / sources / index.js View on Github external
const createReporter = () => {
  const output = through2();
  const p = parser();
  const stream = duplexer(p, output);
  const startedAt = Date.now();

  const println = (input = '', indentLevel = 0) => {
    let indent = '';

    for (let i = 0; i < indentLevel; ++i) {
      indent += INDENT;
    }

    input.split('\n').forEach(line => {
      output.push(`${indent}${line}`);
      output.push('\n');
    });
  };

  const handleTest = name => {

duplexer

Creates a duplex stream

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis

Popular duplexer functions