<commit_before>
var SQLStatementsArray = Class.create({
    
    initialize: function () {
        
        this._sqlStmntsArray = new Array();
    },
    push: function (storageInstance, sql, arguments, statementCallback, errorCallback) {
        
        this._sqlStmntsArray.push(new Array(storageInstance, sql, (arguments.length > 0 ? arguments : null), statementCallback, errorCallback));
    },
    getArray: function () {
        
        return this._sqlStmntsArray;
    },
    getStatementByIndex: function (index) {
        
        return this._sqlStmntsArray[index];
    }
});

var StorageException = Class.create({
    
    initialize: function (message) {
        
        this._message = message;
        
        this.NOT_SUPPORTED = 'NOT_SUPPORTED';
    },
    getMessage: function () {
        
        return this._message;
    }
});



var ResultSet = Class.create({
    
    initialize: function (resultSet) {
        
        this._resultSet = resultSet;
    },
    getLastInsertId: function () {

        if (this._resultSet != null) {

            return this._resultSet.insertId;
        }
    },
    getRowCount: function () {

        if (this._resultSet != null) {

            return this._resultSet.rows.length;
        }
        
        return null;
    },
    getRow: function (index) {

        if (this.getRowCount() > 0) {
            
            return this._resultSet.rows.item(index);
        }
        
        return null;
    }
});

var Storage = Class.create({
    
    initialize: function (dbName, dbVersion, dbDisplayName, dbSize) {
        
        this._lastResultSet = null;
        this._isSuccess = false;
        
        this._DB = null;
        
        this._dbName = dbName;
        this._dbVersion = dbVersion;
        this._dbDisplayName = dbDisplayName;
        this._dbSize = dbSize;
        
        this._isConnected = false;
    },
    connect: function () {
        
        try {
            
            if (!window.openDatabase) {
                
                throw StorageException.NOT_SUPPORTED;
            } else {
                
                this._DB = window.openDatabase(this._dbName, this._dbVersion, this._dbDisplayName, this._dbSize);
                
                this._isConnected = true;
            }
        } catch(e) {
            
            switch (e) {
                case INVALID_STATE_ERR:
                    throw new StorageException('Invalid database version.');
                    break;
                case NOT_SUPPORTED:
                    throw new StorageException('openDatabase not supported');
                    break;
                default:
                    throw new StorageException('Unknown error '+e+'.');
            }
        }
        
        return true;
    },
    getConn: function () {
        
        return this._DB;
    },
    isConnected: function () {
        
        return this._isConnected;
    },
    transact: function (sqlStmntsArray) {
        
        var _sqls = sqlStmntsArray.getArray();
        
        this.setSuccess(false);
        
        this._DB.transaction(function (transaction) {
            
            eval("transaction.__proto__.storageInstance = _sqls[0][0]");
            
            var _js = "";
            
            for (var i = 0; i < _sqls.length; i++) {
                
                _js += "transaction.executeSql('"+_sqls[i][1]+"', "+(_sqls[i][2] === null ? null : "new Array('"+_sqls[i][2].join("','")+"')")+", "+_sqls[i][3]+', '+_sqls[i][4]+');';
            }
            
            eval(_js);
        });
    },
    getSuccess: function () {
        
        return this._isSuccess;
    },
    setSuccess: function (isSuccess) {
        
        this._isSuccess = isSuccess;
    },
    setResultSet: function (resultSet) {
        
        this._lastResultSet = new ResultSet(resultSet);
    },
    getResultSet: function () {
        
        return this._lastResultSet;
    }
});



function _statementCallback(transaction, resultSet) {
    
    var _db = transaction.storageInstance;
    
    _db.setResultSet(resultSet);
    
    if (resultSet.rows.length > 0)
        _db.setSuccess(true);
}

function _nullHandler() {
    
}

