<commit_before>
interface ElementOptions {
  element:    HTMLElement,
  container?: HTMLElement
}

const attributeMap = {
  "anchorLeft":    "left",
  "anchorRight":   "right",
  "anchorTop":     "top",
  "anchorBottom":  "bottom",
  "anchorWidth":   "width",
  "anchorHeight":  "height",
  "anchorHcenter": "hcenter",
  "anchorVcenter": "vcenter"
};

class LayoutManager {

  system = new Constraints.System();
  managers = [] as RectManager[];

  constructor(root: HTMLElement) {
    let iterator = document.createNodeIterator(root, NodeFilter.SHOW_ELEMENT);
    let el: HTMLElement;
    while (el = iterator.nextNode() as any) {
      let isRegistered = false;
      let manager = null;
      Object.keys(el.dataset).forEach(key => {
        if (!attributeMap[key]) {
          return;
        }
        if (!isRegistered) {
          manager = this.register(el, null);
          isRegistered = true;
        }
        let property = attributeMap[key];
        manager.constrain(property, el.dataset[key]);
      });
    }
  }

  /**
   * Register an element with the layout
   */
  register(element: HTMLElement, container?: HTMLElement): ElementManager {
    let m = new ElementManager(this.system, element, container);
    this.managers.push(m);
    return m;
  }

  /**
   * Update the system from the element's actual values
   */
  updateSystem(): void {
    for (let manager of this.managers) {
      manager.updateSystem();
    }
  }

  /**
   * Update the elements with the system's value
   */
  updateLayout(): void {
    this.system.solve();
    for (let manager of this.managers) {
      manager.updateRect();
    }
  }

}
<commit_msg>make the attribute map function local<commit_after>
interface ElementOptions {
  element:    HTMLElement,
  container?: HTMLElement
}

class LayoutManager {

  system = new Constraints.System();
  managers = [] as RectManager[];

  constructor(root: HTMLElement) {

    const attributeMap = {
      "anchorLeft":    "left",
      "anchorRight":   "right",
      "anchorTop":     "top",
      "anchorBottom":  "bottom",
      "anchorWidth":   "width",
      "anchorHeight":  "height",
      "anchorHcenter": "hcenter",
      "anchorVcenter": "vcenter"
    };

    let iterator = document.createNodeIterator(root, NodeFilter.SHOW_ELEMENT);
    let el: HTMLElement;
    while (el = iterator.nextNode() as any) {
      let isRegistered = false;
      let manager = null;
      Object.keys(el.dataset).forEach(key => {
        if (!attributeMap[key]) {
          return;
        }
        if (!isRegistered) {
          manager = this.register(el, null);
          isRegistered = true;
        }
        let property = attributeMap[key];
        manager.constrain(property, el.dataset[key]);
      });
    }
  }

  /**
   * Register an element with the layout
   */
  register(element: HTMLElement, container?: HTMLElement): ElementManager {
    let m = new ElementManager(this.system, element, container);
    this.managers.push(m);
    return m;
  }

  /**
   * Update the system from the element's actual values
   */
  updateSystem(): void {
    for (let manager of this.managers) {
      manager.updateSystem();
    }
  }

  /**
   * Update the elements with the system's value
   */
  updateLayout(): void {
    this.system.solve();
    for (let manager of this.managers) {
      manager.updateRect();
    }
  }

}

{'fraction_non_alphanumeric': 0.1300861300861301, 'fraction_numerical': 0.0, 'mean_word_length': 2.602139037433155, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 5, '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': '7279768', 'n_tokens_mistral': 1029, 'n_tokens_neox': 1026, 'n_words': 247}