<commit_before>
var _ = require('lodash');

var RecordSet = require('./RecordSet');
var util = require('../util');

/**
 * @param {Array} data A list of values
 * @returns {ResultSet} An object containing the data
 */
var ResultSet = function (data, stream) {
  this.data = [];
  this.setStream(stream);
  if(data) this.fromJSON(data);
};
util.extends(ResultSet, 'Container');

ResultSet.prototype.fromJSON = function (data) {
  var me = this;
  _.forEach(data, function(rawRecord) {
    me.data.push(new RecordSet(rawRecord, me.getStream()));
  });
  this.validate();
};

ResultSet.prototype.toJSON = function () {
  return this.data.map(function(r) {
    return r.toJSON();
  });
};

ResultSet.prototype.validate = function () {
  _.forEach(this.data, function(record) {
    record.validate();
  });
};

ResultSet.prototype.setStream = function (s) {
  this.stream = s;
  if(s && s.getServiceObject) {
    this.setServiceObject(s.getServiceObject());
  }
};

ResultSet.prototype.getStream = function () {
  return this.stream;
};


module.exports = ResultSet;<commit_msg>added get by index fn<commit_after>
var _ = require('lodash');

var RecordSet = require('./RecordSet');
var util = require('../util');

/**
 * @param {Array} data A list of values
 * @returns {ResultSet} An object containing the data
 */
var ResultSet = function (data, stream) {
  this.data = [];
  this.setStream(stream);
  if(data) this.fromJSON(data);
};
util.extends(ResultSet, 'Container');

ResultSet.prototype.fromJSON = function (data) {
  var me = this;
  _.forEach(data, function(rawRecord) {
    me.data.push(new RecordSet(rawRecord, me.getStream()));
  });
  this.validate();
};

ResultSet.prototype.toJSON = function () {
  return this.data.map(function(r) {
    return r.toJSON();
  });
};

ResultSet.prototype.validate = function () {
  _.forEach(this.data, function(record) {
    record.validate();
  });
};

ResultSet.prototype.setStream = function (s) {
  this.stream = s;
  if(s && s.getServiceObject) {
    this.setServiceObject(s.getServiceObject());
  }
};

ResultSet.prototype.getStream = function () {
  return this.stream;
};

ResultSet.prototype.get = function (idx) {
  return this.data[idx] || null;
};


module.exports = ResultSet;
{'fraction_non_alphanumeric': 0.1700984780662489, 'fraction_numerical': 0.0, 'mean_word_length': 4.091116173120729, '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': '5965878', 'n_tokens_mistral': 739, 'n_tokens_neox': 733, 'n_words': 151}