<commit_before>/* global angular, console, Backbone, _, $ */

/// @title indx-staged
/// @author <NAME> <<EMAIL>>
/// @version 0.1

angular
	.module('indx')
	.factory('staged', function () {
		'use strict';

		var cloneAttributes = function (attributes) {
			var _attributes = {};
			_.each(attributes, function (v, k) {
				_attributes[k] = _.clone(v);
			});
			return _attributes;
		};

		var areAttributesDifferent = function (attribute1, attribute2) {
			if (typeof attribute1 !== 'object') { attribute1 = [attribute1]; }
			if (typeof attribute2 !== 'object') { attribute2 = [attribute2]; }
			return _.reduce(attribute1, function (memo, v, k) {
				return memo || v !== attribute2[k];
			}, attribute1.length !== attribute2.length)
		};
		var Staged = Backbone.Model.extend({
			initialize: function (attrs, options) {
				this.obj = options.obj;
				this.obj.on('change', this.reset, this)
				this.reset();
			},
			reset: function () {
				this.set(cloneAttributes(this.obj.attributes));
				return this;
			},
			hasChanged: function () {
				var that = this,
					keys = _.union(_.keys(this.attributes), _.keys(this.obj.attributes));
				console.log(keys)
				return _.reduce(keys, function (memo, key) {
					return memo || areAttributesDifferent(that.attributes[key], that.obj.attributes[key]);
				}, false);
			},
			commit: function () {
				this.obj.set(cloneAttributes(this.attributes));
				return this;
			},
			save: function () {
				return this.obj.save(cloneAttributes(this.attributes));
			}
		});
<commit_msg>removed comment<commit_after>/* global angular, console, Backbone, _, $ */

/// @title indx-staged
/// @author <NAME> <<EMAIL>>
/// @version 0.1

angular
	.module('indx')
	.factory('staged', function () {
		'use strict';

		var cloneAttributes = function (attributes) {
			var _attributes = {};
			_.each(attributes, function (v, k) {
				_attributes[k] = _.clone(v);
			});
			return _attributes;
		};

		var areAttributesDifferent = function (attribute1, attribute2) {
			if (typeof attribute1 !== 'object') { attribute1 = [attribute1]; }
			if (typeof attribute2 !== 'object') { attribute2 = [attribute2]; }
			return _.reduce(attribute1, function (memo, v, k) {
				return memo || v !== attribute2[k];
			}, attribute1.length !== attribute2.length)
		};
		var Staged = Backbone.Model.extend({
			initialize: function (attrs, options) {
				this.obj = options.obj;
				this.obj.on('change', this.reset, this)
				this.reset();
			},
			reset: function () {
				this.set(cloneAttributes(this.obj.attributes));
				return this;
			},
			hasChanged: function () {
				var that = this,
					keys = _.union(_.keys(this.attributes), _.keys(this.obj.attributes));
				return _.reduce(keys, function (memo, key) {
					return memo || areAttributesDifferent(that.attributes[key], that.obj.attributes[key]);
				}, false);
			},
			commit: function () {
				this.obj.set(cloneAttributes(this.attributes));
				return this;
			},
			save: function () {
				return this.obj.save(cloneAttributes(this.attributes));
			}
		});

{'fraction_non_alphanumeric': 0.168086500655308, 'fraction_numerical': 0.009174311926605505, 'mean_word_length': 3.3991354466858787, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3673065', 'n_tokens_mistral': 1143, 'n_tokens_neox': 950, 'n_words': 214}