<commit_before>// zip :: ReadableStream... -> ReadableStream
// zip function takes one or more streams
// and returns a readable combining the streams,
// such that it gathers chunks from all streams
// applying the first chunk as a function to the rest
// and then pushes them onto the combined
// stream, by waiting for all streams to have pushed a chunk.
//

import merge from "./merge";
import pipe from "./pipe";

export default function zip(...streams) {
  let applier, merged;

  // Merge streams
  merged = merge(...streams);

  // Create applier
  applier = pipe( chunks => {
    let [fn, ...args] = chunks;
    return fn(...args);
  });

  // return zipped stream
  return merged.pipeThrough( new applier );
}

// Browserify compat
if ( typeof module !== "undefined" )
  module.exports = zip;<commit_msg>Added type annotations for split.js<commit_after>// @flow

// zip :: ReadableStream... -> ReadableStream
// zip function takes one or more streams
// and returns a readable combining the streams,
// such that it gathers chunks from all streams
// applying the first chunk as a function to the rest
// and then pushes them onto the combined
// stream, by waiting for all streams to have pushed a chunk.
//

import type { ReadableWritable } from "./streams";
import { ReadableStream } from "./streams";

import merge from "./merge";
import pipe from "./pipe";

export default function zip(...streams: Array<ReadableStream>): ReadableStream {
  let applier: ReadableWritable,
      merged: ReadableStream;

  // Merge streams
  merged = merge(...streams);

  // Create applier
  applier = new pipe( chunks => {
    let [fn, ...args] = chunks;
    return fn(...args);
  });

  // return zipped stream
  return merged.pipeThrough( applier );
}
{'fraction_non_alphanumeric': 0.11986301369863013, 'fraction_numerical': 0.0, 'mean_word_length': 3.115023474178404, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '701085', 'n_tokens_mistral': 494, 'n_tokens_neox': 478, 'n_words': 207}