<commit_before>import Service, { inject as service } from '@ember/service';

import ajax from '../utils/ajax';

export default class FetcherService extends Service {
  @service fastboot;

  ajax(url) {
    let fastboot = this.fastboot;
    let shoebox = this.fastboot.shoebox;
    let cache = shoebox.retrieve('ajax-cache');
    if (!cache) {
      cache = {};
    }

    if (cache[url]) {
      return cache[url];
    }

    return ajax(url).then(function (resp) {
      if (shoebox && fastboot.isFastBoot) {
        cache[url] = deepCopy(resp);
        shoebox.put('ajax-cache', cache);
      }
      return resp;
    });
  }
}

function deepCopy(obj) {<commit_msg>Auto merge of #2889 - Turbo87:async-ajax, r=locks<commit_after>import Service, { inject as service } from '@ember/service';

import ajax from '../utils/ajax';

export default class FetcherService extends Service {
  @service fastboot;

  async ajax(url) {
    let fastboot = this.fastboot;
    let shoebox = this.fastboot.shoebox;
    let cache = shoebox.retrieve('ajax-cache');
    if (!cache) {
      cache = {};
    }

    if (cache[url]) {
      return cache[url];
    }

    let resp = await ajax(url);
    if (shoebox && fastboot.isFastBoot) {
      cache[url] = deepCopy(resp);
      shoebox.put('ajax-cache', cache);
    }
    return resp;
  }
}

function deepCopy(obj) {
{'fraction_non_alphanumeric': 0.13967310549777118, 'fraction_numerical': 0.004457652303120356, 'mean_word_length': 2.8158640226628897, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5274631', 'n_tokens_mistral': 470, 'n_tokens_neox': 449, 'n_words': 107}