<commit_before>(function () {
  angular
    .module("ng-geocoder")
    .factory("ngGeocoderService", ngGeocoderService);

  ngGeocoderService.$inject = ["$q"];

  function ngGeocoderService ($q) {
    var geocoder = new google.maps.Geocoder();
    var service  = {
      "geocodeById": geocodeById,
      "geocodeByQuery": geocodeByQuery
    }

    return service;

    function handleReply (defer, results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        return defer.resolve(results);
      } else if (status === google.maps.GeocoderStatus.ZERO_RESULTS) {
        return defer.resolve([]);
      } else if (status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
        return defer.reject("Over query limit");
      } else if (status === google.maps.GeocoderStatus.REQUEST_DENIED) {
        return defer.reject("Request denied");
      }

      return defer.reject("Unknown error");
    }

    function geocodeById (placeId) {
      return geocode({ "placeId": placeId });
    }

    function geocodeByQuery (query, region) {
      return geocode({ "address": query, "region": region });
    }
<commit_msg>Change if...else statement to switch for better code organization<commit_after>(function () {
  angular
    .module("ng-geocoder")
    .factory("ngGeocoderService", ngGeocoderService);

  ngGeocoderService.$inject = ["$q"];

  function ngGeocoderService ($q) {
    var geocoder = new google.maps.Geocoder();
    var service  = {
      "geocodeById": geocodeById,
      "geocodeByQuery": geocodeByQuery
    }

    return service;

    function handleReply (defer, results, status) {
      switch (status) {
        case google.maps.GeocoderStatus.OK:
          return defer.resolve(results);
        case google.maps.GeocoderStatus.ZERO_RESULTS:
          return defer.resolve([]);
        case google.maps.GeocoderStatus.OVER_QUERY_LIMIT:
          return defer.reject("Over query limit");
        case google.maps.GeocoderStatus.REQUEST_DENIED:
          return defer.reject("Request denied");
        default:
          return defer.reject("Unknown error");
      }
    }

    function geocodeById (placeId) {
      return geocode({ "placeId": placeId });
    }

    function geocodeByQuery (query, region) {
      var params = {
        "address": query,
        "region": region
      }

      return geocode(params);
    }

{'fraction_non_alphanumeric': 0.12272534913245874, 'fraction_numerical': 0.0, 'mean_word_length': 2.8129032258064517, 'pattern_counts': {'":': 10, '<': 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': '1337248', 'n_tokens_mistral': 736, 'n_tokens_neox': 707, 'n_words': 152}