<commit_before>/**
 * Module dependencies.
 */
var debug = require('debug')('bootable');


/**
 * Creates an instance of `Initializer`.
 *
 * @constructor
 * @api public
 */
function Initializer() {
  this._phases = [];
}

/**
 * Run all phases.
 *
 * When the initializer is run, all phases will be executed sequentially, in
 * the order in which they were registered.  Once complete, `cb` will be
 * invoked.
 *
 * @param {Function} cb
 * @param {Object} [thisArg]
 * @api public
 */
Initializer.prototype.run = function(cb, thisArg) {
  var phases = this._phases
    , idx = 0;
  
  function next(err) {
    if (err) { return cb(err); }
    
    var phase = phases[idx++];
    // all done
    if (!phase) { return cb(); }
    
    try {
      if (typeof phase == 'object') {
        debug('%s', phase.constructor ? phase.constructor.name + '#boot' : 'anonymous#boot');
        phase.boot(next);
      } else {
        debug('%s', phase.name || 'anonymous');
        var arity = phase.length;
        if (arity == 1) {
          phase.call(thisArg, next);
        } else {
          phase.call(thisArg);
          next();
        }
      }
    } catch (ex) {
      next(ex);
    }
  }
  next();
};

/**
 * Register a phase.
 *
 * A phase can be either synchronous or asynchronous.  Synchronous phases have
 * following function signature
 *
 *     function myPhase() {
 *       // perform initialization
 *     }
 *
 * Asynchronous phases have the following function signature.
 *
 *     function myAsyncPhase(done) {
 *       // perform initialization
 *       done();  // or done(err);
 *     }
 *
 * The phase may also be an object that has a `boot` function.  In this case,
 * the object's boot function will be called during the boot sequence.  This is
 * typically used for objects that need to establish a persistent connection,
 * for example to a database or message queue.
 *
 * @param {Function} fn
 * @api public
 */
Initializer.prototype.phase = function(fn) {
  this._phases.push(fn);
  return this;
};


/**
 * Expose `Initializer`.
 */
module.exports = Initializer;<commit_msg>Clarify comments.<commit_after>/**
 * Module dependencies.
 */
var debug = require('debug')('bootable');


/**
 * Creates an instance of `Initializer`.
 *
 * @constructor
 * @api public
 */
function Initializer() {
  this._phases = [];
}

/**
 * Run all phases.
 *
 * When the initializer is run, all phases will be executed sequentially, in
 * the order in which they were registered.  Once complete, `cb` will be
 * invoked.
 *
 * @param {Function} cb
 * @param {Object} [thisArg]
 * @api public
 */
Initializer.prototype.run = function(cb, thisArg) {
  var phases = this._phases
    , idx = 0;
  
  function next(err) {
    if (err) { return cb(err); }
    
    var phase = phases[idx++];
    // all done
    if (!phase) { return cb(); }
    
    try {
      if (typeof phase == 'object') {
        debug('%s', phase.constructor ? phase.constructor.name + '#boot' : 'anonymous#boot');
        phase.boot(next);
      } else {
        debug('%s', phase.name || 'anonymous');
        var arity = phase.length;
        if (arity == 1) {
          phase.call(thisArg, next);
        } else {
          phase.call(thisArg);
          next();
        }
      }
    } catch (ex) {
      next(ex);
    }
  }
  next();
};

/**
 * Register a phase.
 *
 * A phase can be either synchronous or asynchronous.  Synchronous phases have
 * following function signature
 *
 *     function myPhase() {
 *       // perform initialization
 *     }
 *
 * Asynchronous phases have the following function signature.
 *
 *     function myAsyncPhase(done) {
 *       // perform initialization
 *       done();  // or done(err);
 *     }
 *
 * The phase may also be an object that has a `boot` function.  In this case,
 * the object's boot function will be called during the boot sequence.  This is
 * typically used for objects that need to establish a persistent connection,
 * for example to a database or message queue.
 *
 * @param {Function|Object} fn
 * @returns {Initializer} `this`, for a fluent interface.
 * @api public
 */
Initializer.prototype.phase = function(fn) {
  this._phases.push(fn);
  return this;
};


/**
 * Expose `Initializer`.
 */
module.exports = Initializer;
{'fraction_non_alphanumeric': 0.13571260859356657, 'fraction_numerical': 0.0009391876027236441, 'mean_word_length': 2.506172839506173, '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': '1024357', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1265, 'n_words': 411}