<commit_before>"use strict";

var utils = require("../utils");
var log = require("npmlog");

module.exports = function(defaultFuncs, api, ctx) {
  return function getThreadList(start, end, type, callback) {
    if (utils.getType(callback) === 'Undefined') {
      if (utils.getType(end) !== 'Number') {
        throw {
          error: "Please pass a number as a second argument."
        };
      } else if (utils.getType(type) === 'Function') {
        callback = type;
        type = 'inbox'; //default to inbox
      } else if (utils.getType(type) != 'String') {
        throw {
          error: "Please pass a String as a third argument. Your options are: inbox, pending, and archived"
        };
      } else {
        throw {
          error: "getThreadList: need callback"
        };
      }
    }

    type = type.toLowerCase();
    if (type === 'archived') {
      type = 'action:archived';
    } else if (type !== 'inbox' && type !== 'pending') {
      throw {
        error: "type can only be one of the following: inbox, pending, archived"
      }
    }

    if (end <= start) end = start + 20;

    var form = {
      'client': 'mercury'
    };

    form[type + '[offset]'] = start;
    form[type + '[limit]'] = end - start;

    if (ctx.globalOptions.pageID) {
      form.request_user_id = ctx.globalOptions.pageID;
    }

    defaultFuncs
      .post("https://www.facebook.com/ajax/mercury/threadlist_info.php", ctx.jar, form)
      .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
      .then(function(resData) {
        if (resData.error) {
          throw resData;
        }
        log.verbose("Response in getThreadList: " + JSON.stringify(resData.payload.threads));
        return callback(null, (resData.payload.threads || []).map(utils.formatThread));<commit_msg>"removeToLowerCase"<commit_after>"use strict";

var utils = require("../utils");
var log = require("npmlog");

module.exports = function(defaultFuncs, api, ctx) {
  return function getThreadList(start, end, type, callback) {
    if (utils.getType(callback) === 'Undefined') {
      if (utils.getType(end) !== 'Number') {
        throw {
          error: "Please pass a number as a second argument."
        };
      } else if (utils.getType(type) === 'Function') {
        callback = type;
        type = 'inbox'; //default to inbox
      } else if (utils.getType(type) != 'String') {
        throw {
          error: "Please pass a String as a third argument. Your options are: inbox, pending, and archived"
        };
      } else {
        throw {
          error: "getThreadList: need callback"
        };
      }
    }

    if (type === 'archived') {
      type = 'action:archived';
    } else if (type !== 'inbox' && type !== 'pending') {
      throw {
        error: "type can only be one of the following: inbox, pending, archived"
      }
    }

    if (end <= start) end = start + 20;

    var form = {
      'client': 'mercury'
    };

    form[type + '[offset]'] = start;
    form[type + '[limit]'] = end - start;

    if (ctx.globalOptions.pageID) {
      form.request_user_id = ctx.globalOptions.pageID;
    }

    defaultFuncs
      .post("https://www.facebook.com/ajax/mercury/threadlist_info.php", ctx.jar, form)
      .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
      .then(function(resData) {
        if (resData.error) {
          throw resData;
        }
        log.verbose("Response in getThreadList: " + JSON.stringify(resData.payload.threads));
        return callback(null, (resData.payload.threads || []).map(utils.formatThread));
{'fraction_non_alphanumeric': 0.15023869699522607, 'fraction_numerical': 0.0011232799775344005, 'mean_word_length': 2.4086124401913875, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '1835883', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1092, 'n_words': 273}