function _successHandler() {
    
    console.log('Successful statement!');
}<commit_msg>Renamed foreign object as transaction prototype<commit_after>
var SQLStatementsArray = Class.create({
    
    initialize: function () {
        
        this._sqlStmntsArray = new Array();
    },
    push: function (storageInstance, sql, arguments, statementCallback, errorCallback) {
        
        this._sqlStmntsArray.push(new Array(storageInstance, sql, (arguments.length > 0 ? arguments : null), statementCallback, errorCallback));
    },
    getArray: function () {
        
        return this._sqlStmntsArray;
    },
    getStatementByIndex: function (index) {
        
        return this._sqlStmntsArray[index];
    }
});

var StorageException = Class.create({
    
    initialize: function (message) {
        
        this._message = message;
        
        this.NOT_SUPPORTED = 'NOT_SUPPORTED';
    },
    getMessage: function () {
        
        return this._message;
    }
});



var ResultSet = Class.create({
    
    initialize: function (resultSet) {
        
        this._resultSet = resultSet;
    },
    getLastInsertId: function () {

        if (this._resultSet != null) {

            return this._resultSet.insertId;
        }
    },
    getRowCount: function () {

        if (this._resultSet != null) {

            return this._resultSet.rows.length;
        }
        
        return null;
    },
    getRow: function (index) {

        if (this.getRowCount() > 0) {
            
            return this._resultSet.rows.item(index);
        }
        
        return null;
    }
});

var Storage = Class.create({
    
    initialize: function (dbName, dbVersion, dbDisplayName, dbSize) {
        
        this._lastResultSet = null;
        this._isSuccess = false;
        
        this._DB = null;
        
        this._dbName = dbName;
        this._dbVersion = dbVersion;
        this._dbDisplayName = dbDisplayName;
        this._dbSize = dbSize;
        
        this._isConnected = false;
    },
    connect: function () {
        
        try {
            
            if (!window.openDatabase) {
                
                throw StorageException.NOT_SUPPORTED;
            } else {
                
                this._DB = window.openDatabase(this._dbName, this._dbVersion, this._dbDisplayName, this._dbSize);
                
                this._isConnected = true;
            }
        } catch(e) {
            
            switch (e) {
                case INVALID_STATE_ERR:
                    throw new StorageException('Invalid database version.');
                    break;
                case NOT_SUPPORTED:
                    throw new StorageException('openDatabase not supported');
                    break;
                default:
                    throw new StorageException('Unknown error '+e+'.');
            }
        }
        
        return true;
    },
    getConn: function () {
        
        return this._DB;
    },
    isConnected: function () {
        
        return this._isConnected;
    },
    transact: function (sqlStmntsArray) {
        
        var _sqls = sqlStmntsArray.getArray();
        
        this.setSuccess(false);
        
        this._DB.transaction(function (transaction) {
            
            eval("transaction.__proto__.objInstance = _sqls[0][0]");
            
            var _js = "";
            
            for (var i = 0; i < _sqls.length; i++) {
                
                _js += "transaction.executeSql('"+_sqls[i][1]+"', "+(_sqls[i][2] === null ? null : "new Array('"+_sqls[i][2].join("','")+"')")+", "+_sqls[i][3]+', '+_sqls[i][4]+');';
            }
            
            eval(_js);
        });
    },
    getSuccess: function () {
        
        return this._isSuccess;
    },
    setSuccess: function (isSuccess) {
        
        this._isSuccess = isSuccess;
    },
    setResultSet: function (resultSet) {
        
        this._lastResultSet = new ResultSet(resultSet);
    },
    getResultSet: function () {
        
        return this._lastResultSet;
    }
});



function _statementCallback(transaction, resultSet) {
    
    var _db = transaction.objInstance;
    
    _db.setResultSet(resultSet);
    
    if (resultSet.rows.length > 0)
        _db.setSuccess(true);
}

function _nullHandler() {
    
}

function _successHandler() {
    
    console.log('Successful statement!');
}
{'fraction_non_alphanumeric': 0.11270207852193996, 'fraction_numerical': 0.002540415704387991, 'mean_word_length': 1.5503533568904593, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6603544', 'n_tokens_mistral': 2442, 'n_tokens_neox': 2379, 'n_words': 451}