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

var noop = function(){};

var modifiable = [
  'key'
, 'value'
, 'expires'
, 'maxAge'
, 'domain'
, 'path'
, 'secure'
, 'httpOnly'
, 'extensions'
];

var readOnly = [
  'hostOnly'
, 'creation'
, 'lastAccessed'
, 'pathIsDefault'
];


/**
 * HTTP Cookie
 * @param {String|Object} data can be a cookie header string or a json object
 * @param {Object} _cookie the underlying cookie
 */
var Cookie = function(data, _cookie) {
  var self = this;
  this._cookie = _cookie || new tc.Cookie();

  modifiable.map(function(attribute) {
    Object.defineProperty(self, attribute, {
    enumerable: true
    , get: function() {
        return self._cookie[attribute];
      }
    , set: function(val) {
        self._cookie[attribute] = val;
      }
    });
  });

  readOnly.map(function(attribute) {
    Object.defineProperty(self, attribute, {
      get: function(){
        return this._cookie[attribute];
      }
    , set: noop
    , enumerable: true
    });
  });

  this.set(data);
};

/**
 * Get cookie as a JSON object
 * @return {Object}
 */
Cookie.prototype.toJSON = function() {
  return {
    key: this.key
  , value: this.value
  , expires: this.expires
  , maxAge: this.maxAge
  , domain: this.domain
  , path: this.path
  , secure: this.secure
  , httpOnly: this.httpOnly
  , extensions: this.extensions
  };
};

/**
 * Get cookie as a set-cookie header string
 * @return {String}
 */
Cookie.prototype.get = function() {
  return this._cookie.toString();
};

/**<commit_msg>return cookie header not set-cookie header<commit_after>var tc = require('tough-cookie');

var noop = function(){};

var modifiable = [
  'key'
, 'value'
, 'expires'
, 'maxAge'
, 'domain'
, 'path'
, 'secure'
, 'httpOnly'
, 'extensions'
];

var readOnly = [
  'hostOnly'
, 'creation'
, 'lastAccessed'
, 'pathIsDefault'
];


/**
 * HTTP Cookie
 * @param {String|Object} data can be a cookie header string or a json object
 * @param {Object} _cookie the underlying cookie
 */
var Cookie = function(data, _cookie) {
  var self = this;
  this._cookie = _cookie || new tc.Cookie();

  modifiable.map(function(attribute) {
    Object.defineProperty(self, attribute, {
    enumerable: true
    , get: function() {
        return self._cookie[attribute];
      }
    , set: function(val) {
        self._cookie[attribute] = val;
      }
    });
  });

  readOnly.map(function(attribute) {
    Object.defineProperty(self, attribute, {
      get: function(){
        return this._cookie[attribute];
      }
    , set: noop
    , enumerable: true
    });
  });

  this.set(data);
};

/**
 * Get cookie as a JSON object
 * @return {Object}
 */
Cookie.prototype.toJSON = function() {
  return {
    key: this.key
  , value: this.value
  , expires: this.expires
  , maxAge: this.maxAge
  , domain: this.domain
  , path: this.path
  , secure: this.secure
  , httpOnly: this.httpOnly
  , extensions: this.extensions
  };
};

/**
 * Get cookie as a cookie header string
 * @return {String}
 */
Cookie.prototype.get = function() {
  return this._cookie.cookieString();
};

/**
{'fraction_non_alphanumeric': 0.15429497568881687, 'fraction_numerical': 0.0, 'mean_word_length': 3.0605263157894735, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6148136', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1024, 'n_words': 249}