<commit_before>/*!
 * @overview  Github.js
 *
 * @copyright (c) 2013 <NAME>, Development Seed
 *            Github.js is freely distributable.
 *
 * @license   Licensed under BSD-3-Clause-Clear
 *
 *            For all details and documentation:
 *            http://substance.io/michael/github
 */
'use strict';

(function (root, factory) {
   /* istanbul ignore next */
   if (typeof define === 'function' && define.amd) {
      define(['es6-promise', 'base-64', 'utf8', 'axios'], function (Promise, Base64, Utf8, axios) {
         return (root.Github = factory(Promise, Base64, Utf8, axios));
      });
   } else if (typeof module === 'object' && module.exports) {
      module.exports = factory(require('es6-promise'), require('base-64'), require('utf8'), require('axios'));
   } else {
      root.Github = factory(root.Promise, root.base64, root.utf8, root.axios);
   }
}(this, function(Promise, Base64, Utf8, axios) {
   function b64encode(string) {
      return Base64.encode(Utf8.encode(string));
   }

   if (Promise.polyfill) {
      Promise.polyfill();
   }

   // Initial Setup
   // -------------

   var Github = function (options) {
      var API_URL = options.apiUrl || 'https://api.github.com';

      // HTTP Request Abstraction
      // =======
      //
      // I'm not proud of this and neither should you be if you were responsible for the XMLHttpRequest spec.

      var _request = Github._request = function _request(method, path, data, cb, raw) {
         function getURL() {
            var url = path.indexOf('//') >= 0 ? path : API_URL + path;

            url += ((/\?/).test(url) ? '&' : '?');

            if (data && typeof data === 'object' && ['GET', 'HEAD', 'DELETE'].indexOf(method) > -1) {
               for (var param in data) {
                  if (data.hasOwnProperty(param))
                     url += '&' + encodeURIComponent(param) + '=' + encodeURIComponent(data[param]);
               }
            }

            return url + (typeof window !== 'undefined' ? '&' + new Date().getTime() : '');
         }

         var config = {
            headers: {
               Accept: raw ? 'application/vnd.github.v3.raw+json' : 'application/vnd.github.v3+json',
               'Content-Type': 'application/json;charset=UTF-8'
            },
            method: method,
            data: data ? data : {},
            url: getURL()
         };

         if ((options.token) || (options.username && options.password)) {
            config.headers['Authorization'] = options.token ?
            'token ' + options.token :
            'Basic ' + b64encode(options.username + ':' + options.password);
         }

         return axios(config)
            .then(function (response) {
               cb(
                  null,
                  response.data || true,
                  response.request
               );
            }, function (response) {
               if (response.status === 304) {
                  cb(
                     null,
                     response.data || true,
                     response.request
                  );
               } else {
                  cb({
                     path: path,
                     request: response.request,
                     error: response.status
                  });
               }
            });
      };

      var _requestAllPages = Github._requestAllPages = function _requestAllPages(path, cb) {
         var results = [];

         (function iterate() {
            _request('GET', path, null, function (err, res, xhr) {
               if (err) {
                  return cb(err);
               }

               results.push.apply(results, res);

               var links = (xhr.getResponseHeader('link') || '').split(/\s*,\s*/g);
               var next = null;

               links.forEach(function (link) {
                  next = /rel="next"/.test(link) ? link : next;
               });

               if (next) {
                  next = (/<(.*)>/.exec(next) || [])[1];
               }

               if (!next) {
                  cb(err, results);
               } else {
                  path = next;
                  iterate();
               }
            });
         })();
      };

      // User API
      // =======

      Github.User = function () {
         this.repos = function (options, cb) {
            if (arguments.length === 1 && typeof arguments[0] === 'function') {
               cb = options;<commit_msg>requestAllPages: Wrap response in array if needed<commit_after>/*!
 * @overview  Github.js
 *
 * @copyright (c) 2013 <NAME>, Development Seed
 *            Github.js is freely distributable.
 *
 * @license   Licensed under BSD-3-Clause-Clear
 *
 *            For all details and documentation:
 *            http://substance.io/michael/github
 */
'use strict';

(function (root, factory) {
   /* istanbul ignore next */
   if (typeof define === 'function' && define.amd) {
      define(['es6-promise', 'base-64', 'utf8', 'axios'], function (Promise, Base64, Utf8, axios) {
         return (root.Github = factory(Promise, Base64, Utf8, axios));
      });
   } else if (typeof module === 'object' && module.exports) {
      module.exports = factory(require('es6-promise'), require('base-64'), require('utf8'), require('axios'));
   } else {
      root.Github = factory(root.Promise, root.base64, root.utf8, root.axios);
   }
}(this, function(Promise, Base64, Utf8, axios) {
   function b64encode(string) {
      return Base64.encode(Utf8.encode(string));
   }

   if (Promise.polyfill) {
      Promise.polyfill();
   }

   // Initial Setup
   // -------------

   var Github = function (options) {
      var API_URL = options.apiUrl || 'https://api.github.com';

      // HTTP Request Abstraction
      // =======
      //
      // I'm not proud of this and neither should you be if you were responsible for the XMLHttpRequest spec.

      var _request = Github._request = function _request(method, path, data, cb, raw) {
         function getURL() {
            var url = path.indexOf('//') >= 0 ? path : API_URL + path;

            url += ((/\?/).test(url) ? '&' : '?');

            if (data && typeof data === 'object' && ['GET', 'HEAD', 'DELETE'].indexOf(method) > -1) {
               for (var param in data) {
                  if (data.hasOwnProperty(param))
                     url += '&' + encodeURIComponent(param) + '=' + encodeURIComponent(data[param]);
               }
            }

            return url + (typeof window !== 'undefined' ? '&' + new Date().getTime() : '');
         }

         var config = {
            headers: {
               Accept: raw ? 'application/vnd.github.v3.raw+json' : 'application/vnd.github.v3+json',
               'Content-Type': 'application/json;charset=UTF-8'
            },
            method: method,
            data: data ? data : {},
            url: getURL()
         };

         if ((options.token) || (options.username && options.password)) {
            config.headers['Authorization'] = options.token ?
            'token ' + options.token :
            'Basic ' + b64encode(options.username + ':' + options.password);
         }

         return axios(config)
            .then(function (response) {
               cb(
                  null,
                  response.data || true,
                  response.request
               );
            }, function (response) {
               if (response.status === 304) {
                  cb(
                     null,
                     response.data || true,
                     response.request
                  );
               } else {
                  cb({
                     path: path,
                     request: response.request,
                     error: response.status
                  });
               }
            });
      };

      var _requestAllPages = Github._requestAllPages = function _requestAllPages(path, cb) {
         var results = [];

         (function iterate() {
            _request('GET', path, null, function (err, res, xhr) {
               if (err) {
                  return cb(err);
               }

               if (!(res instanceof Array)) {
                  res = [res];
               }

               results.push.apply(results, res);

               var links = (xhr.getResponseHeader('link') || '').split(/\s*,\s*/g);
               var next = null;

               links.forEach(function (link) {
                  next = /rel="next"/.test(link) ? link : next;
               });

               if (next) {
                  next = (/<(.*)>/.exec(next) || [])[1];
               }

               if (!next) {
                  cb(err, results);
               } else {
                  path = next;
                  iterate();
               }
            });
         })();
      };

      // User API
      // =======

      Github.User = function () {
         this.repos = function (options, cb) {
            if (arguments.length === 1 && typeof arguments[0] === 'function') {
               cb = options;
{'fraction_non_alphanumeric': 0.15018193847171685, 'fraction_numerical': 0.009482853677362443, 'mean_word_length': 1.4244854317027533, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5235339', 'n_tokens_mistral': 2554, 'n_tokens_neox': 2422, 'n_words': 563}