Socket
Socket
Sign inDemoInstall

js-worker-search

Package Overview
Dependencies
3
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.0 to 1.4.1

5

CHANGELOG.md
Changelog
-----
#### 1.4.1
* Removed source maps from inline worker blob to avoid errors ([@jahed](https://github.com/jahed) - [#23](https://github.com/bvaughn/js-worker-search/pull/23))
#### 1.4.0
* Added support for optional OR searches (documents matching only some of the search tokens) ([@ dlebech](https://github.com/ dlebech) - [#19](https://github.com/bvaughn/js-worker-search/pull/19))
* Added support for optional OR searches (documents matching only some of the search tokens) ([@dlebech](https://github.com/dlebech) - [#19](https://github.com/bvaughn/js-worker-search/pull/19))

@@ -7,0 +10,0 @@ #### 1.3.0

237

dist/5cafaba60d6eb1f43c8f.worker.js
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)

@@ -18,23 +18,23 @@ /******/ var module = installedModules[moduleId] = {

/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports

@@ -49,5 +49,5 @@ /******/ return __webpack_require__(0);

"use strict";
var _util = __webpack_require__(1);
/**

@@ -57,10 +57,10 @@ * Search entry point to web worker.

*/
var searchUtility = new _util.SearchUtility();
self.addEventListener("message", function (event) {
var data = event.data;
var method = data.method;
switch (method) {

@@ -70,4 +70,4 @@ case "indexDocument":

text = data.text;
searchUtility.indexDocument(uid, text);

@@ -78,6 +78,6 @@ break;

query = data.query;
var results = searchUtility.search(query);
self.postMessage({ callbackId: callbackId, results: results });

@@ -87,4 +87,4 @@ break;

var caseSensitive = data.caseSensitive;
searchUtility.setCaseSensitive(caseSensitive);

@@ -94,4 +94,4 @@ break;

var indexMode = data.indexMode;
searchUtility.setIndexMode(indexMode);

@@ -101,4 +101,4 @@ break;

var matchAnyToken = data.matchAnyToken;
searchUtility.setMatchAnyToken(matchAnyToken);

@@ -108,4 +108,4 @@ break;

var tokenizePattern = data.tokenizePattern;
searchUtility.setTokenizePattern(tokenizePattern);

@@ -121,3 +121,3 @@ break;

"use strict";
Object.defineProperty(exports, "__esModule", {

@@ -127,11 +127,11 @@ value: true

exports.SearchUtility = exports.INDEX_MODES = undefined;
var _SearchUtility = __webpack_require__(2);
var _SearchUtility2 = _interopRequireDefault(_SearchUtility);
var _constants = __webpack_require__(3);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _SearchUtility2.default;

@@ -146,19 +146,19 @@ exports.INDEX_MODES = _constants.INDEX_MODES;

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _constants = __webpack_require__(3);
var _SearchIndex = __webpack_require__(4);
var _SearchIndex2 = _interopRequireDefault(_SearchIndex);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -169,3 +169,3 @@ * Synchronous client-side full-text search utility.

var SearchUtility = function () {
/**

@@ -181,3 +181,3 @@ * Constructor.

var _this = this;
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},

@@ -192,13 +192,13 @@ _ref$caseSensitive = _ref.caseSensitive,

tokenizePattern = _ref$tokenizePattern === undefined ? /\s+/ : _ref$tokenizePattern;
_classCallCheck(this, SearchUtility);
this.indexDocument = function (uid, text) {
_this._uids[uid] = true;
var fieldTokens = _this._tokenize(_this._sanitize(text));
fieldTokens.forEach(function (fieldToken) {
var expandedTokens = _this._expandToken(fieldToken);
expandedTokens.forEach(function (expandedToken) {

@@ -208,6 +208,6 @@ _this._searchIndex.indexDocument(expandedToken, uid);

});
return _this;
};
this.search = function (query) {

@@ -218,9 +218,9 @@ if (!query) {

var tokens = _this._tokenize(_this._sanitize(query));
return _this._searchIndex.search(tokens, _this._matchAnyToken);
}
};
this.terminate = function () {};
this._caseSensitive = caseSensitive;

@@ -230,12 +230,12 @@ this._indexMode = indexMode;

this._tokenizePattern = tokenizePattern;
this._searchIndex = new _SearchIndex2.default();
this._uids = {};
}
/**
* Returns a constant representing the current case-sensitive bit.
*/
_createClass(SearchUtility, [{

@@ -246,7 +246,7 @@ key: "getCaseSensitive",

}
/**
* Returns a constant representing the current index mode.
*/
}, {

@@ -257,7 +257,7 @@ key: "getIndexMode",

}
/**
* Returns a constant representing the current match-any-token bit.
*/
}, {

@@ -268,7 +268,7 @@ key: "getMatchAnyToken",

}
/**
* Returns a constant representing the current tokenize pattern.
*/
}, {

@@ -279,3 +279,3 @@ key: "getTokenizePattern",

}
/**

@@ -288,4 +288,4 @@ * Adds or updates a uid in the search index and associates it with the specified text.

*/
/**

@@ -303,7 +303,7 @@ * Searches the current index for the specified query text.

*/
}, {
key: "setCaseSensitive",
/**

@@ -315,3 +315,3 @@ * Sets a new case-sensitive bit

}
/**

@@ -321,3 +321,3 @@ * Sets a new index mode.

*/
}, {

@@ -329,10 +329,10 @@ key: "setIndexMode",

}
this._indexMode = indexMode;
}
/**
* Sets a new match-any-token bit
*/
}, {

@@ -343,7 +343,7 @@ key: "setMatchAnyToken",

}
/**
* Sets a new tokenize pattern (regular expression)
*/
}, {

@@ -354,11 +354,11 @@ key: "setTokenizePattern",

}
/**
* Added to make class adhere to interface. Add cleanup code as needed.
*/
}, {
key: "_expandToken",
/**

@@ -384,3 +384,3 @@ * Index strategy based on 'all-substrings-index-strategy.ts' in github.com/bvaughn/js-search/

var expandedTokens = [];
// String.prototype.charAt() may return surrogate halves instead of whole characters.

@@ -395,3 +395,3 @@ // When this happens in the context of a web-worker it can cause Chrome to crash.

var substring = "";
for (var j = i; j < length; ++j) {

@@ -405,3 +405,3 @@ substring += token.charAt(j);

}
return expandedTokens;

@@ -413,3 +413,3 @@ }

var expandedTokens = [];
// String.prototype.charAt() may return surrogate halves instead of whole characters.

@@ -428,10 +428,10 @@ // When this happens in the context of a web-worker it can cause Chrome to crash.

}
return expandedTokens;
}
/**
* @private
*/
}, {

@@ -442,7 +442,7 @@ key: "_sanitize",

}
/**
* @private
*/
}, {

@@ -456,6 +456,6 @@ key: "_tokenize",

}]);
return SearchUtility;
}();
exports.default = SearchUtility;

@@ -468,3 +468,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", {

@@ -478,3 +478,3 @@ value: true

ALL_SUBSTRINGS: "ALL_SUBSTRINGS",
// Indexes for exact word matches only.

@@ -484,3 +484,3 @@ // Based on 'exact-word-index-strategy' from js-search;

EXACT_WORDS: "EXACT_WORDS",
// Indexes for prefix searches (e.g. the term "cat" is indexed as "c", "ca", and "cat" allowing prefix search lookups).

@@ -497,11 +497,11 @@ // Based on 'prefix-index-strategy' from js-search;

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -513,6 +513,6 @@ * Maps search tokens to uids using a trie structure.

_classCallCheck(this, SearchIndex);
this.tokenToUidMap = {};
}
/**

@@ -524,4 +524,4 @@ * Maps the specified token to a uid.

*/
_createClass(SearchIndex, [{

@@ -533,6 +533,6 @@ key: "indexDocument",

}
this.tokenToUidMap[token][uid] = uid;
}
/**

@@ -546,3 +546,3 @@ * Finds uids that have been mapped to the set of tokens specified.

*/
}, {

@@ -552,13 +552,13 @@ key: "search",

var _this = this;
var uidMap = {};
var uidMatches = {};
var initialized = false;
tokens.forEach(function (token) {
var currentUidMap = _this.tokenToUidMap[token] || {};
if (!initialized) {
initialized = true;
for (var _uid in currentUidMap) {

@@ -585,3 +585,3 @@ uidMap[_uid] = currentUidMap[_uid];

});
var uids = [];

@@ -591,3 +591,3 @@ for (var _uid4 in uidMap) {

}
// Sort according to most matches, if match any token is set.

@@ -599,14 +599,13 @@ if (matchAnyToken) {

}
return uids;
}
}]);
return SearchIndex;
}();
exports.default = SearchIndex;
/***/ }
/******/ ]);
//# sourceMappingURL=5cafaba60d6eb1f43c8f.worker.js.map
/******/ ]);

