<commit_before>/* @flow */
const root = '/api';
const headers = new Headers({
  'Content-Type': 'application/json'
});
const routes = {
  companies: 'companies'
};

class Api {
  execute = (entity :String, options :Object, id :String) => {
    let url = `${root}/${routes[entity]}`;

    if (id) {
      url += `/${id}`;
    }

    return fetch(url, options)
    .then(function (response) {
      return response.json();
    })
    .then(function (responseObject) {
      return id || options.method === 'POST' ? responseObject : responseObject._embedded[entity];
    });
  }

  get = (entity :String, id :String) => {
    return this.execute(entity, {
      method: 'GET',
      headers: headers
    }, id);
  }

  getAll = (entity :String) => {
    return this.execute(entity, {
      method: 'GET',
      headers: headers
    });
  }

  create = (entity :String, data :Object) => {
    return this.execute(entity, {
      method: 'POST',
      headers: headers,
      body: JSON.stringify(data)
    });
  }

  update = (entity :String, data :Object, id :String) => {
    return this.execute(entity, {
      method: 'PUT',
      headers: headers,
      body: JSON.stringify(data)
    }, id);
  }
}
export default new Api();
<commit_msg>Changed function to arrow function<commit_after>/* @flow */
const root = '/api';
const headers = new Headers({
  'Content-Type': 'application/json'
});
const routes = {
  companies: 'companies'
};

class Api {
  execute = (entity :String, options :Object, id :String) => {
    let url = `${root}/${routes[entity]}`;

    if (id) {
      url += `/${id}`;
    }

    return fetch(url, options)
    .then((response) => {
      return response.json();
    })
    .then((responseObject) => {
      return id || options.method === 'POST' ? responseObject : responseObject._embedded[entity];
    });
  }

  get = (entity :String, id :String) => {
    return this.execute(entity, {
      method: 'GET',
      headers: headers
    }, id);
  }

  getAll = (entity :String) => {
    return this.execute(entity, {
      method: 'GET',
      headers: headers
    });
  }

  create = (entity :String, data :Object) => {
    return this.execute(entity, {
      method: 'POST',
      headers: headers,
      body: JSON.stringify(data)
    });
  }

  update = (entity :String, data :Object, id :String) => {
    return this.execute(entity, {
      method: 'PUT',
      headers: headers,
      body: JSON.stringify(data)
    }, id);
  }
}
export default new Api();

{'fraction_non_alphanumeric': 0.1722334004024145, 'fraction_numerical': 0.0, 'mean_word_length': 2.629197080291971, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3167629', 'n_tokens_mistral': 801, 'n_tokens_neox': 798, 'n_words': 202}