<commit_before>var mag = (function(self, module, render, document, undefined) {

  'use strict'

  var privates = {}

  privates.init = function(container, data) {
    if (!(this instanceof privates.init)) return new privates.init(container, data);
    var instance = this;
    console.log('mag init')
  }

  privates.redraw=function(){
    render.redraw( module || render.module || {})
  }

  privates.prop = function(store) {
    var prop = function() {
      if (arguments.length) {
        store = arguments[0]
        render.redraw(module)
      }
      return store
    }

    prop.toJSON = function() {
      // return a copy
      return JSON.parse(JSON.stringify(store))
    }

    return prop
  }


  privates.module = function(domElementId, moduleObject, props) {
    console.time("MagnumJS:init")

    var index = render.roots.indexOf(domElementId);
    if (index < 0) index = render.roots.length;

    //DOM
    var element = document.getElementById(domElementId)
    if (!element) throw new Error('invalid node')
    var parentElement = element.parentNode
    var elementClone = element.cloneNode(true)

    var tempEle = document.createElement("span")
    parentElement.replaceChild(tempEle, element)

    //MODULE
    var mod = module.submodule(moduleObject, [props])

    render.roots[index] = domElementId
    var controller = new mod.controller

    module.controllers[index] = controller
    module.modules[index] = mod
    module.elements[index] = elementClone
    //INTERPOLATIONS
    render.redraw(module)

    //DOM
    parentElement.replaceChild(elementClone, tempEle)

    // call onload if present in controller
    if (controller.onload) controller.onload.call(null, elementClone)
  }

  var interfaces = function(method) {
    return function() {
      return privates[method].apply(this, arguments)
    }
  }

  var api = interfaces('init')

  api['module'] = interfaces('module')
  api['prop'] = interfaces('prop')
  api['redraw'] = interfaces('redraw')

  return api
})(mag = mag || {}, mod, render, document);
<commit_msg>Update mag.js<commit_after>var mag = (function(self, document, undefined) {

  'use strict'

  var privates = {},
    module = self.mod,
    render = self.render,
    fill = self.fill,
    watch = mag.watch

    // REMOVE THIS? why is this here?
    privates.init = function(container, data) {

      // if (!(this instanceof privates.init)) return new privates.init(container, data)
      // var instance = this
      // console.log('mag init')
    }

  privates.redraw = function() {
    render.redraw(module || render.module || {}, fill, watch)
  }

  privates.prop = function(store) {
    var prop = function() {
      if (arguments.length) {
        store = arguments[0]
        privates.redraw()
      }
      return store
    }

    prop.type = 'fun'

    prop.toJSON = function() {
      // return a copy
      return JSON.parse(JSON.stringify(store))
    }

    return prop
  }

  privates.module = function(domElementId, moduleObject, props) {
    console.time("MagnumJS:init")

    var index = render.roots.indexOf(domElementId);
    if (index < 0) index = render.roots.length;

    //DOM
    var element = document.getElementById(domElementId)
    if (!element) throw new Error('invalid node')

    var parentElement = element.parentNode
    var elementClone = element.cloneNode(true)

    var tempEle = document.createElement("span")
    parentElement.replaceChild(tempEle, element)

    //MODULE
    var mod = module.submodule(moduleObject, [props])

    render.roots[index] = domElementId
    var controller = new mod.controller

    module.controllers[index] = controller
    module.modules[index] = mod
    module.elements[index] = elementClone
    //INTERPOLATIONS
    privates.redraw()

    //DOM
    parentElement.replaceChild(elementClone, tempEle)

    // call onload if present in controller
    if (controller.onload) controller.onload.call(null, elementClone)
  }

  var interfaces = function(method) {
    return function() {
      return privates[method].apply(this, arguments)
    }
  }

  var api = interfaces('init')

  api['module'] = interfaces('module')
  api['prop'] = interfaces('prop')
  api['redraw'] = interfaces('redraw')

  return api

}(window.mag || {}, document))

{'fraction_non_alphanumeric': 0.12623181604880337, 'fraction_numerical': 0.0009385265133740028, 'mean_word_length': 3.056137012369172, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1239112', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1248, 'n_words': 298}