<commit_before>var FrameSheetModel = (function() {
    
    var inst;
    var frames = [];
    var width;
    var height;

    var createEmptyFrame_ = function() {
    	var emptyFrame = new Array(width);
		for (var columnIndex=0; columnIndex < width; columnIndex++) {
			emptyFrame[columnIndex] = new Array(height);
    	}
        return emptyFrame;
    };

	return {
		validate: function() {
			return true; // I'm always right dude
		},

		getAllPixels : function () {
			var pixels = [];
			for (var i = 0 ; i < frames.length ; i++) {
				pixels = pixels.concat(this._getFramePixels(frames[i]));
			}
			return pixels;
		},

		_getFramePixels : function (frame) {
			var pixels = [];
			for (var i = 0 ; i < frame.length ; i++) {
				var line = frame[i];
				for (var j = 0 ; j < line.length ; j++) {
					pixels.push(line[j]);
				}
			}
			return pixels;
		},

		// Could be used to pass around model using long GET param (good enough for simple models) and 
		// do some temporary locastorage
		serialize: function() {
			return JSON.stringify(frames);
		},

		/**
		 * Load a framesheet from a string that might have been persisted in db / localstorage
		 * Overrides existing frames.
		 * @param {String} serialized
		 */
		deserialize : function (serialized) {
			try {
				frames = JSON.parse(serialized);
			} catch (e) {
				throw "Could not load serialized framesheet." + e.message()
			}	
		},
		
		addEmptyFrame: function() {
			frames.push(createEmptyFrame_());
		},

		getFrameCount: function() {
			return frames.length;
		},

		getFrameByIndex: function(index) {
			if (isNaN(index)) {
				throw "Bad argument value for getFrameByIndex method: <" + index + ">"
			} else if (index < 0 || index > frames.length) {
				throw "Out of bound index for frameSheet object."
			}

			return frames[index];
		},

		removeFrameByIndex: function(index) {
		  if(index < 0 || index > inst.getFrameCount()) {
		  	throw "Bad index value for removeFrameByIndex.";
		  }
		  frames.splice(index, 1);
		},

		duplicateFrameByIndex: function(frameToDuplicateIndex) {
			var frame = inst.getFrameByIndex(frameToDuplicateIndex);
			var clonedFrame = [];
			for(var i=0, l=frame.length; i<l; i++) {
				clonedFrame.push(frame[i].slice(0));
			}
			frames.splice(frameToDuplicateIndex + 1, 0, clonedFrame);
		},
        
		getInstance: function(width_, height_) {
			
			if (isNaN(width_) || isNaN(height_)) {
				throw "Bad FrameSheetModel initialization in getInstance method.";
			}

			inst = this;

			width = width_;
			height = height_;

			return inst;
		}
	}
})();<commit_msg>Update js/frameSheetModel.js<commit_after>var FrameSheetModel = (function() {
    
    var inst;
    var frames = [];
    var width;
    var height;

    var createEmptyFrame_ = function() {
    	var emptyFrame = new Array(width);
		for (var columnIndex=0; columnIndex < width; columnIndex++) {
			emptyFrame[columnIndex] = new Array(height);
    	}
        return emptyFrame;
    };

	return {
		validate: function() {
			return true; // I'm always right dude
		},

		getAllPixels : function () {
			var pixels = [];
			for (var i = 0 ; i < frames.length ; i++) {
				pixels = pixels.concat(this._getFramePixels(frames[i]));
			}
			return pixels;
		},

		_getFramePixels : function (frame) {
			var pixels = [];
			for (var i = 0 ; i < frame.length ; i++) {
				var line = frame[i];
				for (var j = 0 ; j < line.length ; j++) {
					pixels.push(line[j]);
				}
			}
			return pixels;
		},

		// Could be used to pass around model using long GET param (good enough for simple models) and 
		// do some temporary locastorage
		serialize: function() {
			return JSON.stringify(frames);
		},

		/**
		 * Load a framesheet from a string that might have been persisted in db / localstorage
		 * Overrides existing frames.
		 * @param {String} serialized
		 */
		deserialize : function (serialized) {
			try {
				frames = JSON.parse(serialized);
			} catch (e) {
				throw "Could not load serialized framesheet." + e.message
			}	
		},
		
		addEmptyFrame: function() {
			frames.push(createEmptyFrame_());
		},

		getFrameCount: function() {
			return frames.length;
		},

		getFrameByIndex: function(index) {
			if (isNaN(index)) {
				throw "Bad argument value for getFrameByIndex method: <" + index + ">"
			} else if (index < 0 || index > frames.length) {
				throw "Out of bound index for frameSheet object."
			}

			return frames[index];
		},

		removeFrameByIndex: function(index) {
		  if(index < 0 || index > inst.getFrameCount()) {
		  	throw "Bad index value for removeFrameByIndex.";
		  }
		  frames.splice(index, 1);
		},

		duplicateFrameByIndex: function(frameToDuplicateIndex) {
			var frame = inst.getFrameByIndex(frameToDuplicateIndex);
			var clonedFrame = [];
			for(var i=0, l=frame.length; i<l; i++) {
				clonedFrame.push(frame[i].slice(0));
			}
			frames.splice(frameToDuplicateIndex + 1, 0, clonedFrame);
		},
        
		getInstance: function(width_, height_) {
			
			if (isNaN(width_) || isNaN(height_)) {
				throw "Bad FrameSheetModel initialization in getInstance method.";
			}

			inst = this;

			width = width_;
			height = height_;

			return inst;
		}
	}
})();
{'fraction_non_alphanumeric': 0.1312994786638347, 'fraction_numerical': 0.004247924309712299, 'mean_word_length': 2.8830584707646176, 'pattern_counts': {'":': 0, '<': 19, '<?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': '3474979', 'n_tokens_mistral': 1963, 'n_tokens_neox': 1624, 'n_words': 451}