diff --git a/README.md b/README.md index 886f2dd..569e33a 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,10 @@ In this way contextual search #### Web-Worker Support diff --git a/flexsearch.js b/flexsearch.js index 9f9429a..4ef0b01 100644 --- a/flexsearch.js +++ b/flexsearch.js @@ -316,18 +316,6 @@ var SUPPORT_ASYNC = true; if(self._current_callback && (self._task_completed === self.worker)){ - // if(typeof self._last_empty_query !== 'undefined'){ - // - // if(self._task_result.length){ - // - // self._last_empty_query = ""; - // } - // else{ - // - // self._last_empty_query || (self._last_empty_query = query); - // } - // } - // store result to cache if(self.cache){ @@ -447,11 +435,6 @@ var SUPPORT_ASYNC = true; this._timer = null; this._status = true; - // if(this.mode === 'forward' || this.mode === 'reverse' || this.mode === 'both'){ - // - // this._last_empty_query = ""; - // } - if(SUPPORT_CACHE) { this.cache = custom = ( @@ -951,11 +934,6 @@ var SUPPORT_ASYNC = true; if(SUPPORT_CACHE && this.cache){ - // if(typeof this._last_empty_query !== 'undefined'){ - // - // this._last_empty_query = ""; - // } - this._cache.reset(); } @@ -974,13 +952,6 @@ var SUPPORT_ASYNC = true; } } - // validate last query - - // else if((typeof this._last_empty_query !== 'undefined') && this._last_empty_query && (query.indexOf(this._last_empty_query) === 0)){ - // - // return result; - // } - // encode string _query = this.encode(/** @type {string} */ (_query)); @@ -1082,6 +1053,7 @@ var SUPPORT_ASYNC = true; count > 1 ? + // https://jsperf.com/merge-arrays-comparison check.concat.apply([], map_check) : map_check[0] @@ -1114,18 +1086,6 @@ var SUPPORT_ASYNC = true; //result = intersect_3d(check, limit, this.suggest); } - // if(typeof this._last_empty_query !== 'undefined'){ - // - // if(result.length){ - // - // this._last_empty_query = ""; - // } - // else{ - // - // this._last_empty_query || (this._last_empty_query = query); - // } - // } - // store result to cache if(SUPPORT_CACHE && this.cache){ @@ -2252,9 +2212,11 @@ var SUPPORT_ASYNC = true; } else if(length_z){ - result = result.concat.apply(result, arrays[0]); + arrays = arrays[0]; - if(limit && result && (result.length > limit)){ + result = arrays.length > 1 ? result.concat.apply(result, arrays) : arrays[0]; + + if(limit && (result.length > limit)){ // Note: do not touch original array! @@ -2274,6 +2236,7 @@ var SUPPORT_ASYNC = true; * @returns {Array} */ + /* function intersect_sorted(a, b, limit){ var result = []; @@ -2319,6 +2282,7 @@ var SUPPORT_ASYNC = true; return result; } + */ /** * @param {FlexSearch} ref diff --git a/package.json b/package.json index aa2e69a..9c092e1 100644 --- a/package.json +++ b/package.json @@ -52,10 +52,10 @@ "chai": "^4.1.2", "coveralls": "^3.0.0", "google-closure-compiler": "^20180402.0.0", - "mocha": "^5.0.5", + "mocha": "^5.1.1", "mocha-lcov-reporter": "^1.3.0", "mocha-phantomjs": "^4.1.0", - "nyc": "^11.6.0", + "nyc": "^11.7.1", "phantomjs-prebuilt": "^2.1.16", "updtr": "^2.0.0" }