<commit_before>﻿(function () {
  "use strict";

  var Statement, Database;

  // Alternative typeof implementation yielding more meaningful results,
  // see http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
  function type(obj) {
    var typeString;

    typeString = Object.prototype.toString.call(obj);
    return typeString.substring(8, typeString.length - 1).toLowerCase();
  }

  function throwSQLiteError(message, comException) {
    var error = new Error(message);
    error.resultCode = comException.number & 0xffff;
    throw error;
  }

  Statement = WinJS.Class.define(function (db, sql, args) {
    try {
      this.statement = db.connection.prepare(sql);
    } catch (comException) {
      throwSQLiteError('Error preparing an SQLite statement.', comException);
    }

    if (args) {
      this.bind(args);
    }
  }, {
    bind: function (args) {
      var index, resultCode;

      args.forEach(function (arg, i) {
        index = i + 1;
        switch (type(arg)) {
          case 'number':
            if (arg % 1 === 0) {
              resultCode = this.statement.bindInt(index, arg);
            } else {
              resultCode = this.statement.bindDouble(index, arg);
            }
            break;
          case 'string':
            resultCode = this.statement.bindText(index, arg);
            break;
          case 'null':
            resultCode = this.statement.bindNull(index);
            break;
          default:
            throw new Error("Unsupported argument type: " + type(arg));
        }
        if (resultCode !== SQLite3.ResultCode.ok) {
          throw new Error("Error " + resultCode + " when binding argument to SQL query.");
        }
      }, this);
    },
    run: function () {
      this.statement.step();
    },
    all: function () {
      var result = [];

      this.each(function (row) {
        result.push(row);
      });
      return result;
    },
    each: function (callback) {
      var row, i, len, name;

      while (this.statement.step() === SQLite3.ResultCode.row) {
        row = {};
        for (i = 0, len = this.statement.columnCount() ; i < len; i += 1) {
          name = this.statement.columnName(i);
          switch (this.statement.columnType(i)) {
            case SQLite3.Datatype.integer:
              row[name] = this.statement.columnInt(i);
              break;
            case SQLite3.Datatype.float:
              row[name] = this.statement.columnDouble(i);
              break;
            case SQLite3.Datatype.text:
              row[name] = this.statement.columnText(i);
              break;
            case SQLite3.Datatype["null"]:
              row[name] = null;
              break;
          }
        }
        callback(row);
      }
    },
    close: function () {
      this.statement.close();
    }
  });

  Database = WinJS.Class.define(function (dbPath) {
    try {
      this.connection = SQLite3.Database(dbPath);
    } catch (comException) {
      throwSQLiteError('Error creating an SQLite database connection.', comException);
    }
  }, {
    run: function (sql, args) {
      var statement = new Statement(this, sql, args);

      statement.run();
      statement.close();
    },
    all: function (sql, args) {
      var rows, statement = new Statement(this, sql, args);

      rows = statement.all();
      statement.close();
      return rows;
    },
    each: function (sql, args, callback) {
      if (!callback && type(args) === 'function') {
        callback = args;
        args = null;
      }

      var statement = new Statement(this, sql, args);

      statement.each(callback);
      statement.close();
    },
    close: function () {
      this.connection.close();
    }
});

WinJS.Namespace.define('SQLite3JS', {
  Database: Database
});

}());<commit_msg>Fix indentation<commit_after>﻿(function () {
  "use strict";

  var Statement, Database;

  // Alternative typeof implementation yielding more meaningful results,
  // see http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
  function type(obj) {
    var typeString;

    typeString = Object.prototype.toString.call(obj);
    return typeString.substring(8, typeString.length - 1).toLowerCase();
  }

  function throwSQLiteError(message, comException) {
    var error = new Error(message);
    error.resultCode = comException.number & 0xffff;
    throw error;
  }

  Statement = WinJS.Class.define(function (db, sql, args) {
    try {
      this.statement = db.connection.prepare(sql);
    } catch (comException) {
      throwSQLiteError('Error preparing an SQLite statement.', comException);
    }

    if (args) {
      this.bind(args);
    }
  }, {
    bind: function (args) {
      var index, resultCode;

      args.forEach(function (arg, i) {
        index = i + 1;
        switch (type(arg)) {
          case 'number':
            if (arg % 1 === 0) {
              resultCode = this.statement.bindInt(index, arg);
            } else {
              resultCode = this.statement.bindDouble(index, arg);
            }
            break;
          case 'string':
            resultCode = this.statement.bindText(index, arg);
            break;
          case 'null':
            resultCode = this.statement.bindNull(index);
            break;
          default:
            throw new Error("Unsupported argument type: " + type(arg));
        }
        if (resultCode !== SQLite3.ResultCode.ok) {
          throw new Error("Error " + resultCode + " when binding argument to SQL query.");
        }
      }, this);
    },
    run: function () {
      this.statement.step();
    },
    all: function () {
      var result = [];

      this.each(function (row) {
        result.push(row);
      });
      return result;
    },
    each: function (callback) {
      var row, i, len, name;

      while (this.statement.step() === SQLite3.ResultCode.row) {
        row = {};
        for (i = 0, len = this.statement.columnCount() ; i < len; i += 1) {
          name = this.statement.columnName(i);
          switch (this.statement.columnType(i)) {
            case SQLite3.Datatype.integer:
              row[name] = this.statement.columnInt(i);
              break;
            case SQLite3.Datatype.float:
              row[name] = this.statement.columnDouble(i);
              break;
            case SQLite3.Datatype.text:
              row[name] = this.statement.columnText(i);
              break;
            case SQLite3.Datatype["null"]:
              row[name] = null;
              break;
          }
        }
        callback(row);
      }
    },
    close: function () {
      this.statement.close();
    }
  });

  Database = WinJS.Class.define(function (dbPath) {
    try {
      this.connection = SQLite3.Database(dbPath);
    } catch (comException) {
      throwSQLiteError('Error creating an SQLite database connection.', comException);
    }
  }, {
    run: function (sql, args) {
      var statement = new Statement(this, sql, args);

      statement.run();
      statement.close();
    },
    all: function (sql, args) {
      var rows, statement = new Statement(this, sql, args);

      rows = statement.all();
      statement.close();
      return rows;
    },
    each: function (sql, args, callback) {
      if (!callback && type(args) === 'function') {
        callback = args;
        args = null;
      }

      var statement = new Statement(this, sql, args);

      statement.each(callback);
      statement.close();
    },
    close: function () {
      this.connection.close();
    }
  });

  WinJS.Namespace.define('SQLite3JS', {
    Database: Database
  });

}());
{'fraction_non_alphanumeric': 0.13359477124183006, 'fraction_numerical': 0.006274509803921568, 'mean_word_length': 1.9840093603744149, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1036623', 'n_tokens_mistral': 2236, 'n_tokens_neox': 2182, 'n_words': 495}