<commit_before>var Promise = require('bluebird'),
    google = require('googleapis'),
    youtube = google.youtube('v3');

/**
 * Paginator Constructor
 * @constructor
 */
function Paginator(options){
  var component = this;
  this.options(options);
  this.getAllPages = function(responses){
    if(!component._options.endpoint || !component._options.params ){
      throw new Error('missing required params');
    }
    else{
      if(!responses) responses = [];
      return component.getPage().then(function(response){
        responses.push(response);
        if(response.nextPageToken){
          component._options.params.pageToken = response.nextPageToken;
          return component.getAllPages(responses);
        }
        else{
          return responses;
        }
      });

    }
  };
  this.getPage = function(){
    return component.executeFunctionByName(component._options.endpoint, youtube, component._options.params);
  };
  this.executeFunctionByName = function (functionName, context /*, args */) {
    var args = [].slice.call(arguments).splice(2);
    var namespaces = functionName.split(".");
    var func = namespaces.pop();
    for(var i = 0; i < namespaces.length; i++) {
      context = context[namespaces[i]];
    }
    var promisified = Promise.promisify(context[func]);
    return promisified.apply(this, args);
  };
}

/**
 * Set options
 * @param  {Object} opts Options to set
 */
Paginator.prototype.options = function(opts) {
  this._options = opts || {};
};

Paginator.prototype.getOptions = function(){
  return this._options;
};


var paginator = new Paginator();

module.exports = paginator;<commit_msg>Paginator code format<commit_after>var Promise = require('bluebird'),
  google = require('googleapis'),
  youtube = google.youtube('v3');

/**
 * Paginator Constructor
 * @constructor
 */
function Paginator(options) {
  var component = this;
  this.options(options);

  this.getAllPages = function (responses) {

    if (!component._options.endpoint || !component._options.params) {
      throw new Error('missing required params');
    }

    if (!responses) {
      responses = [];
    }

    return component.getPage().then(function (response) {
      responses.push(response);

      if (response.nextPageToken) {
        component._options.params.pageToken = response.nextPageToken;
        return component.getAllPages(responses);
      } else {
        return responses;
      }
    });
  };

  this.getPage = function () {
    return component.executeFunctionByName(component._options.endpoint, youtube, component._options.params);
  };

  this.executeFunctionByName = function (functionName, context) {
    var args = [].slice.call(arguments).splice(2),
      namespaces = functionName.split("."),
      func = namespaces.pop();

    for (var i = 0; i < namespaces.length; i++) {
      context = context[namespaces[i]];
    }

    var promisified = Promise.promisify(context[func]);
    return promisified.apply(this, args);
  };

}

/**
 * Set options
 * @param  {Object} opts Options to set
 */
Paginator.prototype.options = function (opts) {
  this._options = opts || {};
};

Paginator.prototype.getOptions = function () {
  return this._options;
};


var paginator = new Paginator();

module.exports = paginator;
{'fraction_non_alphanumeric': 0.13988368533823078, 'fraction_numerical': 0.0018365472910927456, 'mean_word_length': 3.328476821192053, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1727039', 'n_tokens_mistral': 960, 'n_tokens_neox': 938, 'n_words': 194}