<commit_before>###
Basic Module with extend/include methods

@namespace Atoms.Core
@class Module

@author <NAME> <<EMAIL>> || @soyjavi
###
"use strict"

DEFAULT_EVENTS = ["add", "update", "delete"]

class window.Hamsa

  # -- STATIC ------------------------------------------------------------------
  ###
  Instance repository
  ###
  @records  = {}

  ###
  Observer reference
  ###
  @observer = undefined

  ###
  Returns all instances of the Class
  @method all
  @return {array}     Array of all repository instances.
  ###
  @all: ->
    records = []
    records.push record for uid, record of @records
    return records

  ###
  Destroy all instances of the Class
  @method destroyAll
  @return {array}     Empty array of all repository instances.
  ###
  @destroyAll: ->
    delete @records[uid] for uid of @records
    return @records

  ###
  Finds a determinate instance with a field attribute.
  @method findBy
  @param  {string}    Name of field to search.
  @param  {string}    Value to filter search.
  @return {object}    Hamsa instance.
  ###
  @findBy: (name, value) ->
    return record for uid, record of @records when record[name] is value
    return null

  ###
  Observe changes in instance repository.
  @method observe
  @param  {function}  A function to execute each time the object is changed.
  @return {object}    A object observe state.
  ###
  @observe: (callback, events = DEFAULT_EVENTS) ->
    @observer = Object.observe @records, (states) ->
      callback state for state in states
    , events

  ###
  Unobserve changes in instance repository.
  @method unobserve
  @return {object}    A object observe state.
  ###
  @unobserve: ->
    Object.unobserve @records, @observer


  # -- INSTANCE ----------------------------------------------------------------
  ###
  Create a nre instance for a Hamsa Class.
  @method constructor
  @param  {object}    Fields for the instance.
  @param  {function}  A function to execute each time the fields change.<commit_msg>Fixed typo: not necesary return<commit_after>###
Basic Module with extend/include methods

@namespace Atoms.Core
@class Module

@author <NAME> <<EMAIL>> || @soyjavi
###
"use strict"

DEFAULT_EVENTS = ["add", "update", "delete"]

class window.Hamsa

  # -- STATIC ------------------------------------------------------------------
  ###
  Instance repository
  ###
  @records  = {}

  ###
  Observer reference
  ###
  @observer = undefined

  ###
  Returns all instances of the Class
  @method all
  @return {array}     Array of all repository instances.
  ###
  @all: ->
    records = []
    records.push record for uid, record of @records
    records

  ###
  Destroy all instances of the Class
  @method destroyAll
  @return {array}     Empty array of all repository instances.
  ###
  @destroyAll: ->
    delete @records[uid] for uid of @records
    @records

  ###
  Finds a determinate instance with a field attribute.
  @method findBy
  @param  {string}    Name of field to search.
  @param  {string}    Value to filter search.
  @return {object}    Hamsa instance.
  ###
  @findBy: (name, value) ->
    record for uid, record of @records when record[name] is value

  ###
  Observe changes in instance repository.
  @method observe
  @param  {function}  A function to execute each time the object is changed.
  @return {object}    A object observe state.
  ###
  @observe: (callback, events = DEFAULT_EVENTS) ->
    @observer = Object.observe @records, (states) ->
      callback state for state in states
    , events

  ###
  Unobserve changes in instance repository.
  @method unobserve
  @return {object}    A object observe state.
  ###
  @unobserve: ->
    Object.unobserve @records, @observer


  # -- INSTANCE ----------------------------------------------------------------
  ###
  Create a nre instance for a Hamsa Class.
  @method constructor
  @param  {object}    Fields for the instance.
  @param  {function}  A function to execute each time the fields change.
{'fraction_non_alphanumeric': 0.16612214124151797, 'fraction_numerical': 0.0, 'mean_word_length': 2.3558178752107928, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, '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': '2928748', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1111, 'n_words': 416}