<commit_before>/**
 * Wrapper for arcgis api
 */
var rq = require('./request/index')
var uniq = require('./lib/uniq')

import user from './user/index'
import organization from './org/index'
import group from './group/index'
import item from './item/index'
import usage from './usage/index'

var Client = {
  search: function (queryString = '\"\"', num = 100, page = 0, sort = 'created', order = 'desc') {
    var startNum = num * page + 1
    return this.request(`search`, {'q': queryString, 'num': num, start: startNum, sortField: sort, sortOrder: order} )
    .then(function (results) {
      results.currentPage = page
      results.pages = Math.ceil(results.total / num)
      return results
    })
  },
  user: user,
  organization: organization,
  group: group,
  item: item,
  usage: usage
}

/**
 * Sets up a new arcgis client
 * @param {Object} Auth object with token, domain, username and password. Use as needed.
 * @returns {Object} Object with methods for necessary routes
 */
let client = ({token = "", domain = "www.arcgis.com", username = null, password = <PASSWORD>, enterpriseCreditials = false} = {}) => {
  var arcgis = Object.create(Client)
  console.log(token)
  /* Automatically add client id, base url */
  /**
   * Sets ups base request to ArcGIS
   * @param {String} URL to append to root URL
   * @param {Object} Options to pass as query parameters
   * @returns {Promise} On resolution will return results
   */
  arcgis.request = (url = '/', form = {}, post, rootUrl = `https://${domain}/sharing/rest/`) => {
    if (!form.public){
      form.token = token
    }
    form.f     = 'pjson'
    if (post) {
      return rq.post(`${rootUrl}${url}`, form)
    } else {
      return rq.get(`${rootUrl}${url}`, form)
    }
  }
  return arcgis
}

module.exports = client<commit_msg>optional callback for reqeust<commit_after>/**
 * Wrapper for arcgis api
 */
var rq = require('./request/index')
var uniq = require('./lib/uniq')

import user from './user/index'
import organization from './org/index'
import group from './group/index'
import item from './item/index'
import usage from './usage/index'

var Client = {
  search: function (queryString = '\"\"', num = 100, page = 0, sort = 'created', order = 'desc') {
    var startNum = num * page + 1
    return this.request(`search`, {'q': queryString, 'num': num, start: startNum, sortField: sort, sortOrder: order} )
    .then(function (results) {
      results.currentPage = page
      results.pages = Math.ceil(results.total / num)
      return results
    })
  },
  user: user,
  organization: organization,
  group: group,
  item: item,
  usage: usage
}

/**
 * Sets up a new arcgis client
 * @param {Object} Auth object with token, domain, username and password. Use as needed.
 * @returns {Object} Object with methods for necessary routes
 */
let client = ({token = "", domain = "www.arcgis.com", username = null, password = <PASSWORD>, enterpriseCreditials = false} = {}) => {
  var arcgis = Object.create(Client)
  console.log(token)
  /* Automatically add client id, base url */
  /**
   * Sets ups base request to ArcGIS
   * @param {String} URL to append to root URL
   * @param {Object} Options to pass as query parameters
   * @returns {Promise} On resolution will return results
   */
  arcgis.request = ({url = '/', form = {}, post = false, rootUrl = `https://${domain}/sharing/rest/` } = {}, cb) => {
    if (!form.public){
      form.token = token
    }
    form.f     = 'pjson'
    cb ? console.log(cb) : console.log('return promise')
    if (cb) {
      if (post) {
        rq.post(`${rootUrl}${url}`, form).then(cb)
      } else {
        rq.get(`${rootUrl}${url}`, form).then(cb)
      }
    }
    if (post) {
      return rq.post(`${rootUrl}${url}`, form)
    } else {
      return rq.get(`${rootUrl}${url}`, form)
    }
  }
  return arcgis
}

module.exports = client
{'fraction_non_alphanumeric': 0.15876715876715877, 'fraction_numerical': 0.00259000259000259, 'mean_word_length': 3.02711157455683, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '705978', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1217, 'n_words': 381}