<commit_before>(function() {
  'use strict';

  function FuryModel(pk) {
    this._remoteData = null;
    this._eventQueue = {
      'loaded': [],
      'created': [],
      'deleted': []
    };
    this._filteredProperties = [
      '_pk',
      '_remoteData',
      '_eventQueue',
      '_filteredProperties',
      '_init',
      '_load',
      '_create',
      '_update',
      '_delete',
      '_process',
      '_unprocess',
      '$exists',
      '$load',
      '$reset',
      '$save',
      '$delete',
      '$raw',
      '$once'
    ];

    if (typeof pk === 'undefined') {
      this._pk = null;
    }
    else {
      this._pk = pk;
    }

    if (this._pk === null) {
      this._init();
    }
    else {
      this.$load();
    }
  }
  FuryModel.prototype._init = function() {
    // may inherit
    // responsability: define default values
  };
  FuryModel.prototype._load = function() {
    // to inherit
    // should return a promise with raw data resolved
  };
  FuryModel.prototype._create = function(data) {
    // to inherit
    // should return a promise with the primary key and created raw data as resolved values
  };
  FuryModel.prototype._update = function(data) {
    // to inherit
    // should return a promise
  };
  FuryModel.prototype._delete = function() {
    // to inherit
    // should return a promise
  };
  FuryModel.prototype._process = function(data) {
    // may inherit
    // convert some raw values to something else
    // return processed datas

    return data;
  };
  FuryModel.prototype._unprocess = function(object) {
    // may inherit
    // should return a raw object

    return object;
  };

  FuryModel.prototype.$exists = function() {
    return this._pk !== null;
  };

  FuryModel.prototype.$load = function() {
    var self = this;
    if (this._remoteData !== null) {
      return when.resolve(this);
    }
    else {
      return this.
      _load()
      .then(function(raw) {
        self._remoteData = raw;

        _setProperties(self, self._process(raw));
        return _callEventsOnce(self._eventQueue, 'loaded', self);
      });
    }
  };

  FuryModel.prototype.$reset = function() {
    Object.keys(this)
    .filter(function(prop) {
      return this._filteredProperties.indexOf(prop) === -1;
    }, this)
    .forEach(function(prop) {
      if (typeof this._remoteObject[prop] === 'undefined') {
        delete this[prop];
      }
      else {
        this[prop] = this._remoteObject[prop]; // @todo deep copy
      }
    }, this);
  };

  FuryModel.prototype.$save = function(data) {
    var self = this;
    if (!this.$exists()) {
      return this<commit_msg>fix: allow $reset on an inexistant instance<commit_after>(function() {
  'use strict';

  function FuryModel(pk) {
    this._remoteData = null;
    this._eventQueue = {
      'loaded': [],
      'created': [],
      'deleted': []
    };
    this._filteredProperties = [
      '_pk',
      '_remoteData',
      '_eventQueue',
      '_filteredProperties',
      '_init',
      '_load',
      '_create',
      '_update',
      '_delete',
      '_process',
      '_unprocess',
      '$exists',
      '$load',
      '$reset',
      '$save',
      '$delete',
      '$raw',
      '$once'
    ];

    if (typeof pk === 'undefined') {
      this._pk = null;
    }
    else {
      this._pk = pk;
    }

    if (this._pk === null) {
      this._init();
    }
    else {
      this.$load();
    }
  }
  FuryModel.prototype._init = function() {
    // may inherit
    // responsability: define default values
  };
  FuryModel.prototype._load = function() {
    // to inherit
    // should return a promise with raw data resolved
  };
  FuryModel.prototype._create = function(data) {
    // to inherit
    // should return a promise with the primary key and created raw data as resolved values
  };
  FuryModel.prototype._update = function(data) {
    // to inherit
    // should return a promise
  };
  FuryModel.prototype._delete = function() {
    // to inherit
    // should return a promise
  };
  FuryModel.prototype._process = function(data) {
    // may inherit
    // convert some raw values to something else
    // return processed datas

    return data;
  };
  FuryModel.prototype._unprocess = function(object) {
    // may inherit
    // should return a raw object

    return object;
  };

  FuryModel.prototype.$exists = function() {
    return this._pk !== null;
  };

  FuryModel.prototype.$load = function() {
    var self = this;
    if (this._remoteData !== null) {
      return when.resolve(this);
    }
    else {
      return this.
      _load()
      .then(function(raw) {
        self._remoteData = raw;

        _setProperties(self, self._process(raw));
        return _callEventsOnce(self._eventQueue, 'loaded', self);
      });
    }
  };

  FuryModel.prototype.$reset = function() {
    Object.keys(this)
    .filter(function(prop) {
      return this._filteredProperties.indexOf(prop) === -1;
    }, this)
    .forEach(function(prop) {
      if (!this._remoteObject || typeof this._remoteObject[prop] === 'undefined') {
        delete this[prop];
      }
      else {
        this[prop] = this._remoteObject[prop]; // @todo deep copy
      }
    }, this);
  };

  FuryModel.prototype.$save = function(data) {
    var self = this;
    if (!this.$exists()) {
      return this
{'fraction_non_alphanumeric': 0.14331269930594634, 'fraction_numerical': 0.00037516413430876007, 'mean_word_length': 2.132784958871915, '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': '5476391', 'n_tokens_mistral': 1622, 'n_tokens_neox': 1594, 'n_words': 378}