@@ -48,9 +48,2 @@ module.exports =

module.exports = __webpack_require__(1);
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
"use strict";

@@ -63,7 +56,7 @@

var _SearchApi = __webpack_require__(2);
var _SearchApi = __webpack_require__(1);
var _SearchApi2 = _interopRequireDefault(_SearchApi);
var _util = __webpack_require__(3);
var _util = __webpack_require__(2);

@@ -76,3 +69,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/***/ },
/* 2 */
/* 1 */
/***/ function(module, exports, __webpack_require__) {

@@ -86,5 +79,5 @@

var _util = __webpack_require__(3);
var _util = __webpack_require__(2);
var _worker = __webpack_require__(7);
var _worker = __webpack_require__(6);

@@ -178,3 +171,3 @@ var _worker2 = _interopRequireDefault(_worker);

/***/ },
/* 3 */
/* 2 */
/***/ function(module, exports, __webpack_require__) {

@@ -189,7 +182,7 @@

var _SearchUtility = __webpack_require__(4);
var _SearchUtility = __webpack_require__(3);
var _SearchUtility2 = _interopRequireDefault(_SearchUtility);
var _constants = __webpack_require__(5);
var _constants = __webpack_require__(4);

@@ -203,3 +196,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/***/ },
/* 4 */
/* 3 */
/***/ function(module, exports, __webpack_require__) {

@@ -215,5 +208,5 @@

var _constants = __webpack_require__(5);
var _constants = __webpack_require__(4);
var _SearchIndex = __webpack_require__(6);
var _SearchIndex = __webpack_require__(5);

@@ -502,3 +495,3 @@ var _SearchIndex2 = _interopRequireDefault(_SearchIndex);

/***/ },
/* 5 */
/* 4 */
/***/ function(module, exports) {

@@ -529,3 +522,3 @@

/***/ },
/* 6 */
/* 5 */
/***/ function(module, exports) {

@@ -639,3 +632,3 @@

/***/ },
/* 7 */
/* 6 */
/***/ function(module, exports, __webpack_require__) {

@@ -649,3 +642,3 @@

var _SearchWorkerLoader = __webpack_require__(8);
var _SearchWorkerLoader = __webpack_require__(7);

@@ -659,3 +652,3 @@ var _SearchWorkerLoader2 = _interopRequireDefault(_SearchWorkerLoader);

/***/ },
/* 8 */
/* 7 */
/***/ function(module, exports, __webpack_require__) {

@@ -671,3 +664,3 @@

var _uuid = __webpack_require__(9);
var _uuid = __webpack_require__(8);

@@ -744,3 +737,3 @@ var _uuid2 = _interopRequireDefault(_uuid);

// $FlowFixMe eslint-disable-next-line
WorkerClass = __webpack_require__(11);
WorkerClass = __webpack_require__(10);
}

