<commit_before>'use strict';
module.exports = cachingStream;
var duplexer = require('duplexify');
var stream = require('readable-stream');

function cachingStream(defensiveCopies) {
	var created = false;
	var cacheStream = noOpReader();

	var output = noOpReader();
	var input = new stream.Writable({write: write})
		.once('finish', inputEnded);

	var duplex = duplexer(input, output);
	duplex.endPassThroughStream = endPassThroughStream;
	duplex.createCacheStream = createCacheStream;
	duplex.dropCache = dropCache;
	return duplex;

	function write(buffer, enc, cb) {
		if (cacheStream) {
			cacheStream.push(copyBuffer(buffer));
		}
		if (output) {
			output.push(buffer);
		}
		cb();
	}

	function inputEnded() {
		endPassThroughStream();
		endCacheStream();
	}

	function createCacheStream() {
		if (created) {
			throw new Error('copyStream was already created');
		}
		if (!cacheStream) {
			throw new Error('cache has been dropped');
		}
		created = true;
		return cacheStream;
	}

	function endPassThroughStream() {
		if (output) {
			output.push(null);
			output = null;
		}
	}

	function endCacheStream() {
		if (cacheStream) {
			cacheStream.push(null);
			if (created) {
				cacheStream = null;
			}
		}
	}

	function dropCacheStore() {
		if (!created) {
			cacheStream = null;
		}
	}

	function dropCache(endStream) {
		dropCacheStore();
		if (endStream) {
			endCacheStream();
		}
	}

	function copyBuffer(buffer) {
		return defensiveCopies && output ? new Buffer(buffer) : buffer;
	}
}

function noOp() {}

function noOpReader() {
	return new stream.Readable({read: noOp});
}<commit_msg>iojs and Node 4.0 fix<commit_after>'use strict';
module.exports = cachingStream;
var duplexer = require('duplexify');
var stream = require('readable-stream');

function cachingStream(defensiveCopies) {
	var created = false;
	var cacheStream = noOpReader();

	var output = noOpReader(true);
	var input = new stream.Writable({write: write})
		.once('finish', inputEnded);

	var duplex = duplexer(input, output, {readableObjectMode: true});
	duplex.endPassThroughStream = endPassThroughStream;
	duplex.createCacheStream = createCacheStream;
	duplex.dropCache = dropCache;
	return duplex;

	function write(buffer, enc, cb) {
		if (cacheStream) {
			cacheStream.push(copyBuffer(buffer));
		}
		if (output) {
			output.push(buffer);
		}
		cb();
	}

	function inputEnded() {
		endPassThroughStream();
		endCacheStream();
	}

	function createCacheStream() {
		if (created) {
			throw new Error('copyStream was already created');
		}
		if (!cacheStream) {
			throw new Error('cache has been dropped');
		}
		created = true;
		return cacheStream;
	}

	function endPassThroughStream() {
		if (output) {
			output.push(null);
			output = null;
		}
	}

	function endCacheStream() {
		if (cacheStream) {
			cacheStream.push(null);
			if (created) {
				cacheStream = null;
			}
		}
	}

	function dropCacheStore() {
		if (!created) {
			cacheStream = null;
		}
	}

	function dropCache(endStream) {
		dropCacheStore();
		if (endStream) {
			endCacheStream();
		}
	}

	function copyBuffer(buffer) {
		return defensiveCopies && output ? new Buffer(buffer) : buffer;
	}
}

function noOp() {}

function noOpReader(objectMode) {
	return new stream.Readable({objectMode: objectMode, read: noOp});
}
{'fraction_non_alphanumeric': 0.13087248322147652, 'fraction_numerical': 0.0006101281269066504, 'mean_word_length': 4.15566037735849, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4053051', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1066, 'n_words': 250}