title: Processing nested streams
body: <p>I am trying to generate an output file by joining 2 csv input streams, for each record in csv 1 I want to generate an output for each record in csv 2.</p>
  
  <p>I came across highland while browsing stack overflow for any similar solutions and came across:</p>
  
  <p><a href="https://stackoverflow.com/questions/27721268/nested-stream-operations-in-highland-js">Nested stream operations in Highland.js</a></p>
  
  <p>I have attempted to adjust this to my own problem and so far have this:</p>
  
  <pre><code>    const debug = require('debug')('csvparse');
      const csv = require('fast-csv');
      const fs = require('fs');
      const args = process.argv;
      const h = require('highland');
  
      const typestream = h(fs.createReadStream(args[2]).pipe(csv({ headers: true, ignoreEmpty: true })));
      const postcodestream = h(fs.createReadStream(args[3]).pipe(csv({ headers: true, ignoreEmpty: true })));
  
      const pipeline = typestream.flatMap((type) =&gt; {
          debug(type);
  
          return postcodestream.flatMap((postcode) =&gt; {
              debug(postcode);
  
              return h([`${type.type}-${postcode.postcode}\n`]);
          });
      });
  
      pipeline.pipe(process.stdout);
  
  </code></pre>
  
  <p>With the following example inputs
  csv1:</p>
  
  <pre><code>type,
  STREET,
  ROAD,
  </code></pre>
  
  <p>csv2:</p>
  
  <pre><code>postcode,
  3456
  3446
  1234
  </code></pre>
  
  <p>Id expect output of </p>
  
  <pre><code>STREET-3456
  STREET-3446
  STREET-1234
  ROAD-3456
  ROAD-3446
  ROAD-1234
  </code></pre>
  
  <p>But Im just getting:</p>
  
  <pre><code>STREET-3456
  STREET-3446
  STREET-1234
  </code></pre>
  
  <p>I can see from the debug statements that i get the out of ROAD once and then it stops.</p>