<commit_before>var Emitter = require('events').EventEmitter;
var compose = require('cobweb-compose');
var co      = require('co');

// Cobweb Class

var Cobweb = module.exports = function Cobweb () {
  var self = this instanceof Cobweb ? this : Object.create(Cobweb.prototype);
  self.initialize.apply(self, arguments);
  return self;
}

// Cobweb Prototype

var cobweb = Cobweb.prototype = Object.create(Emitter.prototype);

cobweb.initialize = function (middleware) {
  this.middleware = [];
  if (!middleware) return this;
  if (Array.isArray(middleware)) {
    middleware.forEach(this.include);
  } else this.include(middleware);
}

cobweb.compose = function () {
  var mwf = co(compose(this.middleware));
  return function* (next) {
    yield mwf.bind(this.context);
    yield next;
  }
}

cobweb.include = function (middleware) {
  this.middleware.push(middleware);
  return this;
}

cobweb.process = function (input, callback) {
  if (!Array.isArray(input)) input = [input];
  co(function* () {
    yield input.map(function (item) {
      var mwf = co(compose(this.middleware));
      var ctx = this.createContext(item);
      return mwf.bind(ctx);
    }, this);
    if (callback) callback();
  }).call(this);
}

cobweb.createContext = function (input) {
  var ctx = Object.create(this.context);
  ctx.input = input;
  return ctx;
}

// Cobweb Context

var context = cobweb.context = {};

context.throw = function (err) {
  throw err instanceof Error ? err : new Error(err);
}<commit_msg>Minor style changes<commit_after>var Emitter = require('events').EventEmitter;
var compose = require('cobweb-compose');
var co      = require('co');

// Cobweb Class

var Cobweb = module.exports = function Cobweb () {
  var self = this instanceof Cobweb ? this : Object.create(cobweb);
  self.initialize.apply(self, arguments);
  return self;
}

// Cobweb Prototype

var cobweb = Cobweb.prototype = Object.create(Emitter.prototype);

cobweb.initialize = function (middleware) {
  this.middleware = [];
  if (!middleware) return this;
  if (Array.isArray(middleware)) {
    middleware.forEach(this.include);
  } else this.include(middleware);
}

cobweb.compose = function () {
  var mwf = co(compose(this.middleware));
  return function* (next) {
    yield mwf.bind(this.context);
    yield next;
  }
}

cobweb.include = function (middleware) {
  this.middleware.push(middleware);
  return this;
}

cobweb.process = function (input, callback) {
  if (!Array.isArray(input)) input = [input];
  co(function* (self) {
    yield input.map(function (item) {
      var mwf = co(compose(self.middleware));
      var ctx = self.createContext(item);
      return mwf.bind(ctx);
    });
    if (callback) callback.call(self);
  })(this);
}

cobweb.createContext = function (input) {
  var ctx = Object.create(this.context);
  ctx.input = input;
  return ctx;
}

// Cobweb Context

var context = cobweb.context = {};

context.throw = function (err) {
  throw err instanceof Error ? err : new Error(err);
}
{'fraction_non_alphanumeric': 0.14457831325301204, 'fraction_numerical': 0.0, 'mean_word_length': 3.8444084278768234, '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': '2570580', 'n_tokens_mistral': 987, 'n_tokens_neox': 980, 'n_words': 230}