<commit_before>/// <reference path="Common.ts" />
/// <reference path="Model.ts" />
/// <reference path="Directives.ts" />
/// <reference path="dir/Bind.ts" />
/// <reference path="dir/If.ts" />
/// <reference path="dir/For.ts" />
/// <reference path="dir/Root.ts" />
/// <reference path="dir/With.ts" />


namespace MVC {


export namespace Directives {


export const REGISTRY: DirectiveConstructorInterface[] = [
  WithDirective,
  ForDirective,
  IfDirective,
  BindDirective,
  RootDirective,
];


}  // namespace Directives


function _bind(directiveIndex: number, model: Model, node: Node): DirectiveInterface {
  const registry = MVC.Directives.REGISTRY;
  const DirectiveConstructor = registry[directiveIndex % registry.length];
  return new DirectiveConstructor((model, node) => {
    return _bind(directiveIndex + 1, model, node);
  }, model, node);
}


export function bind(model: Dictionary, view: Element, controller: () => void): void {
  _bind(0, Model.create(model), view);
}


export function bindBody(model: Dictionary, controller: () => void): void {
  MVC.bind(model, document.body, controller);
}


}  // namespace MVC<commit_msg>Avoid making the directiveIndex too big<commit_after>/// <reference path="Common.ts" />
/// <reference path="Model.ts" />
/// <reference path="Directives.ts" />
/// <reference path="dir/Bind.ts" />
/// <reference path="dir/If.ts" />
/// <reference path="dir/For.ts" />
/// <reference path="dir/Root.ts" />
/// <reference path="dir/With.ts" />


namespace MVC {


export namespace Directives {


export const REGISTRY: DirectiveConstructorInterface[] = [
  WithDirective,
  ForDirective,
  IfDirective,
  BindDirective,
  RootDirective,
];


}  // namespace Directives


function _bind(directiveIndex: number, model: Model, node: Node): DirectiveInterface {
  const registry = MVC.Directives.REGISTRY;
  const DirectiveConstructor = registry[directiveIndex % registry.length];
  return new DirectiveConstructor((model, node) => {
    return _bind((directiveIndex + 1) % registry.length, model, node);
  }, model, node);
}


export function bind(model: Dictionary, view: Element, controller: () => void): void {
  _bind(0, Model.create(model), view);
}


export function bindBody(model: Dictionary, controller: () => void): void {
  MVC.bind(model, document.body, controller);
}


}  // namespace MVC
{'fraction_non_alphanumeric': 0.16085106382978723, 'fraction_numerical': 0.001702127659574468, 'mean_word_length': 4.189845474613686, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, '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': '5126185', 'n_tokens_mistral': 742, 'n_tokens_neox': 710, 'n_words': 171}