<commit_before>const _ = require('co-lodash');
const through = require('through');
const duplex = require('duplexer');
const pause = require('pause-stream');
const split = require('split');

exports.through = through;
exports.duplex = duplex;
exports.pause = pause;
exports.split = split;

exports.wait = function *(stream) {
  yield cb => {
    stream.on('end', cb);
    stream.on('finish', cb);
  };
};

exports.Reader = require('./lib/reader.js').Reader;
exports.LineReader = require('./lib/reader.js').LineReader;
exports.Writer = require('./lib/writer.js').Writer;

const EachStream = require('./lib/each-stream.js');
const MapStream = require('./lib/map-stream.js');
const EventStream = require('./lib/event-stream.js');
const IterableStream = require('./lib/iterable-stream');

exports.object = {
  each: (iterator, opt) => new EachStream(iterator, _.defaults(opt || {}, { objectMode: true })),
  map: (mapper, opt) => new MapStream(mapper, _.defaults(opt || {}, { objectMode: true })),
  filter: (filter, opt) => new MapStream(filter, _.defaults(opt || {}, { objectMode: true, isFilter: true  })),
  fromEmitter: (em, opt) => new EventStream(em, _.defaults(opt || {}, { objectMode: true }))
};

exports.string = {<commit_msg>use Promise, so async function can use it.<commit_after>const _ = require('co-lodash');
const through = require('through');
const duplex = require('duplexer');
const pause = require('pause-stream');
const split = require('split');

exports.through = through;
exports.duplex = duplex;
exports.pause = pause;
exports.split = split;

exports.wait = stream => new Promise((resolve, reject) => {
  stream.on('end', resolve);
  stream.on('finish', resolve);
  stream.on('error', reject);
});

exports.Reader = require('./lib/reader.js').Reader;
exports.LineReader = require('./lib/reader.js').LineReader;
exports.Writer = require('./lib/writer.js').Writer;

const EachStream = require('./lib/each-stream.js');
const MapStream = require('./lib/map-stream.js');
const EventStream = require('./lib/event-stream.js');
const IterableStream = require('./lib/iterable-stream');

exports.object = {
  each: (iterator, opt) => new EachStream(iterator, _.defaults(opt || {}, { objectMode: true })),
  map: (mapper, opt) => new MapStream(mapper, _.defaults(opt || {}, { objectMode: true })),
  filter: (filter, opt) => new MapStream(filter, _.defaults(opt || {}, { objectMode: true, isFilter: true  })),
  fromEmitter: (em, opt) => new EventStream(em, _.defaults(opt || {}, { objectMode: true }))
};

exports.string = {
{'fraction_non_alphanumeric': 0.1980276134122288, 'fraction_numerical': 0.0, 'mean_word_length': 4.939110070257612, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '3759515', 'n_tokens_mistral': 774, 'n_tokens_neox': 769, 'n_words': 179}