<commit_before>resourceRequest = require './resource-request.coffee'
virtual = require './virtual-resource.coffee'

resources = {}

# TODO : Implement cache invalidation on a periodic basis here
exports.combine = ({resources, req, separator, contentType, prefix}) ->
  id = resources.length + (resources.href for resource in resources).join ':'

  if not resource = resources[id]
    # Create a new resource and load async
    resource = resources[id] = {
      id
      content: {href: resource.href, complete: false} for resource in resources
      deferred: []
    }

    checkComplete = ->
      # Determine if there are any incomplete operations
      for content in resource.content
        if not content.complete
          return false

      resource.content = (content.data for content in resource.content).join ''

      for deferred in resource.deferred
        deferred resource.content
<commit_msg>Fix id generation within the resource combiner<commit_after>resourceRequest = require './resource-request.coffee'
virtual = require './virtual-resource.coffee'

resources = {}

# TODO : Implement cache invalidation on a periodic basis here
exports.combine = ({resources, req, separator, contentType, prefix}) ->
  id = resources.length + (resource.href for resource in resources).join ':'

  if not resource = resources[id]
    # Create a new resource and load async
    resource = resources[id] = {
      id
      content: {href: resource.href, complete: false} for resource in resources
      deferred: []
    }

    checkComplete = ->
      # Determine if there are any incomplete operations
      for content in resource.content
        if not content.complete
          return false

      resource.content = (content.data for content in resource.content).join ''

      for deferred in resource.deferred
        deferred resource.content

{'fraction_non_alphanumeric': 0.08728448275862069, 'fraction_numerical': 0.0, 'mean_word_length': 3.117516629711752, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6410565', 'n_tokens_mistral': 472, 'n_tokens_neox': 453, 'n_words': 170}