@@ -876,3 +869,3 @@

/***/ },
/* 9 */
/* 8 */
/***/ function(module, exports, __webpack_require__) {

@@ -888,3 +881,3 @@

// returns 128-bits of randomness, since that's what's usually required
var _rng = __webpack_require__(10);
var _rng = __webpack_require__(9);

@@ -1067,3 +1060,3 @@ // Maps for number <-> hex string conversion

/***/ },
/* 10 */
/* 9 */
/***/ function(module, exports) {

@@ -1107,11 +1100,11 @@

/***/ },
/* 11 */
/* 10 */
/***/ function(module, exports, __webpack_require__) {
module.exports = function() {
return __webpack_require__(12)("/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\"use strict\";\n\t\n\tvar _util = __webpack_require__(1);\n\t\n\t/**\n\t * Search entry point to web worker.\n\t * Builds search index and performs searches on separate thread from the ui.\n\t */\n\t\n\tvar searchUtility = new _util.SearchUtility();\n\t\n\tself.addEventListener(\"message\", function (event) {\n\t var data = event.data;\n\t var method = data.method;\n\t\n\t\n\t switch (method) {\n\t case \"indexDocument\":\n\t var uid = data.uid,\n\t text = data.text;\n\t\n\t\n\t searchUtility.indexDocument(uid, text);\n\t break;\n\t case \"search\":\n\t var callbackId = data.callbackId,\n\t query = data.query;\n\t\n\t\n\t var results = searchUtility.search(query);\n\t\n\t self.postMessage({ callbackId: callbackId, results: results });\n\t break;\n\t case \"setCaseSensitive\":\n\t var caseSensitive = data.caseSensitive;\n\t\n\t\n\t searchUtility.setCaseSensitive(caseSensitive);\n\t break;\n\t case \"setIndexMode\":\n\t var indexMode = data.indexMode;\n\t\n\t\n\t searchUtility.setIndexMode(indexMode);\n\t break;\n\t case \"setMatchAnyToken\":\n\t var matchAnyToken = data.matchAnyToken;\n\t\n\t\n\t searchUtility.setMatchAnyToken(matchAnyToken);\n\t break;\n\t case \"setTokenizePattern\":\n\t var tokenizePattern = data.tokenizePattern;\n\t\n\t\n\t searchUtility.setTokenizePattern(tokenizePattern);\n\t break;\n\t }\n\t}, false);\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\"use strict\";\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\texports.SearchUtility = exports.INDEX_MODES = undefined;\n\t\n\tvar _SearchUtility = __webpack_require__(2);\n\t\n\tvar _SearchUtility2 = _interopRequireDefault(_SearchUtility);\n\t\n\tvar _constants = __webpack_require__(3);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\texports.default = _SearchUtility2.default;\n\texports.INDEX_MODES = _constants.INDEX_MODES;\n\texports.SearchUtility = _SearchUtility2.default;\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\"use strict\";\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\t\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\t\n\tvar _constants = __webpack_require__(3);\n\t\n\tvar _SearchIndex = __webpack_require__(4);\n\t\n\tvar _SearchIndex2 = _interopRequireDefault(_SearchIndex);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/**\n\t * Synchronous client-side full-text search utility.\n\t * Forked from JS search (github.com/bvaughn/js-search).\n\t */\n\tvar SearchUtility = function () {\n\t\n\t /**\n\t * Constructor.\n\t *\n\t * @param indexMode See #setIndexMode\n\t * @param tokenizePattern See #setTokenizePattern\n\t * @param caseSensitive See #setCaseSensitive\n\t * @param matchAnyToken See #setMatchAnyToken\n\t */\n\t function SearchUtility() {\n\t var _this = this;\n\t\n\t var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n\t _ref$caseSensitive = _ref.caseSensitive,\n\t caseSensitive = _ref$caseSensitive === undefined ? false : _ref$caseSensitive,\n\t _ref$indexMode = _ref.indexMode,\n\t indexMode = _ref$indexMode === undefined ? _constants.INDEX_MODES.ALL_SUBSTRINGS : _ref$indexMode,\n\t _ref$matchAnyToken = _ref.matchAnyToken,\n\t matchAnyToken = _ref$matchAnyToken === undefined ? false : _ref$matchAnyToken,\n\t _ref$tokenizePattern = _ref.tokenizePattern,\n\t tokenizePattern = _ref$tokenizePattern === undefined ? /\\s+/ : _ref$tokenizePattern;\n\t\n\t _classCallCheck(this, SearchUtility);\n\t\n\t this.indexDocument = function (uid, text) {\n\t _this._uids[uid] = true;\n\t\n\t var fieldTokens = _this._tokenize(_this._sanitize(text));\n\t\n\t fieldTokens.forEach(function (fieldToken) {\n\t var expandedTokens = _this._expandToken(fieldToken);\n\t\n\t expandedTokens.forEach(function (expandedToken) {\n\t _this._searchIndex.indexDocument(expandedToken, uid);\n\t });\n\t });\n\t\n\t return _this;\n\t };\n\t\n\t this.search = function (query) {\n\t if (!query) {\n\t return Object.keys(_this._uids);\n\t } else {\n\t var tokens = _this._tokenize(_this._sanitize(query));\n\t\n\t return _this._searchIndex.search(tokens, _this._matchAnyToken);\n\t }\n\t };\n\t\n\t this.terminate = function () {};\n\t\n\t this._caseSensitive = caseSensitive;\n\t this._indexMode = indexMode;\n\t this._matchAnyToken = matchAnyToken;\n\t this._tokenizePattern = tokenizePattern;\n\t\n\t this._searchIndex = new _SearchIndex2.default();\n\t this._uids = {};\n\t }\n\t\n\t /**\n\t * Returns a constant representing the current case-sensitive bit.\n\t */\n\t\n\t\n\t _createClass(SearchUtility, [{\n\t key: \"getCaseSensitive\",\n\t value: function getCaseSensitive() {\n\t return this._caseSensitive;\n\t }\n\t\n\t /**\n\t * Returns a constant representing the current index mode.\n\t */\n\t\n\t }, {\n\t key: \"getIndexMode\",\n\t value: function getIndexMode() {\n\t return this._indexMode;\n\t }\n\t\n\t /**\n\t * Returns a constant representing the current match-any-token bit.\n\t */\n\t\n\t }, {\n\t key: \"getMatchAnyToken\",\n\t value: function getMatchAnyToken() {\n\t return this._matchAnyToken;\n\t }\n\t\n\t /**\n\t * Returns a constant representing the current tokenize pattern.\n\t */\n\t\n\t }, {\n\t key: \"getTokenizePattern\",\n\t value: function getTokenizePattern() {\n\t return this._tokenizePattern;\n\t }\n\t\n\t /**\n\t * Adds or updates a uid in the search index and associates it with the specified text.\n\t * Note that at this time uids can only be added or updated in the index, not removed.\n\t *\n\t * @param uid Uniquely identifies a searchable object\n\t * @param text Text to associate with uid\n\t */\n\t\n\t\n\t /**\n\t * Searches the current index for the specified query text.\n\t * Only uids matching all of the words within the text will be accepted,\n\t * unless matchAny is set to true.\n\t * If an empty query string is provided all indexed uids will be returned.\n\t *\n\t * Document searches are case-insensitive by default (e.g. \"search\" will match \"Search\").\n\t * Document searches use substring matching by default (e.g. \"na\" and \"me\" will both match \"name\").\n\t *\n\t * @param query Searchable query text\n\t * @return Array of uids\n\t */\n\t\n\t }, {\n\t key: \"setCaseSensitive\",\n\t\n\t\n\t /**\n\t * Sets a new case-sensitive bit\n\t */\n\t value: function setCaseSensitive(caseSensitive) {\n\t this._caseSensitive = caseSensitive;\n\t }\n\t\n\t /**\n\t * Sets a new index mode.\n\t * See util/constants/INDEX_MODES\n\t */\n\t\n\t }, {\n\t key: \"setIndexMode\",\n\t value: function setIndexMode(indexMode) {\n\t if (Object.keys(this._uids).length > 0) {\n\t throw Error(\"indexMode cannot be changed once documents have been indexed\");\n\t }\n\t\n\t this._indexMode = indexMode;\n\t }\n\t\n\t /**\n\t * Sets a new match-any-token bit\n\t */\n\t\n\t }, {\n\t key: \"setMatchAnyToken\",\n\t value: function setMatchAnyToken(matchAnyToken) {\n\t this._matchAnyToken = matchAnyToken;\n\t }\n\t\n\t /**\n\t * Sets a new tokenize pattern (regular expression)\n\t */\n\t\n\t }, {\n\t key: \"setTokenizePattern\",\n\t value: function setTokenizePattern(pattern) {\n\t this._tokenizePattern = pattern;\n\t }\n\t\n\t /**\n\t * Added to make class adhere to interface. Add cleanup code as needed.\n\t */\n\t\n\t }, {\n\t key: \"_expandToken\",\n\t\n\t\n\t /**\n\t * Index strategy based on 'all-substrings-index-strategy.ts' in github.com/bvaughn/js-search/\n\t *\n\t * @private\n\t */\n\t value: function _expandToken(token) {\n\t switch (this._indexMode) {\n\t case _constants.INDEX_MODES.EXACT_WORDS:\n\t return [token];\n\t case _constants.INDEX_MODES.PREFIXES:\n\t return this._expandPrefixTokens(token);\n\t case _constants.INDEX_MODES.ALL_SUBSTRINGS:\n\t default:\n\t return this._expandAllSubstringTokens(token);\n\t }\n\t }\n\t }, {\n\t key: \"_expandAllSubstringTokens\",\n\t value: function _expandAllSubstringTokens(token) {\n\t var expandedTokens = [];\n\t\n\t // String.prototype.charAt() may return surrogate halves instead of whole characters.\n\t // When this happens in the context of a web-worker it can cause Chrome to crash.\n\t // Catching the error is a simple solution for now; in the future I may try to better support non-BMP characters.\n\t // Resources:\n\t // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt\n\t // https://mathiasbynens.be/notes/javascript-unicode\n\t try {\n\t for (var i = 0, length = token.length; i < length; ++i) {\n\t var substring = \"\";\n\t\n\t for (var j = i; j < length; ++j) {\n\t substring += token.charAt(j);\n\t expandedTokens.push(substring);\n\t }\n\t }\n\t } catch (error) {\n\t console.error(\"Unable to parse token \\\"\" + token + \"\\\" \" + error);\n\t }\n\t\n\t return expandedTokens;\n\t }\n\t }, {\n\t key: \"_expandPrefixTokens\",\n\t value: function _expandPrefixTokens(token) {\n\t var expandedTokens = [];\n\t\n\t // String.prototype.charAt() may return surrogate halves instead of whole characters.\n\t // When this happens in the context of a web-worker it can cause Chrome to crash.\n\t // Catching the error is a simple solution for now; in the future I may try to better support non-BMP characters.\n\t // Resources:\n\t // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt\n\t // https://mathiasbynens.be/notes/javascript-unicode\n\t try {\n\t for (var i = 0, length = token.length; i < length; ++i) {\n\t expandedTokens.push(token.substr(0, i + 1));\n\t }\n\t } catch (error) {\n\t console.error(\"Unable to parse token \\\"\" + token + \"\\\" \" + error);\n\t }\n\t\n\t return expandedTokens;\n\t }\n\t\n\t /**\n\t * @private\n\t */\n\t\n\t }, {\n\t key: \"_sanitize\",\n\t value: function _sanitize(string) {\n\t return this._caseSensitive ? string.trim() : string.trim().toLocaleLowerCase();\n\t }\n\t\n\t /**\n\t * @private\n\t */\n\t\n\t }, {\n\t key: \"_tokenize\",\n\t value: function _tokenize(text) {\n\t return text.split(this._tokenizePattern).filter(function (text) {\n\t return text;\n\t }); // Remove empty tokens\n\t }\n\t }]);\n\t\n\t return SearchUtility;\n\t}();\n\t\n\texports.default = SearchUtility;\n\n/***/ },\n/* 3 */\n/***/ function(module, exports) {\n\n\t\"use strict\";\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\tvar INDEX_MODES = exports.INDEX_MODES = {\n\t // Indexes for all substring searches (e.g. the term \"cat\" is indexed as \"c\", \"ca\", \"cat\", \"a\", \"at\", and \"t\").\n\t // Based on 'all-substrings-index-strategy' from js-search;\n\t // github.com/bvaughn/js-search/blob/master/source/index-strategy/all-substrings-index-strategy.ts\n\t ALL_SUBSTRINGS: \"ALL_SUBSTRINGS\",\n\t\n\t // Indexes for exact word matches only.\n\t // Based on 'exact-word-index-strategy' from js-search;\n\t // github.com/bvaughn/js-search/blob/master/source/index-strategy/exact-word-index-strategy.ts\n\t EXACT_WORDS: \"EXACT_WORDS\",\n\t\n\t // Indexes for prefix searches (e.g. the term \"cat\" is indexed as \"c\", \"ca\", and \"cat\" allowing prefix search lookups).\n\t // Based on 'prefix-index-strategy' from js-search;\n\t // github.com/bvaughn/js-search/blob/master/source/index-strategy/prefix-index-strategy.ts\n\t PREFIXES: \"PREFIXES\"\n\t};\n\n/***/ },\n/* 4 */\n/***/ function(module, exports) {\n\n\t\"use strict\";\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\t\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/**\n\t * Maps search tokens to uids using a trie structure.\n\t */\n\tvar SearchIndex = function () {\n\t function SearchIndex() {\n\t _classCallCheck(this, SearchIndex);\n\t\n\t this.tokenToUidMap = {};\n\t }\n\t\n\t /**\n\t * Maps the specified token to a uid.\n\t *\n\t * @param token Searchable token (e.g. \"road\")\n\t * @param uid Identifies a document within the searchable corpus\n\t */\n\t\n\t\n\t _createClass(SearchIndex, [{\n\t key: \"indexDocument\",\n\t value: function indexDocument(token, uid) {\n\t if (!this.tokenToUidMap[token]) {\n\t this.tokenToUidMap[token] = {};\n\t }\n\t\n\t this.tokenToUidMap[token][uid] = uid;\n\t }\n\t\n\t /**\n\t * Finds uids that have been mapped to the set of tokens specified.\n\t * Only uids that have been mapped to all tokens will be returned.\n\t *\n\t * @param tokens Array of searchable tokens (e.g. [\"long\", \"road\"])\n\t * @param matchAnyToken Whether to match any token. Default is false.\n\t * @return Array of uids that have been associated with the set of search tokens\n\t */\n\t\n\t }, {\n\t key: \"search\",\n\t value: function search(tokens, matchAnyToken) {\n\t var _this = this;\n\t\n\t var uidMap = {};\n\t var uidMatches = {};\n\t var initialized = false;\n\t\n\t tokens.forEach(function (token) {\n\t var currentUidMap = _this.tokenToUidMap[token] || {};\n\t\n\t if (!initialized) {\n\t initialized = true;\n\t\n\t for (var _uid in currentUidMap) {\n\t uidMap[_uid] = currentUidMap[_uid];\n\t uidMatches[_uid] = 1;\n\t }\n\t } else {\n\t // Delete existing matches if using and AND query (the default)\n\t // Otherwise add new results to the matches\n\t if (!matchAnyToken) {\n\t for (var _uid2 in uidMap) {\n\t if (!currentUidMap[_uid2]) {\n\t delete uidMap[_uid2];\n\t }\n\t }\n\t } else {\n\t for (var _uid3 in currentUidMap) {\n\t uidMap[_uid3] = currentUidMap[_uid3];\n\t uidMatches[_uid3] = (uidMatches[_uid3] || 0) + 1;\n\t }\n\t }\n\t }\n\t });\n\t\n\t var uids = [];\n\t for (var _uid4 in uidMap) {\n\t uids.push(uidMap[_uid4]);\n\t }\n\t\n\t // Sort according to most matches, if match any token is set.\n\t if (matchAnyToken) {\n\t uids.sort(function (a, b) {\n\t return uidMatches[b] - uidMatches[a];\n\t });\n\t }\n\t\n\t return uids;\n\t }\n\t }]);\n\t\n\t return SearchIndex;\n\t}();\n\t\n\texports.default = SearchIndex;\n\n/***/ }\n/******/ ]);\n//# sourceMappingURL=5cafaba60d6eb1f43c8f.worker.js.map", __webpack_require__.p + "5cafaba60d6eb1f43c8f.worker.js");
return __webpack_require__(11)("/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n\n\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\"use strict\";\n\n\tvar _util = __webpack_require__(1);\n\n\t/**\n\t * Search entry point to web worker.\n\t * Builds search index and performs searches on separate thread from the ui.\n\t */\n\n\tvar searchUtility = new _util.SearchUtility();\n\n\tself.addEventListener(\"message\", function (event) {\n\t var data = event.data;\n\t var method = data.method;\n\n\n\t switch (method) {\n\t case \"indexDocument\":\n\t var uid = data.uid,\n\t text = data.text;\n\n\n\t searchUtility.indexDocument(uid, text);\n\t break;\n\t case \"search\":\n\t var callbackId = data.callbackId,\n\t query = data.query;\n\n\n\t var results = searchUtility.search(query);\n\n\t self.postMessage({ callbackId: callbackId, results: results });\n\t break;\n\t case \"setCaseSensitive\":\n\t var caseSensitive = data.caseSensitive;\n\n\n\t searchUtility.setCaseSensitive(caseSensitive);\n\t break;\n\t case \"setIndexMode\":\n\t var indexMode = data.indexMode;\n\n\n\t searchUtility.setIndexMode(indexMode);\n\t break;\n\t case \"setMatchAnyToken\":\n\t var matchAnyToken = data.matchAnyToken;\n\n\n\t searchUtility.setMatchAnyToken(matchAnyToken);\n\t break;\n\t case \"setTokenizePattern\":\n\t var tokenizePattern = data.tokenizePattern;\n\n\n\t searchUtility.setTokenizePattern(tokenizePattern);\n\t break;\n\t }\n\t}, false);\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\"use strict\";\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\texports.SearchUtility = exports.INDEX_MODES = undefined;\n\n\tvar _SearchUtility = __webpack_require__(2);\n\n\tvar _SearchUtility2 = _interopRequireDefault(_SearchUtility);\n\n\tvar _constants = __webpack_require__(3);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\texports.default = _SearchUtility2.default;\n\texports.INDEX_MODES = _constants.INDEX_MODES;\n\texports.SearchUtility = _SearchUtility2.default;\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\"use strict\";\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _constants = __webpack_require__(3);\n\n\tvar _SearchIndex = __webpack_require__(4);\n\n\tvar _SearchIndex2 = _interopRequireDefault(_SearchIndex);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\t/**\n\t * Synchronous client-side full-text search utility.\n\t * Forked from JS search (github.com/bvaughn/js-search).\n\t */\n\tvar SearchUtility = function () {\n\n\t /**\n\t * Constructor.\n\t *\n\t * @param indexMode See #setIndexMode\n\t * @param tokenizePattern See #setTokenizePattern\n\t * @param caseSensitive See #setCaseSensitive\n\t * @param matchAnyToken See #setMatchAnyToken\n\t */\n\t function SearchUtility() {\n\t var _this = this;\n\n\t var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n\t _ref$caseSensitive = _ref.caseSensitive,\n\t caseSensitive = _ref$caseSensitive === undefined ? false : _ref$caseSensitive,\n\t _ref$indexMode = _ref.indexMode,\n\t indexMode = _ref$indexMode === undefined ? _constants.INDEX_MODES.ALL_SUBSTRINGS : _ref$indexMode,\n\t _ref$matchAnyToken = _ref.matchAnyToken,\n\t matchAnyToken = _ref$matchAnyToken === undefined ? false : _ref$matchAnyToken,\n\t _ref$tokenizePattern = _ref.tokenizePattern,\n\t tokenizePattern = _ref$tokenizePattern === undefined ? /\\s+/ : _ref$tokenizePattern;\n\n\t _classCallCheck(this, SearchUtility);\n\n\t this.indexDocument = function (uid, text) {\n\t _this._uids[uid] = true;\n\n\t var fieldTokens = _this._tokenize(_this._sanitize(text));\n\n\t fieldTokens.forEach(function (fieldToken) {\n\t var expandedTokens = _this._expandToken(fieldToken);\n\n\t expandedTokens.forEach(function (expandedToken) {\n\t _this._searchIndex.indexDocument(expandedToken, uid);\n\t });\n\t });\n\n\t return _this;\n\t };\n\n\t this.search = function (query) {\n\t if (!query) {\n\t return Object.keys(_this._uids);\n\t } else {\n\t var tokens = _this._tokenize(_this._sanitize(query));\n\n\t return _this._searchIndex.search(tokens, _this._matchAnyToken);\n\t }\n\t };\n\n\t this.terminate = function () {};\n\n\t this._caseSensitive = caseSensitive;\n\t this._indexMode = indexMode;\n\t this._matchAnyToken = matchAnyToken;\n\t this._tokenizePattern = tokenizePattern;\n\n\t this._searchIndex = new _SearchIndex2.default();\n\t this._uids = {};\n\t }\n\n\t /**\n\t * Returns a constant representing the current case-sensitive bit.\n\t */\n\n\n\t _createClass(SearchUtility, [{\n\t key: \"getCaseSensitive\",\n\t value: function getCaseSensitive() {\n\t return this._caseSensitive;\n\t }\n\n\t /**\n\t * Returns a constant representing the current index mode.\n\t */\n\n\t }, {\n\t key: \"getIndexMode\",\n\t value: function getIndexMode() {\n\t return this._indexMode;\n\t }\n\n\t /**\n\t * Returns a constant representing the current match-any-token bit.\n\t */\n\n\t }, {\n\t key: \"getMatchAnyToken\",\n\t value: function getMatchAnyToken() {\n\t return this._matchAnyToken;\n\t }\n\n\t /**\n\t * Returns a constant representing the current tokenize pattern.\n\t */\n\n\t }, {\n\t key: \"getTokenizePattern\",\n\t value: function getTokenizePattern() {\n\t return this._tokenizePattern;\n\t }\n\n\t /**\n\t * Adds or updates a uid in the search index and associates it with the specified text.\n\t * Note that at this time uids can only be added or updated in the index, not removed.\n\t *\n\t * @param uid Uniquely identifies a searchable object\n\t * @param text Text to associate with uid\n\t */\n\n\n\t /**\n\t * Searches the current index for the specified query text.\n\t * Only uids matching all of the words within the text will be accepted,\n\t * unless matchAny is set to true.\n\t * If an empty query string is provided all indexed uids will be returned.\n\t *\n\t * Document searches are case-insensitive by default (e.g. \"search\" will match \"Search\").\n\t * Document searches use substring matching by default (e.g. \"na\" and \"me\" will both match \"name\").\n\t *\n\t * @param query Searchable query text\n\t * @return Array of uids\n\t */\n\n\t }, {\n\t key: \"setCaseSensitive\",\n\n\n\t /**\n\t * Sets a new case-sensitive bit\n\t */\n\t value: function setCaseSensitive(caseSensitive) {\n\t this._caseSensitive = caseSensitive;\n\t }\n\n\t /**\n\t * Sets a new index mode.\n\t * See util/constants/INDEX_MODES\n\t */\n\n\t }, {\n\t key: \"setIndexMode\",\n\t value: function setIndexMode(indexMode) {\n\t if (Object.keys(this._uids).length > 0) {\n\t throw Error(\"indexMode cannot be changed once documents have been indexed\");\n\t }\n\n\t this._indexMode = indexMode;\n\t }\n\n\t /**\n\t * Sets a new match-any-token bit\n\t */\n\n\t }, {\n\t key: \"setMatchAnyToken\",\n\t value: function setMatchAnyToken(matchAnyToken) {\n\t this._matchAnyToken = matchAnyToken;\n\t }\n\n\t /**\n\t * Sets a new tokenize pattern (regular expression)\n\t */\n\n\t }, {\n\t key: \"setTokenizePattern\",\n\t value: function setTokenizePattern(pattern) {\n\t this._tokenizePattern = pattern;\n\t }\n\n\t /**\n\t * Added to make class adhere to interface. Add cleanup code as needed.\n\t */\n\n\t }, {\n\t key: \"_expandToken\",\n\n\n\t /**\n\t * Index strategy based on 'all-substrings-index-strategy.ts' in github.com/bvaughn/js-search/\n\t *\n\t * @private\n\t */\n\t value: function _expandToken(token) {\n\t switch (this._indexMode) {\n\t case _constants.INDEX_MODES.EXACT_WORDS:\n\t return [token];\n\t case _constants.INDEX_MODES.PREFIXES:\n\t return this._expandPrefixTokens(token);\n\t case _constants.INDEX_MODES.ALL_SUBSTRINGS:\n\t default:\n\t return this._expandAllSubstringTokens(token);\n\t }\n\t }\n\t }, {\n\t key: \"_expandAllSubstringTokens\",\n\t value: function _expandAllSubstringTokens(token) {\n\t var expandedTokens = [];\n\n\t // String.prototype.charAt() may return surrogate halves instead of whole characters.\n\t // When this happens in the context of a web-worker it can cause Chrome to crash.\n\t // Catching the error is a simple solution for now; in the future I may try to better support non-BMP characters.\n\t // Resources:\n\t // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt\n\t // https://mathiasbynens.be/notes/javascript-unicode\n\t try {\n\t for (var i = 0, length = token.length; i < length; ++i) {\n\t var substring = \"\";\n\n\t for (var j = i; j < length; ++j) {\n\t substring += token.charAt(j);\n\t expandedTokens.push(substring);\n\t }\n\t }\n\t } catch (error) {\n\t console.error(\"Unable to parse token \\\"\" + token + \"\\\" \" + error);\n\t }\n\n\t return expandedTokens;\n\t }\n\t }, {\n\t key: \"_expandPrefixTokens\",\n\t value: function _expandPrefixTokens(token) {\n\t var expandedTokens = [];\n\n\t // String.prototype.charAt() may return surrogate halves instead of whole characters.\n\t // When this happens in the context of a web-worker it can cause Chrome to crash.\n\t // Catching the error is a simple solution for now; in the future I may try to better support non-BMP characters.\n\t // Resources:\n\t // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt\n\t // https://mathiasbynens.be/notes/javascript-unicode\n\t try {\n\t for (var i = 0, length = token.length; i < length; ++i) {\n\t expandedTokens.push(token.substr(0, i + 1));\n\t }\n\t } catch (error) {\n\t console.error(\"Unable to parse token \\\"\" + token + \"\\\" \" + error);\n\t }\n\n\t return expandedTokens;\n\t }\n\n\t /**\n\t * @private\n\t */\n\n\t }, {\n\t key: \"_sanitize\",\n\t value: function _sanitize(string) {\n\t return this._caseSensitive ? string.trim() : string.trim().toLocaleLowerCase();\n\t }\n\n\t /**\n\t * @private\n\t */\n\n\t }, {\n\t key: \"_tokenize\",\n\t value: function _tokenize(text) {\n\t return text.split(this._tokenizePattern).filter(function (text) {\n\t return text;\n\t }); // Remove empty tokens\n\t }\n\t }]);\n\n\t return SearchUtility;\n\t}();\n\n\texports.default = SearchUtility;\n\n/***/ },\n/* 3 */\n/***/ function(module, exports) {\n\n\t\"use strict\";\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\tvar INDEX_MODES = exports.INDEX_MODES = {\n\t // Indexes for all substring searches (e.g. the term \"cat\" is indexed as \"c\", \"ca\", \"cat\", \"a\", \"at\", and \"t\").\n\t // Based on 'all-substrings-index-strategy' from js-search;\n\t // github.com/bvaughn/js-search/blob/master/source/index-strategy/all-substrings-index-strategy.ts\n\t ALL_SUBSTRINGS: \"ALL_SUBSTRINGS\",\n\n\t // Indexes for exact word matches only.\n\t // Based on 'exact-word-index-strategy' from js-search;\n\t // github.com/bvaughn/js-search/blob/master/source/index-strategy/exact-word-index-strategy.ts\n\t EXACT_WORDS: \"EXACT_WORDS\",\n\n\t // Indexes for prefix searches (e.g. the term \"cat\" is indexed as \"c\", \"ca\", and \"cat\" allowing prefix search lookups).\n\t // Based on 'prefix-index-strategy' from js-search;\n\t // github.com/bvaughn/js-search/blob/master/source/index-strategy/prefix-index-strategy.ts\n\t PREFIXES: \"PREFIXES\"\n\t};\n\n/***/ },\n/* 4 */\n/***/ function(module, exports) {\n\n\t\"use strict\";\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\t/**\n\t * Maps search tokens to uids using a trie structure.\n\t */\n\tvar SearchIndex = function () {\n\t function SearchIndex() {\n\t _classCallCheck(this, SearchIndex);\n\n\t this.tokenToUidMap = {};\n\t }\n\n\t /**\n\t * Maps the specified token to a uid.\n\t *\n\t * @param token Searchable token (e.g. \"road\")\n\t * @param uid Identifies a document within the searchable corpus\n\t */\n\n\n\t _createClass(SearchIndex, [{\n\t key: \"indexDocument\",\n\t value: function indexDocument(token, uid) {\n\t if (!this.tokenToUidMap[token]) {\n\t this.tokenToUidMap[token] = {};\n\t }\n\n\t this.tokenToUidMap[token][uid] = uid;\n\t }\n\n\t /**\n\t * Finds uids that have been mapped to the set of tokens specified.\n\t * Only uids that have been mapped to all tokens will be returned.\n\t *\n\t * @param tokens Array of searchable tokens (e.g. [\"long\", \"road\"])\n\t * @param matchAnyToken Whether to match any token. Default is false.\n\t * @return Array of uids that have been associated with the set of search tokens\n\t */\n\n\t }, {\n\t key: \"search\",\n\t value: function search(tokens, matchAnyToken) {\n\t var _this = this;\n\n\t var uidMap = {};\n\t var uidMatches = {};\n\t var initialized = false;\n\n\t tokens.forEach(function (token) {\n\t var currentUidMap = _this.tokenToUidMap[token] || {};\n\n\t if (!initialized) {\n\t initialized = true;\n\n\t for (var _uid in currentUidMap) {\n\t uidMap[_uid] = currentUidMap[_uid];\n\t uidMatches[_uid] = 1;\n\t }\n\t } else {\n\t // Delete existing matches if using and AND query (the default)\n\t // Otherwise add new results to the matches\n\t if (!matchAnyToken) {\n\t for (var _uid2 in uidMap) {\n\t if (!currentUidMap[_uid2]) {\n\t delete uidMap[_uid2];\n\t }\n\t }\n\t } else {\n\t for (var _uid3 in currentUidMap) {\n\t uidMap[_uid3] = currentUidMap[_uid3];\n\t uidMatches[_uid3] = (uidMatches[_uid3] || 0) + 1;\n\t }\n\t }\n\t }\n\t });\n\n\t var uids = [];\n\t for (var _uid4 in uidMap) {\n\t uids.push(uidMap[_uid4]);\n\t }\n\n\t // Sort according to most matches, if match any token is set.\n\t if (matchAnyToken) {\n\t uids.sort(function (a, b) {\n\t return uidMatches[b] - uidMatches[a];\n\t });\n\t }\n\n\t return uids;\n\t }\n\t }]);\n\n\t return SearchIndex;\n\t}();\n\n\texports.default = SearchIndex;\n\n/***/ }\n/******/ ]);", __webpack_require__.p + "5cafaba60d6eb1f43c8f.worker.js");
};
/***/ },
/* 12 */
/* 11 */
/***/ function(module, exports) {

@@ -1118,0 +1111,0 @@

{
"name": "js-worker-search",
"version": "1.4.0",
"version": "1.4.1",
"description": "JavaScript client-side search API with web-worker support",

@@ -20,3 +20,3 @@ "author": "Brian Vaughn (brian.david.vaughn@gmail.com)",

"pretest": "yarn run flow && yarn run prettier && yarn run lint",
"prettier": "prettier --write 'src/**/*.js'",
"prettier": "prettier --write '{src/**,.}/*.js'",
"start": "watch 'clear && yarn run lint -s && yarn run test -s' src",

@@ -23,0 +23,0 @@ "test": "jest"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc