<commit_before>var url = require('url');
var tc = require('tough-cookie');

/**
 * Get the domain given a url
 * @param  {String} urlString
 * @return {String} domain
 */
function getDomainFromUrl(urlString) {
  return url.parse(urlString).hostname;
};


/**
 * Holds cookies
 * @param {Object} _jar the underlying cookie jar
 */
var CookieJar = function(_jar) {
  this._jar = jar || new tc.CookieJar();
};

/**
 * Add a cookie to the cookie jar
 * @param {String|Object} data can be a Cookie|json object or a set-cookie header string
 * @param {String} domain
 * @param {Function} callback(error) [optional]
 */
CookieJar.prototype.add = function(data, domain, callback) {
  if (data instanceof Cookie)
    this._jar.setCookie(data._cookie, callback);
  else if (typeof data === 'object' || typeof cookie === 'string')
    this._jar.setCookie(new Cookie(data)._cookie);
  else
    if (callback) callback(new Error('invalid data parameter'))
};

/**
 * Remove a cookie by name for a given domain
 * @param  {String} name
 * @param  {String} domain
 */
CookieJar.prototype.remove = function(name, domain) {

};

/**
 * Get cookies that match the given properties
 * @param  {object} props
 * @return {Array} Cookie objects
 */
CookieJar.prototype.getCookies = function(props) {
  // get tough cookies, wrap w/Cookie, return array of Cookie objects
  return [];
};

module.exports.CookieJar = CookieJar;<commit_msg>Remove unnecessary callbacks and params<commit_after>var tc = require('tough-cookie');
var Cookie = require('./cookie');

var noop = function(){};


/**
 * Holds cookies
 */
var CookieJar = function() {
  this._jar = new tc.CookieJar(new tc.MemoryCookieStore());
};

/**
 * Add a cookie to the cookie jar
 * @param {String|Object} data can be a Cookie|json object or a set-cookie
 *                        header string
 * @param {String} url
 * @param {Object} [options]
 */
CookieJar.prototype.add = function(data, url, options) {

  if (data instanceof Cookie) {
    this._jar.setCookie(data._cookie, url, options, noop);
  } else if (typeof data === 'object' || typeof cookie === 'string') {
    this._jar.setCookie(new Cookie(data)._cookie);
  }
};

/**
 * Remove a cookie by name for a given domain. If the key or path is null then
 * all cookies for the given domain and path (if given) will be removed. Note:
 * when cookies are added without a path specified the default path is "/" in
 * accordance with http://tools.ietf.org/search/rfc6265#section-5.1.4 - so you
 * should use that for the path param when appropriate.
 * @param  {String} domain
 * @param  {String} path
 * @param  {String} key
 */
CookieJar.prototype.remove = function(domain, path, key) {

  if (key == null || path == null) {
    this._jar.store.removeCookies(domain, path, noop);
  } else {
    this._jar.store.removeCookie(domain, path, key, noop);
  }
};

/**
 * Get cookies that match the given properties
 * @param  {String} url
 * @param  {Object} [options]
 * @param  {Function} callback
 */
CookieJar.prototype.getCookies = function(url, options, callback) {
  if (typeof options === 'function') {
    callback = options;
    options = {};
  }
  // get tough cookies, wrap w/Cookie, return array of Cookie objects
  this._jar.getCookies(url, options, function(error, tcCookies) {
    if (error) return callback(error);

    var cookies = [];
    for (var i=0, len = tcCookies.length; i<len; i++) {
      cookies.push(new Cookie(tcCookies[i]));
    }

    return callback(null, cookies);
  });
};


/**
 * Get HTTP Cookie header string
 * @param  {String}   url
 * @param  {Object} [options]
 * @param  {Function} callback
 */
CookieJar.prototype.getCookieHeaderString = function(url, options, callback) {
  if (typeof options === 'function') {
    callback = options;
    options = {};
  }
  return this._jar.getCookieString(url, options, callback);
};

/**
 * Get cookie jar as a JSON object
 * @return {Object}
 */
CookieJar.prototype.toJSON = function() {
  return this._jar.store.idx;
};

module.exports.CookieJar = CookieJar;
{'fraction_non_alphanumeric': 0.140625, 'fraction_numerical': 0.001984126984126984, 'mean_word_length': 3.6516724336793542, 'pattern_counts': {'":': 0, '<': 4, '<?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': '870078', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1244, 'n_words': 395}