<commit_before>/**
 * User: gisborne
 * Date: 9/23/14
 * Time: 0:09
 */

export scope = ->
  @fns = {}

  @getFn = (name) ->
    return @fns[name].fn if @fns[name]
    void

  @getFnMeta = (f) ->
    @fn_meta[f]

  @defineFn = (id, options, fn) ->
    @fns      ||= {}
    @fn_meta  ||= {}

    name = options.name || id
    @fns[id] = @fns[name] =
      fn: fn
      id: id
      name: name

    @fn_meta[fn] =
      name: name
      id:   id

  this<commit_msg>Add a call function to scope to immediately invoke a function by name<commit_after>/**
 * User: gisborne
 * Date: 9/23/14
 * Time: 0:09
 */
require! _: 'prelude-ls'

export scope = ->
  @fns = {}

  @getFn = (name) ->
    return @fns[name].fn if @fns[name]
    void

  @getFnMeta = (f) ->
    @fn_meta[f]

  @defineFn = (id, options, fn) ->
    @fns      ||= {}
    @fn_meta  ||= {}

    name = options.name || id
    @fns[id] = @fns[name] =
      fn: fn
      id: id
      name: name

    @fn_meta[fn] =
      name: name
      id:   id

  @call = (name) ->
    args = Array.prototype.slice.call(arguments, 1)
    f = this.getFn name
    f.apply args
  this
{'fraction_non_alphanumeric': 0.17410714285714285, 'fraction_numerical': 0.015178571428571428, 'mean_word_length': 1.926892950391645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '1473749', 'n_tokens_mistral': 476, 'n_tokens_neox': 452, 'n_words': 109}