<commit_before>import {v4 as rawuuid} from "uuid";

//---------------------------------------------------------
// Misc. Utilities
//---------------------------------------------------------
export function clone<T>(obj:T):T {
  if(typeof obj !== "object") return obj;
  if(obj.constructor === Array) {
    let neue:T = [] as any;
    for(let ix = 0; ix < (obj as any).length; ix++) {
      neue[ix] = clone(obj[ix]);
    }
    return neue;
  } else {
    let neue:T = {} as any;
    for(let key in obj) {
      neue[key] = clone(obj[key]);
    }
    return neue;
  }
}

export function uuid() {
  let raw:string = rawuuid();
  let mangled = raw.slice(0, 8) + raw.slice(9, 9 + 4) + raw.slice(-12);
  return "⦑" + mangled + "⦒";
}

export function sortComparator(a, b) {
  if(!a.sort || !b.sort) return 0;
  let aSort = a.sort;
  let bSort = b.sort;
  return aSort === bSort ? 0 : (aSort < bSort ? -1 : 1);
}

export function debounce<CB extends Function>(fn:CB, wait:number, leading?:boolean) {
  let timeout, context, args;

  let doFn = function doDebounced() {
    timeout = undefined;
    fn.apply(context, args);
    context = undefined;
    args = undefined;
  }

  let debounced:CB;
  if(!leading) {
    debounced = function(...argList) {
      context = this;
      args = argList;
      if(timeout) {
        window.clearTimeout(timeout);
      }
      timeout = window.setTimeout(doFn, wait);
    } as any;
  } else {
    debounced = function(...argList) {<commit_msg>Different identifier character for client events<commit_after>import {v4 as rawuuid} from "uuid";

//---------------------------------------------------------
// Misc. Utilities
//---------------------------------------------------------
export function clone<T>(obj:T):T {
  if(typeof obj !== "object") return obj;
  if(obj.constructor === Array) {
    let neue:T = [] as any;
    for(let ix = 0; ix < (obj as any).length; ix++) {
      neue[ix] = clone(obj[ix]);
    }
    return neue;
  } else {
    let neue:T = {} as any;
    for(let key in obj) {
      neue[key] = clone(obj[key]);
    }
    return neue;
  }
}

export function uuid() {
  let raw:string = rawuuid();
  let mangled = raw.slice(0, 8) + raw.slice(9, 9 + 4) + raw.slice(-12);
  return "⍦" + mangled;
}

export function sortComparator(a, b) {
  if(!a.sort || !b.sort) return 0;
  let aSort = a.sort;
  let bSort = b.sort;
  return aSort === bSort ? 0 : (aSort < bSort ? -1 : 1);
}

export function debounce<CB extends Function>(fn:CB, wait:number, leading?:boolean) {
  let timeout, context, args;

  let doFn = function doDebounced() {
    timeout = undefined;
    fn.apply(context, args);
    context = undefined;
    args = undefined;
  }

  let debounced:CB;
  if(!leading) {
    debounced = function(...argList) {
      context = this;
      args = argList;
      if(timeout) {
        window.clearTimeout(timeout);
      }
      timeout = window.setTimeout(doFn, wait);
    } as any;
  } else {
    debounced = function(...argList) {
{'fraction_non_alphanumeric': 0.22579564489112228, 'fraction_numerical': 0.008710217755443886, 'mean_word_length': 2.084710743801653, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '2297616', 'n_tokens_mistral': 1008, 'n_tokens_neox': 994, 'n_words': 262}