<commit_before>define(["jquery", "./utils"], function($, utils) {
    "use strict";
    
    function ArrayDataSource(data, delay) {
        this.data = data;
        if(delay) {
            setTimeout(this.load.bind(this), delay);
        } else {
            this.load();
        }
    }
    
    ArrayDataSource.prototype = {
        load: function(data) {
            if(data !== undefined) {
              this.data = data;
            }

            $(this).trigger("dataloaded");
            for(var x = 0, l = this.data.length;x<l;x++) {
                if(this.data[x].id === undefined) {
                    this.data[x].id = x;
                }
            }

            this.ready = true;
        },
        
        recordCount: function() {
            this.assertReady();
            return this.data.length;
        },

        getRowByIndex: function(idx) {
            this.assertReady();
            return this.data[idx];
        },

        getRecordById: function(id) {
            this.assertReady();
            for(var x=0,l=this.data.length; x<l; x++) {
                if(this.data[x].id == id) return this.data[x];
            }
        },

        getData: function(start, end) {
            this.assertReady();
            if(!start && !end) return this.data;
            if(!start) start = 0;
            if(!end) end = this.recordCount();
            return this.data.slice(start, end);<commit_msg>Update arraydatasource.js<commit_after>define(["jquery", "./utils"], function($, utils) {
    "use strict";
    
    function ArrayDataSource(data, delay) {
        this.data = data;
        if(delay) {
            setTimeout(this.load.bind(this), delay);
        } else {
            this.load();
        }
    }
    
    ArrayDataSource.prototype = {
        load: function(data) {
            if(data !== undefined) {
              this.data = data;
            }

            for(var x = 0, l = this.data.length;x<l;x++) {
                if(this.data[x].id === undefined) {
                    this.data[x].id = x;
                }
            }

            $(this).trigger("dataloaded");
            this.ready = true;
        },
        
        recordCount: function() {
            this.assertReady();
            return this.data.length;
        },

        getRowByIndex: function(idx) {
            this.assertReady();
            return this.data[idx];
        },

        getRecordById: function(id) {
            this.assertReady();
            for(var x=0,l=this.data.length; x<l; x++) {
                if(this.data[x].id == id) return this.data[x];
            }
        },

        getData: function(start, end) {
            this.assertReady();
            if(!start && !end) return this.data;
            if(!start) start = 0;
            if(!end) end = this.recordCount();
            return this.data.slice(start, end);
{'fraction_non_alphanumeric': 0.1456884561891516, 'fraction_numerical': 0.002086230876216968, 'mean_word_length': 1.3601312551271534, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1270503', 'n_tokens_mistral': 837, 'n_tokens_neox': 817, 'n_words': 146}