<commit_before>'use strict';

/**
 *  Module dependencies.
 */

var debug = require('debug')('ware');
var Emitter = require('events').EventEmitter;
var compose = require('koa-compose');
var co = require('co');

/**
 *  slice() reference.
 */

var slice = Array.prototype.slice;

/**
 *  Ware prototype.
 */

var w = Ware.prototype;

/**
 *  Expose `Ware`.
 */

exports = module.exports = Ware;

/**
 *  Initialize a new `Ware` manager.
 *
 *  @api public
 */

function Ware () {
  if (!(this instanceof Ware)) return new Ware;
  this.env = process.env.NODE_ENV || 'development';
  this.outputErrors = 'test' != this.env;
  this.on('error', this.onerror);
  this.fns = [];
  this.context = Object.create(null);
}


/**
 *  Inherit from `Emitter.prototype`.
 */

Ware.prototype.__proto__ = Emitter.prototype;

/**
 *  Use the given middleware `fn`.
 *
 *  @param {GeneratorFunction} fn
 *  @return {Ware} self
 *  @api public
 */

w.use = function (fn) {
  debug('use %s', fn._name || fn.name || '-');
  this.fns.push(fn);
  return this;
};

/**
 *  Run through the middleware with the given `args` and optional `callback`.
 *
 *  @param {Mixed} args...
 *  @param {GeneratorFunction} callback (optional)
 *  @return {Ware}
 *  @api public
 */

w.run = function () {
  debug('run');
  var self = this;
  var mw = [].concat(this.fns);
  var args = slice.call(arguments);
  var last = args[args.length - 1];
  var callback = 'function' === typeof last ? last : null;
  if (callback) args.pop();
  mw.push(callback || noop);
  var gen = compose(mw);
  var fn = co(gen);
  var ctx = Object.create(this.context);
  ctx.input = args;
  ctx.onerror = function (err) {
    if (!err) return;
    self.emit('error', err);<commit_msg>add ctx.output<commit_after>'use strict';

/**
 *  Module dependencies.
 */

var debug = require('debug')('ware');
var Emitter = require('events').EventEmitter;
var compose = require('koa-compose');
var co = require('co');

/**
 *  slice() reference.
 */

var slice = Array.prototype.slice;

/**
 *  Ware prototype.
 */

var w = Ware.prototype;

/**
 *  Expose `Ware`.
 */

exports = module.exports = Ware;

/**
 *  Initialize a new `Ware` manager.
 *
 *  @api public
 */

function Ware () {
  if (!(this instanceof Ware)) return new Ware;
  this.env = process.env.NODE_ENV || 'development';
  this.outputErrors = 'test' != this.env;
  this.on('error', this.onerror);
  this.fns = [];
  this.context = Object.create(null);
}


/**
 *  Inherit from `Emitter.prototype`.
 */

Ware.prototype.__proto__ = Emitter.prototype;

/**
 *  Use the given middleware `fn`.
 *
 *  @param {GeneratorFunction} fn
 *  @return {Ware} self
 *  @api public
 */

w.use = function (fn) {
  debug('use %s', fn._name || fn.name || '-');
  this.fns.push(fn);
  return this;
};

/**
 *  Run through the middleware with the given `args` and optional `callback`.
 *
 *  @param {Mixed} args...
 *  @param {GeneratorFunction} callback (optional)
 *  @return {Ware}
 *  @api public
 */

w.run = function () {
  debug('run');
  var self = this;
  var mw = [].concat(this.fns);
  var args = slice.call(arguments);
  var last = args[args.length - 1];
  var callback = 'function' === typeof last ? last : null;
  if (callback) args.pop();
  mw.push(callback || noop);
  var gen = compose(mw);
  var fn = co(gen);
  var ctx = Object.create(this.context);
  ctx.input = args;
  ctx.output = Object.create(null);
  ctx.onerror = function (err) {
    if (!err) return;
    self.emit('error', err);
{'fraction_non_alphanumeric': 0.18424834722621444, 'fraction_numerical': 0.0005748778384593274, 'mean_word_length': 3.1826923076923075, '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': '3642068', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1219, 'n_words': 312}