src/algoliasearch.helper.js
function AlgoliaSearchHelper(client, index, options) {
  if (client.addAlgoliaAgent && !doesClientAgentContainsHelper(client)) {
    client.addAlgoliaAgent('JS Helper (' + version + ')');
  }

  this.setClient(client);
  var opts = options || {};
  opts.index = index;
  this.state = SearchParameters.make(opts);
  this.lastResults = null;
  this._queryId = 0;
  this._lastQueryIdReceived = -1;
  this.derivedHelpers = [];
  this._currentNbQueries = 0;
}
function AlgoliaSearchHelper(client, index, options) {
  if (client.addAlgoliaAgent && !doesClientAgentContainsHelper(client)) {
    client.addAlgoliaAgent('JS Helper (' + version + ')');
  }

  this.setClient(client);
  var opts = options || {};
  opts.index = index;
  this.state = SearchParameters.make(opts);
  this.lastResults = null;
  this._queryId = 0;
  this._lastQueryIdReceived = -1;
  this.derivedHelpers = [];
  this._currentNbQueries = 0;
}
Event triggered when the queue of queries have been depleted (with any result or outdated queries)
@event AlgoliaSearchHelper#event:searchQueueEmpty
@example
helper.on('searchQueueEmpty', function() {
console.log('No more search pending');
// This is received before the result event if we're not expecting new results
});

helper.search();
 
Initialize a new AlgoliaSearchHelper
@class
@classdesc The AlgoliaSearchHelper is a class that ease the management of the
search. It provides an event based interface for search callbacks:
- change: when the internal search state is changed.
This event contains a {@link SearchParameters} object and the
{@link SearchResults} of the last result if any.
- search: when a search is triggered using the `search()` method.
- result: when the response is retrieved from Algolia and is processed.
This event contains a {@link SearchResults} object and the
{@link SearchParameters} corresponding to this answer.
- error: when the response is an error. This event contains the error returned by the server.
@param  {AlgoliaSearch} client an AlgoliaSearch client
@param  {string} index the index name to query
@param  {SearchParameters | object} options an object defining the initial
config of the search. It doesn't have to be a {SearchParameters},
just an object containing the properties you need from it.