Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(helper, { stalledSearchDelay = 200 } = {}) {
if (!(helper instanceof algoliaHelper.AlgoliaSearchHelper)) {
throw new TypeError(
'Store should be constructed with an AlgoliaSearchHelper instance as first parameter.'
);
}
// We require one start() call to execute the first search query.
// Allows every widget to alter the state at initialization
// without trigger multiple queries.
this._stoppedCounter = 1;
this._highlightPreTag = '<em>';
this._highlightPostTag = '</em>';
this._cacheEnabled = true;
this._stalledSearchDelay = stalledSearchDelay;
import algoliasearchHelper from 'algoliasearch-helper';
import version from '../lib/version.js';
import urlHelper from 'algoliasearch-helper/src/url';
import isEqual from 'lodash/lang/isEqual';
import merge from 'lodash/object/merge';/**/
const AlgoliaSearchHelper = algoliasearchHelper.AlgoliaSearchHelper;
const majorVersionNumber = version.split('.')[0];
let firstRender = true;
function timerMaker(t0) {
let t = t0;
return function timer() {
const now = Date.now();
const delta = now - t;
t = now;
return delta;
};
}
/**
* @typedef {object} UrlUtil
* @property {string} character the character used in the url
export const serialize = function(helper) {
if (!(helper instanceof algoliaHelper.AlgoliaSearchHelper)) {
throw new TypeError('Serialize expects an algolia helper instance.');
}
const client = helper.getClient();
const response = helper.lastResults ? helper.lastResults._rawResults : null;
const serialized = {
searchParameters: Object.assign({}, helper.state),
appId: client.applicationID,
apiKey: client.apiKey,
response,
};
return serialized;
};