<commit_before>//     Backbone.Collection.search-ajax v0.2
//     by <NAME> - <EMAIL>
//     For all details and documentation:
//     https://github.com/homeslicesolutions/backbone-collection-search

!function(_, Backbone){

  // Extending out
  _.extend(Backbone.Collection.prototype, {  

    //@ Search for AJAX version
    search: function(keyword, attributes) {
      
      // Closure
      var that = this;

      // Get new data
      this.fetch({
        parse: false,
        data: {
          keyword: keyword,
          attributes: attributes
        },
        success: function( collection ){

          // Instantiate new Collection
          collection._searchQuery = keyword;
          collection.getSearchQuery = function() { 
            return this._searchQuery;
          }

          // Cache the recently searched metadata
          that._searchResults = collection;

          // Fire search event with new collection
          that.trigger('search', collection );
        }
      });
    },

    //@ Get recent search query
    getSearchQuery: function() {
      return this.getSearchResults().getSearchQuery();
    },
    
    //@ Get recent search results
    getSearchResults: function() {
      return this._searchResults;
    },

    //_Cache
    _searchResults: null

  });

}(_, Backbone);<commit_msg>Check for null exception on getSearchQuery<commit_after>//     Backbone.Collection.search-ajax v0.2
//     by <NAME> - <EMAIL>
//     For all details and documentation:
//     https://github.com/homeslicesolutions/backbone-collection-search

!function(_, Backbone){

  // Extending out
  _.extend(Backbone.Collection.prototype, {  

    //@ Search for AJAX version
    search: function(keyword, attributes) {
      
      // Closure
      var that = this;

      // Get new data
      this.fetch({
        parse: false,
        data: {
          keyword: keyword,
          attributes: attributes
        },
        success: function( collection ){

          // Instantiate new Collection
          collection._searchQuery = keyword;
          collection.getSearchQuery = function() { 
            return this._searchQuery;
          }

          // Cache the recently searched metadata
          that._searchResults = collection;

          // Fire search event with new collection
          that.trigger('search', collection );
        }
      });
    },

    //@ Get recent search query
    getSearchQuery: function() {
      return this.getSearchResults() && this.getSearchResults().getSearchQuery();
    },
    
    //@ Get recent search results
    getSearchResults: function() {
      return this._searchResults;
    },

    //_Cache
    _searchResults: null

  });

}(_, Backbone);

{'fraction_non_alphanumeric': 0.10678899082568807, 'fraction_numerical': 0.0014678899082568807, 'mean_word_length': 1.9502164502164503, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '953436', 'n_tokens_mistral': 722, 'n_tokens_neox': 695, 'n_words': 177}