<commit_before>
class AppStorage extends KDObject

  constructor: (appId, version)->
    @_applicationID = appId
    @_applicationVersion = version
    @reset()
    super

  fetchStorage: (callback)->

    [appId, version] = [@_applicationID, @_applicationVersion]

    unless @_storage
      KD.whoami().fetchStorage {appId, version}, (error, storage) =>
        unless error
          callback? @_storage = storage or {appId, version, bucket:{}}
          @emit "storageFetched"
          @emit "ready"
        else
          callback? null

    else
      callback? @_storage
      KD.utils.defer =>
        @emit "storageFetched"
        @emit "ready"

  fetchValue: (key, callback, group = 'bucket')->

    @reset()
    @fetchStorage (storage)=>
      callback if storage[group]?[key] then storage[group][key]

  getValue: (key, group = 'bucket')->

    return unless @_storage
    return if @_storageData[group]?[key]? then @_storageData[group][key]<commit_msg>Fix AppStorage initialize issue<commit_after>
class AppStorage extends KDObject

  constructor: (appId, version)->
    @_applicationID = appId
    @_applicationVersion = version
    @reset()
    super

  fetchStorage: (callback)->

    [appId, version] = [@_applicationID, @_applicationVersion]

    unless @_storage
      KD.whoami().fetchStorage {appId, version}, (error, storage) =>
        if not error and storage
          @_storage = storage
          callback? @_storage
          @emit "storageFetched"
          @emit "ready"
        else
          callback? null
    else
      callback? @_storage
      KD.utils.defer =>
        @emit "storageFetched"
        @emit "ready"

  fetchValue: (key, callback, group = 'bucket')->

    @reset()
    @fetchStorage (storage)=>
      callback if storage[group]?[key] then storage[group][key]

  getValue: (key, group = 'bucket')->

    return unless @_storage
    return if @_storageData[group]?[key]? then @_storageData[group][key]
{'fraction_non_alphanumeric': 0.12192622950819672, 'fraction_numerical': 0.0, 'mean_word_length': 2.836935166994106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '3303473', 'n_tokens_mistral': 589, 'n_tokens_neox': 561, 'n_words': 154}