<commit_before>/// <reference path="indexer.ts" />
module api {
  declare var window;
  declare var uuid;
  
  export var version = 0;

  type Id = string;
  type Fact = any[];

  interface Constraint {
    view?: Id,
    leftSource?: Id,
    leftField?: Id,
    rightSource?: Id,
    rightField?: Id,
    operation?: Id,
  }

  export function now() {
    if (window.performance) {
      return window.performance.now();
    }
    return (new Date()).getTime();
  }

  export var arraysIdentical:(a:any[], b:any[])=>boolean = Indexing.arraysIdentical;
  export var zip:(keys:string[], rows:any[][])=>any[] = Indexing.zip;
  export var clone:<T>(item:T)=>T = Indexing.clone;

  if(!window.DEBUG) {
    window.DEBUG = {RECEIVE: 0,
                    SEND: 0,
                    INDEXER: 0,
                    TABLE_CELL_LOOKUP: true};
  }

  export var KEYS = {
    BACKSPACE: 8,
    UP: 38,
    DOWN: 40,
    ENTER: 13,
    Z: 90,
    F: 70,
    ESC: 27,
    SPACE: 32,
  };

  export function extend(dest, src) {
    for(var key in src) {
      if(!src.hasOwnProperty(key)) { continue; }
      dest[key] = src[key];
    }
    return dest;
  }

  export function displaySort(idA:string, idB:string): number {
    var orderA = ixer.index("display order")[idA];
    var orderB = ixer.index("display order")[idB];
    if(orderB - orderA) { return orderB - orderA; }
    else { return idA.localeCompare(idB); }
  }

  export function invert(obj:Object): Object {
    var res = {};
    for(var key in obj) {
      if(!obj.hasOwnProperty(key)) { continue; }
      res[obj[key]] = key;
    }
    return res;
  }

  export var alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
                  "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
  export var alphabetLower = alphabet.map(function(char) {
    return char.toLowerCase();
  });
  var alphabetLowerToIx = invert(alphabetLower);

  export function reverseDiff(diff) {
    var neue = [];
    for(var diffIx = 0, diffLen = diff.length; diffIx < diffLen; diffIx++) {
      var copy = diff[diffIx].slice();
      neue[diffIx] = copy;
      if(copy[1] === "inserted") {
        copy[1] = "removed";
      } else {
        copy[1] = "inserted";
      }
    }
    return neue;
  }
  
  export function checkVersion(callback:(error:Error, newVersionExists?:boolean) => void) {
    let request = new XMLHttpRequest();
    request.onreadystatechange = function() {
      if(request.readyState === 4) {
        if(request.status !== 200) {
          return callback(new Error(`HTTP Response: ${request.status}`));
        }
        
        callback(undefined, +request.responseText > +api.version);
      }
    }
    request.open("GET", "https://raw.githubusercontent.com/Kodowa/Eve/master/version");
    request.send();<commit_msg>Adds commented testing url for update checker<commit_after>/// <reference path="indexer.ts" />
module api {
  declare var window;
  declare var uuid;
  
  export var version = 0;

  type Id = string;
  type Fact = any[];

  interface Constraint {
    view?: Id,
    leftSource?: Id,
    leftField?: Id,
    rightSource?: Id,
    rightField?: Id,
    operation?: Id,
  }

  export function now() {
    if (window.performance) {
      return window.performance.now();
    }
    return (new Date()).getTime();
  }

  export var arraysIdentical:(a:any[], b:any[])=>boolean = Indexing.arraysIdentical;
  export var zip:(keys:string[], rows:any[][])=>any[] = Indexing.zip;
  export var clone:<T>(item:T)=>T = Indexing.clone;

  if(!window.DEBUG) {
    window.DEBUG = {RECEIVE: 0,
                    SEND: 0,
                    INDEXER: 0,
                    TABLE_CELL_LOOKUP: true};
  }

  export var KEYS = {
    BACKSPACE: 8,
    UP: 38,
    DOWN: 40,
    ENTER: 13,
    Z: 90,
    F: 70,
    ESC: 27,
    SPACE: 32,
  };

  export function extend(dest, src) {
    for(var key in src) {
      if(!src.hasOwnProperty(key)) { continue; }
      dest[key] = src[key];
    }
    return dest;
  }

  export function displaySort(idA:string, idB:string): number {
    var orderA = ixer.index("display order")[idA];
    var orderB = ixer.index("display order")[idB];
    if(orderB - orderA) { return orderB - orderA; }
    else { return idA.localeCompare(idB); }
  }

  export function invert(obj:Object): Object {
    var res = {};
    for(var key in obj) {
      if(!obj.hasOwnProperty(key)) { continue; }
      res[obj[key]] = key;
    }
    return res;
  }

  export var alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
                  "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
  export var alphabetLower = alphabet.map(function(char) {
    return char.toLowerCase();
  });
  var alphabetLowerToIx = invert(alphabetLower);

  export function reverseDiff(diff) {
    var neue = [];
    for(var diffIx = 0, diffLen = diff.length; diffIx < diffLen; diffIx++) {
      var copy = diff[diffIx].slice();
      neue[diffIx] = copy;
      if(copy[1] === "inserted") {
        copy[1] = "removed";
      } else {
        copy[1] = "inserted";
      }
    }
    return neue;
  }
  
  export function checkVersion(callback:(error:Error, newVersionExists?:boolean) => void) {
    let request = new XMLHttpRequest();
    request.onreadystatechange = function() {
      if(request.readyState === 4) {
        if(request.status !== 200) {
          return callback(new Error(`HTTP Response: ${request.status}`));
        }
        
        callback(undefined, +request.responseText > +api.version);
      }
    }
    //request.open("GET", "https://gist.githubusercontent.com/joshuafcole/117ec93af90c054bac23/raw/1350f2aae121e19129e561678b107ec042a6cbd2/version");
    request.open("GET", "https://raw.githubusercontent.com/Kodowa/Eve/master/version");
    request.send();
{'fraction_non_alphanumeric': 0.16841201716738197, 'fraction_numerical': 0.0159656652360515, 'mean_word_length': 2.620882535736482, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1945263', 'n_tokens_mistral': 2116, 'n_tokens_neox': 2005, 'n_words': 467}