<commit_before>var fw = require('knockout/build/output/knockout-latest');
var _ = require('footwork-lodash');

var objectTools = require('./object-tools');
var regExpIsEqual = objectTools.regExpIsEqual;
var sortOfEqual = objectTools.sortOfEqual;

var makeOrGetRequest = require('../misc/ajax').makeOrGetRequest;
var privateDataSymbol = require('../misc/util').getSymbol('footwork');

function collectionSync () {
  return fw.sync.apply(this, arguments);
}

function get (id) {
  var collection = this;
  return _.find(collection(), function findModelWithId (model) {
    var found = _.result(model, collection[privateDataSymbol].getIdAttribute()) === id;
    if(fw.isDataModel(model) && !found) {
      found = model[privateDataSymbol].idAttributeObservable() === id;
    }
    return found;
  });
}

function getData () {
  var collection = this;
  var castAsModelData = collection[privateDataSymbol].castAs.modelData;
  return _.reduce(collection(), function (models, model) {
    models.push(castAsModelData(model));
    return models;
  }, []);
}

function toJSON () {
  return this.getData();
}

function pluck (attribute) {
  var collection = this;
  var castAsModelData = collection[privateDataSymbol].castAs.modelData;
  return _.reduce(collection(), function (pluckedValues, model) {
    pluckedValues.push(castAsModelData(model, attribute));
    return pluckedValues;
  }, []);
}<commit_msg>now relying on collection idAttribute configuration only<commit_after>var fw = require('knockout/build/output/knockout-latest');
var _ = require('footwork-lodash');

var objectTools = require('./object-tools');
var regExpIsEqual = objectTools.regExpIsEqual;
var sortOfEqual = objectTools.sortOfEqual;

var makeOrGetRequest = require('../misc/ajax').makeOrGetRequest;
var privateDataSymbol = require('../misc/util').getSymbol('footwork');

function collectionSync () {
  return fw.sync.apply(this, arguments);
}

function get (id) {
  var collection = this;
  return _.find(collection(), function findModelWithId (model) {
    return _.result(model, collection[privateDataSymbol].getIdAttribute()) === id;
  });
}

function getData () {
  var collection = this;
  var castAsModelData = collection[privateDataSymbol].castAs.modelData;
  return _.reduce(collection(), function (models, model) {
    models.push(castAsModelData(model));
    return models;
  }, []);
}

function toJSON () {
  return this.getData();
}

function pluck (attribute) {
  var collection = this;
  var castAsModelData = collection[privateDataSymbol].castAs.modelData;
  return _.reduce(collection(), function (pluckedValues, model) {
    pluckedValues.push(castAsModelData(model, attribute));
    return pluckedValues;
  }, []);
}
{'fraction_non_alphanumeric': 0.13984461709211987, 'fraction_numerical': 0.0, 'mean_word_length': 5.159453302961276, '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': '2751633', 'n_tokens_mistral': 806, 'n_tokens_neox': 797, 'n_words': 170}