<commit_before>#     rivets.js
#     version : 0.1.9
#     author : <NAME>
#     license : MIT

# The Rivets namespace.
Rivets = {}

# A single binding between a model attribute and a DOM element.
class Rivets.Binding
  # All information about the binding is passed into the constructor; the DOM
  # element, the routine identifier, the model object and the keypath at which
  # to listen for changes.
  constructor: (@el, @type, @model, @keypath, @formatters = []) ->
    @routine = Rivets.routines[@type] || attributeBinding @type

  # Sets the value for the binding. This Basically just runs the binding routine
  # with the suplied value and applies any formatters.
  set: (value) =>
    for formatter in @formatters
      value = Rivets.config.formatters[formatter] value

    @routine @el, value

  # Subscribes to the model for changes at the specified keypath. Bi-directional
  # routines will also listen for changes on the element to propagate them back
  # to the model.
  bind: =>
    Rivets.config.adapter.subscribe @model, @keypath, @set

    if Rivets.config.preloadData
      @set Rivets.config.adapter.read @model, @keypath

    if @type in bidirectionals
      @el.addEventListener 'change', @publish

  publish: (e) =>
    el = e.target or e.srcElement
    Rivets.config.adapter.publish @model, @keypath, getInputValue el<commit_msg>Add some code docs for Rivets.Binding#publish.<commit_after>#     rivets.js
#     version : 0.1.9
#     author : <NAME>
#     license : MIT

# The Rivets namespace.
Rivets = {}

# A single binding between a model attribute and a DOM element.
class Rivets.Binding
  # All information about the binding is passed into the constructor; the DOM
  # element, the routine identifier, the model object and the keypath at which
  # to listen for changes.
  constructor: (@el, @type, @model, @keypath, @formatters = []) ->
    @routine = Rivets.routines[@type] || attributeBinding @type

  # Sets the value for the binding. This Basically just runs the binding routine
  # with the suplied value and applies any formatters.
  set: (value) =>
    for formatter in @formatters
      value = Rivets.config.formatters[formatter] value

    @routine @el, value

  # Subscribes to the model for changes at the specified keypath. Bi-directional
  # routines will also listen for changes on the element to propagate them back
  # to the model.
  bind: =>
    Rivets.config.adapter.subscribe @model, @keypath, @set

    if Rivets.config.preloadData
      @set Rivets.config.adapter.read @model, @keypath

    if @type in bidirectionals
      @el.addEventListener 'change', @publish

  # Publishes the value currently set on the input element back to the model.
  publish: (e) =>
    el = e.target or e.srcElement
    Rivets.config.adapter.publish @model, @keypath, getInputValue el
{'fraction_non_alphanumeric': 0.08845470692717584, 'fraction_numerical': 0.0021314387211367673, 'mean_word_length': 3.406885758998435, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '3577906', 'n_tokens_mistral': 860, 'n_tokens_neox': 810, 'n_words': 321}