<commit_before>//     Backbone.Model File Upload v0.1
//     by <NAME> - <EMAIL>
//     For all details and documentation:
//     https://github.com/homeslicesolutions/backbone-model-file-upload

(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['underscore', 'backbone'], factory);
    } else {
        // Browser globals
        factory(_, Backbone);
    }
}(this, function(_, Backbone){

  // Clone the original Backbone.Model.prototype
  var backboneModelClone = _.clone( Backbone.Model.prototype );

  // Extending out
  _.extend(Backbone.Model.prototype, {

    // ! Default file attribute - can be overwritten
    fileAttribute: 'file',

    // @ Save - overwritten
    save: function(key, val, options) {

      // Variables
      var attrs, attributes = this.attributes;

      // Signature parsing - taken directly from original Backbone.Model.save
      // and it states: 'Handle both "key", value and {key: value} -style arguments.'
      if (key == null || typeof key === 'object') {
        attrs = key;
        options = val;
      } else {
        (attrs = {})[key] = val;
      }

      // Validate & wait options - taken directly from original Backbone.Model.save
      options = _.extend({validate: true}, options);
      if (attrs && !options.wait) {
        if (!this.set(attrs, options)) return false;
      } else {
        if (!this._validate(attrs, options)) return false;
      }
      if (attrs && options.wait) {
        this.attributes = _.extend({}, attributes, attrs);
      }

      // Check for "formData" flag and check for if file exist.
      if ( options.formData === true
           || options.formData !== false
              && this.attributes[ this.fileAttribute ]
              && this.attributes[ this.fileAttribute ] instanceof File ) {

        // Flatten Attributes reapplying File Object
        var formAttrs = _.clone( this.attributes ),
            fileAttr = this.attributes[ this.fileAttribute ];<commit_msg>Added "attrs" fix and new just "options" feature<commit_after>//     Backbone.Model File Upload v0.3
//     by <NAME> - <EMAIL>
//     For all details and documentation:
//     https://github.com/homeslicesolutions/backbone-model-file-upload
//     Contributors:
//       lutherism - <NAME> - alex.openrobot.net
//       bildja - <NAME> - github.com/bildja

(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['underscore', 'backbone'], factory);
    } else {
        // Browser globals
        factory(_, Backbone);
    }
}(this, function(_, Backbone){

  // Clone the original Backbone.Model.prototype
  var backboneModelClone = _.clone( Backbone.Model.prototype );

  // Extending out
  _.extend(Backbone.Model.prototype, {

    // ! Default file attribute - can be overwritten
    fileAttribute: 'file',

    // @ Save - overwritten
    save: function(key, val, options) {

      // Variables
      var attrs, attributes = this.attributes;

      // Signature parsing - similar to original Backbone.Model.save
      // Handle (key, value, options), ({key: value}, options), and (options) -style arguments.
      if (typeof key === 'object') {
        if (typeof val === void 0) {
          attrs = attributes;
          options = key;
        } else {
          attrs = key;
          options = val;
        }
      } else {
        (attrs = {})[key] = val;
      }

      // Validate & wait options - taken directly from original Backbone.Model.save
      options = _.extend({validate: true}, options);
      if (attrs && !options.wait) {
        if (!this.set(attrs, options)) return false;
      } else {
        if (!this._validate(attrs, options)) return false;
      }
      if (attrs && options.wait) {
        this.attributes = _.extend({}, attributes, attrs);
      }

      // Check for "formData" flag and check for if file exist.
      if ( options.formData === true 
           || options.formData !== false 
              && attrs[ this.fileAttribute ] 
              && attrs[ this.fileAttribute ] instanceof File ) {
        
        // Flatten Attributes reapplying File Object
        var formAttrs = _.clone( attrs ),
            fileAttr = attrs[ this.fileAttribute ];
{'fraction_non_alphanumeric': 0.13006445672191527, 'fraction_numerical': 0.0011510128913443832, 'mean_word_length': 2.176169590643275, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '3840404', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1194, 'n_words': 356}