<commit_before>noflo = require 'noflo'

# @runtime noflo-browser

class RequireModule extends noflo.AsyncComponent
  icon: 'dot-circle-o'
  description: 'Load an AMD module'

  constructor: ->
    @inPorts = new noflo.InPorts
      path:
        datatype: 'string'
        description: 'Path of the module to load'
    @outPorts = new noflo.OutPorts
      module:
        datatype: 'object'
      error:
        datatype: 'object'
        required: false

    super 'path', 'module'

  doAsync: (path, callback) ->
    return callback new Error 'Require.js not available' unless window.requirejs
    try
      window.requirejs [path], (module) =>
        @outPorts.module.beginGroup path
        @outPorts.module.send module
        @outPorts.module.endGroup path
        do callback
      , (err) ->
        callback err
    catch err
      callback err

exports.getComponent = -> new RequireModule<commit_msg>Sometimes Require.js needs a second chance<commit_after>noflo = require 'noflo'

# @runtime noflo-browser

class RequireModule extends noflo.AsyncComponent
  icon: 'dot-circle-o'
  description: 'Load an AMD module'

  constructor: ->
    @inPorts = new noflo.InPorts
      path:
        datatype: 'string'
        description: 'Path of the module to load'
    @outPorts = new noflo.OutPorts
      module:
        datatype: 'object'
      error:
        datatype: 'object'
        required: false

    super 'path', 'module'

  doRequire: (path, callback) ->
    window.requirejs [path], (module) =>
      @outPorts.module.beginGroup path
      @outPorts.module.send module
      @outPorts.module.endGroup path
      do callback
    , (err) ->
      callback err
  doAsync: (path, callback) ->
    return callback new Error 'Require.js not available' unless window.requirejs
    try
      @doRequire path, callback
    catch err
      try
        @doRequire path, callback
      catch e
        callback err

exports.getComponent = -> new RequireModule
{'fraction_non_alphanumeric': 0.09123343527013252, 'fraction_numerical': 0.0, 'mean_word_length': 2.499108734402852, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '1042023', 'n_tokens_mistral': 598, 'n_tokens_neox': 577, 'n_words': 172}