<commit_before>import {Log, Component} from 'bkb'

type Comp = Component & MonkberryComponent

export interface MonkberryComponent {
  attachTo(el: HTMLElement): void
  update?(value: string): void
}

export interface ComponentMakers {
  [directiveName: string]: (el: HTMLElement, value?: string) => Component & MonkberryComponent
}

export default function createBkbDirectives(log: Log, makers: ComponentMakers) {
  let directives = {}
  for (let name in makers) {
    if (makers.hasOwnProperty(name))
      directives[name] = createDirective(log, makers[name], name)
  }
  return directives
}

function createDirective(log: Log, maker: (el: HTMLElement, value: string) => Comp, directiveName: string) {
  return class {
    private comp: Comp
    private el: HTMLElement

    bind(node) {
      this.el = node
    }

    unbind() {
      this.el = null
      if (this.comp) {
        try {
          this.comp.bkb.destroy()
          this.comp = null
        } catch (e) {<commit_msg>strictNullChecks with BkbMonkberryDirective<commit_after>import { Log, Component } from 'bkb'

type Comp = Component & MonkberryComponent

export interface MonkberryComponent {
  attachTo(el: HTMLElement): void
  update?(value?: string): void
}

export interface ComponentMakers {
  [directiveName: string]: (el: HTMLElement, value?: string) => Component & MonkberryComponent
}

export default function createBkbDirectives(log: Log, makers: ComponentMakers) {
  let directives = {}
  for (let name in makers) {
    if (makers.hasOwnProperty(name))
      directives[name] = createDirective(log, makers[name], name)
  }
  return directives
}

function createDirective(log: Log, maker: (el: HTMLElement, value?: string) => Comp, directiveName: string) {
  return class {
    private comp: Comp | null
    private el: HTMLElement | null

    bind(node) {
      this.el = node
    }

    unbind() {
      this.el = null
      if (this.comp) {
        try {
          this.comp.bkb.destroy()
          this.comp = null
        } catch (e) {
{'fraction_non_alphanumeric': 0.1099009900990099, 'fraction_numerical': 0.0, 'mean_word_length': 3.3839479392624727, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3624044', 'n_tokens_mistral': 628, 'n_tokens_neox': 623, 'n_words': 172}