<commit_before>"use strict";

var path            = require('path');
var util            = require('util');
var Transform       = require('stream').Transform;
var PassThrough     = require('stream').PassThrough;
var Buffer          = require('buffer').Buffer;
var reactdown       = require('./index');
var isString        = require('./lib/isString');
var parseScopeSpec  = require('./lib/parseScopeSpec');

var cwd = process.cwd();

module.exports = function reactdownTransform(filename, opts) {
  if (!isString(filename) && !opts) {
    opts = filename;
    filename = undefined;
  }


  if (filename && !/\.md$/.exec(filename)) {
    return new PassThrough();
  }

  var scope = parseScopeSpec(opts.scope);

  for (var k in scope) {
    scope[k] = path.resolve(cwd, scope[k]);
  }

  opts.scope = scope;

  return new ReactdownTransform(opts);
}

function ReactdownTransform(opts) {
  Transform.call(this);
  this._buffer = new Buffer('');
  this._opts = opts;
}
util.inherits(ReactdownTransform, Transform);

ReactdownTransform.prototype._transform = function(chunk, encoding, done) {
  this._buffer = Buffer.concat([this._buffer, chunk]);
  done();
}

ReactdownTransform.prototype._flush = function(done) {<commit_msg>Parametrize transform over reactdown compiler<commit_after>"use strict";

var path            = require('path');
var util            = require('util');
var Transform       = require('stream').Transform;
var PassThrough     = require('stream').PassThrough;
var Buffer          = require('buffer').Buffer;
var reactdown       = require('./index');
var isString        = require('./lib/isString');
var parseScopeSpec  = require('./lib/parseScopeSpec');

var cwd = process.cwd();

module.exports = function reactdownTransform(filename, opts) {
  if (!isString(filename) && !opts) {
    opts = filename;
    filename = undefined;
  }


  if (filename && !/\.md$/.exec(filename)) {
    return new PassThrough();
  }

  var scope = parseScopeSpec(opts.scope);

  for (var k in scope) {
    scope[k] = path.resolve(cwd, scope[k]);
  }

  opts.scope = scope;

  return new ReactdownTransform(opts);
}

function ReactdownTransform(opts) {
  Transform.call(this);
  this._buffer = new Buffer('');
  this._opts = opts;
  this._reactdown = opts.reactdown || reactdown;
}
util.inherits(ReactdownTransform, Transform);

ReactdownTransform.prototype._transform = function(chunk, encoding, done) {
  this._buffer = Buffer.concat([this._buffer, chunk]);
  done();
}

ReactdownTransform.prototype._flush = function(done) {
{'fraction_non_alphanumeric': 0.1489108910891089, 'fraction_numerical': 0.0, 'mean_word_length': 3.7481203007518795, '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': '6147368', 'n_tokens_mistral': 760, 'n_tokens_neox': 741, 'n_words': 171}