<commit_before>import Ember from 'ember';

var NullReference, serialize;

var isPlainObject = function (o) {
  // This doesn't work for basic objects such as Object.create(null)
  return Object(o) === o && Object.getPrototypeOf(o) === Object.prototype;
};

var isCollaborativeList = function (object) {
  return object &&
    object.hasOwnProperty('insertAll') &&
    object.hasOwnProperty('pushAll') &&
    object.hasOwnProperty('removeRange');
};

var get = function () {
  if (Ember.isArray(arguments[0])) {
    return get.apply(this, arguments[0]);
  }

  var components = arguments;
  var cur = this;
  for (var i = 0; i < components.length; i++) {
    cur = cur._get(components[i]);
  }
  return cur;
};

var MapReference = function (model, parent, key, data) {
  this.model = model;
  this.parent = parent;
  this.key = key;
  this.data = data;
};

MapReference.isFor = function (data) {
  //return data instanceof gapi.drive.realtime.CollaborativeMap;
  return data &&
    data.hasOwnProperty('size') &&
    data.hasOwnProperty('keys') &&
    data.hasOwnProperty('values');
};

// this is used for debugging purposes to get a snapshot of the Google Drive data structure
MapReference.serialize = function (object) {
  var serialized = {};
  object.items().forEach(function (pair) {
    serialized[pair[0]] = serialize(pair[1]);
  });
  return serialized;
};

MapReference.prototype.path = function (key) {
  if (this.parent) {
    return this.parent.path(this.key) + (key ? '/' + key : '');
  } else {
    return key || '';
  }
};
<commit_msg>Added array issue-specific fix to reference.js<commit_after>import Ember from 'ember';

var NullReference, serialize;

var isPlainObject = function (o) {
  // This doesn't work for basic objects such as Object.create(null)
  return Object(o) === o && Object.getPrototypeOf(o) === Object.prototype;
};

var isCollaborativeList = function (object) {
  return object &&
    object.hasOwnProperty('insertAll') &&
    object.hasOwnProperty('pushAll') &&
    object.hasOwnProperty('removeRange');
};

var get = function () {
  if (Ember.isArray(arguments[0])) {
    return get.apply(this, arguments[0]);
  }

  var components = arguments;
  var cur = this;
  for (var i = 0; i < components.length; i++) {
    cur = cur._get(components[i]);
  }
  return cur;
};

var MapReference = function (model, parent, key, data) {
  this.model = model;
  this.parent = parent;
  this.key = key;
  this.data = data;
};

MapReference.isFor = function (data) {
  //return data instanceof gapi.drive.realtime.CollaborativeMap;
  return data &&
    data.hasOwnProperty('size') &&
    data.hasOwnProperty('keys') &&
    data.hasOwnProperty('values');
};

// this is used for debugging purposes to get a snapshot of the Google Drive data structure
MapReference.serialize = function (object) {
  var serialized = {};
  object.items().forEach(function (pair) {
    if (pair[1] instanceof Array) {
      // gapi returns array properties with non-writable elements, so we need to remap them as a temporary fix
      serialized[pair[0]] = serialize(pair[1]).map(function (item) { return item; });
    } else {
      serialized[pair[0]] = serialize(pair[1]);
    } 
  });
  return serialized;
};

MapReference.prototype.path = function (key) {
  if (this.parent) {
    return this.parent.path(this.key) + (key ? '/' + key : '');
  } else {
    return key || '';
  }
};

{'fraction_non_alphanumeric': 0.1487603305785124, 'fraction_numerical': 0.0038370720188902006, 'mean_word_length': 3.693905817174515, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5357836', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1067, 'n_words': 282}