<commit_before>class Storylet
  constructor: (@id, @title, @text, @choices) ->
    Object.freeze @

angular.module 'qbn.storylet', ['qbn.state']
  .factory 'storylets', (makeGameState) ->
    library = {}
    api =
      register: (args...) ->
        storylet = new Storylet args...
        library[storylet.id] = storylet # Storylets are stored in immutable form
        return this # Allow Chaining
      resolve: (q) ->
        if q instanceof Storylet
          q
        else
          makeGameState library[q.toString()]
    return Object.freeze api
<commit_msg>Fix Crash in Storylet Resolution<commit_after>class Storylet
  constructor: (@id, @title, @text, @choices) ->
    Object.freeze @

angular.module 'qbn.storylet', ['qbn.state']
  .factory 'storylets', (makeGameState) ->
    library = {}
    api =
      register: (args...) ->
        storylet = new Storylet args...
        library[storylet.id] = storylet # Storylets are stored in immutable form
        return this # Allow Chaining
      resolve: (q) ->
        if q instanceof Storylet
          q
        else
          storylet = library[q.toString()]
          if storylet? then makeGameState storylet else undefined
    return Object.freeze api

{'fraction_non_alphanumeric': 0.11311475409836065, 'fraction_numerical': 0.0, 'mean_word_length': 2.3636363636363638, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3071432', 'n_tokens_mistral': 352, 'n_tokens_neox': 352, 'n_words': 105}