New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tiny-trie

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-trie - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

docs/assets/css/main.css

528

dist/packed-trie.js

@@ -10,477 +10,135 @@ (function webpackUniversalModuleDefinition(root, factory) {

root["TinyTrie"] = factory();
})(this, function() {
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ module.l = 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;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ return __webpack_require__(__webpack_require__.s = "./lib/PackedTrie.ts");
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/******/ ({
'use strict';
/***/ "./lib sync recursive":
/*!******************!*\
!*** ./lib sync ***!
\******************/
/*! no static exports found */
/***/ (function(module, exports) {
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; }; })(); /**
* @file Small class for querying a binary-encoded Trie
*
* TODO - rewrite as a native class. Babel adds a lot of overhead. This class
* should be tiny and transparent.
*/
eval("function webpackEmptyContext(req) {\n\tvar e = new Error('Cannot find module \"' + req + '\".');\n\te.code = 'MODULE_NOT_FOUND';\n\tthrow e;\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nmodule.exports = webpackEmptyContext;\nwebpackEmptyContext.id = \"./lib sync recursive\";\n\n//# sourceURL=webpack://TinyTrie/./lib_sync?");
Object.defineProperty(exports, "__esModule", {
value: true
});
/***/ }),
var _base = __webpack_require__(1);
/***/ "./lib/PackedTrie.ts":
/*!***************************!*\
!*** ./lib/PackedTrie.ts ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var _constants = __webpack_require__(2);
"use strict";
eval("/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nvar _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\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n(function (factory) {\n if (( false ? undefined : _typeof(module)) === \"object\" && _typeof(module.exports) === \"object\") {\n var v = factory(__webpack_require__(\"./lib sync recursive\"), exports);\n if (v !== undefined) module.exports = v;\n } else if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ./base64 */ \"./lib/base64.ts\"), __webpack_require__(/*! ./constants */ \"./lib/constants.ts\")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n})(function (require, exports) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", { value: true });\n var base64_1 = require(\"./base64\");\n var constants_1 = require(\"./constants\");\n function readBits(binary, start, len) {\n var startChar = ~~(start / 6);\n var startBitOffset = start % 6;\n var endBit = startBitOffset + len;\n var charLen = Math.ceil(endBit / 6);\n var mask = (0x1 << len) - 1;\n var chunk = 0;\n for (var i = 0; i < charLen; i++) {\n chunk <<= 6;\n chunk |= base64_1.BASE64_CHAR_TO_INT[binary[startChar + i]];\n }\n var rightPadding = endBit % 6;\n if (rightPadding) {\n chunk >>= 6 - rightPadding;\n }\n return chunk & mask;\n }\n\n var PackedTrie = function () {\n function PackedTrie(binary) {\n _classCallCheck(this, PackedTrie);\n\n this.lastMask = 0x1;\n this.pointerShift = 1;\n var ptr = 0;\n var headerCharCount = readBits(binary, ptr, constants_1.HEADER_WIDTH_FIELD);\n ptr += constants_1.HEADER_WIDTH_FIELD;\n var header = binary.substr(0, headerCharCount);\n var version = readBits(binary, ptr, constants_1.VERSION_FIELD);\n ptr += constants_1.VERSION_FIELD;\n if (version !== constants_1.VERSION) {\n throw new Error(\"Version mismatch! Binary: \" + version + \", Reader: \" + constants_1.VERSION);\n }\n this.data = binary.substr(headerCharCount);\n var offsetSign = readBits(header, ptr, constants_1.OFFSET_SIGN_FIELD);\n ptr += constants_1.OFFSET_SIGN_FIELD;\n var offset = readBits(header, ptr, constants_1.OFFSET_VAL_FIELD);\n ptr += constants_1.OFFSET_VAL_FIELD;\n if (offsetSign) {\n offset = -offset;\n }\n this.offset = offset;\n var charWidth = readBits(header, ptr, constants_1.CHAR_WIDTH_FIELD);\n ptr += constants_1.CHAR_WIDTH_FIELD;\n var pointerWidth = readBits(header, ptr, constants_1.POINTER_WIDTH_FIELD);\n ptr += constants_1.POINTER_WIDTH_FIELD;\n var headerFieldChars = Math.ceil(ptr / 6);\n var charTable = header.substr(headerFieldChars);\n this.table = charTable.split('').reduce(function (agg, char, i) {\n agg[char] = i + 1;\n return agg;\n }, _defineProperty({}, constants_1.TERMINAL, 0));\n this.inverseTable = [constants_1.TERMINAL].concat(charTable.split(''));\n this.wordWidth = charWidth + pointerWidth + 1;\n this.pointerMask = (0x1 << pointerWidth) - 1;\n this.charMask = (0x1 << charWidth) - 1;\n this.charShift = 1 + pointerWidth;\n }\n\n _createClass(PackedTrie, [{\n key: \"test\",\n value: function test(str) {\n var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { wildcard: null, prefix: false },\n wildcard = _ref.wildcard,\n prefix = _ref.prefix;\n\n return this.search(str, { wildcard: wildcard, prefix: prefix, first: true }) !== null;\n }\n }, {\n key: \"search\",\n value: function search(str) {\n var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { wildcard: null, prefix: false, first: false },\n wildcard = _ref2.wildcard,\n prefix = _ref2.prefix,\n first = _ref2.first;\n\n if (wildcard && wildcard.length !== 1) {\n throw new Error(\"Wilcard must be a single character; got \" + wildcard);\n }\n var data = this.data,\n offset = this.offset,\n table = this.table,\n inverseTable = this.inverseTable,\n wordWidth = this.wordWidth,\n lastMask = this.lastMask,\n pointerShift = this.pointerShift,\n pointerMask = this.pointerMask,\n charShift = this.charShift,\n charMask = this.charMask;\n\n var matches = [];\n var queue = [{ pointer: 0, memo: '', depth: 0 }];\n var lastDepth = str.length;\n while (queue.length) {\n var node = queue.shift();\n var isLast = node.depth >= lastDepth;\n var token = isLast ? constants_1.TERMINAL : str[node.depth];\n var isWild = token === wildcard || prefix && isLast;\n var wordPointer = node.pointer;\n while (true) {\n if (!isWild && !table.hasOwnProperty(token)) {\n break;\n }\n var bits = wordPointer * wordWidth;\n var chunk = readBits(data, bits, wordWidth);\n var charIdx = chunk >> charShift & charMask;\n if (isWild || charIdx === table[token]) {\n var pointer = chunk >> pointerShift & pointerMask;\n var newChar = inverseTable[charIdx];\n if (isLast && newChar === constants_1.TERMINAL) {\n if (first) {\n return node.memo;\n }\n matches.push(node.memo);\n if (!isWild) {\n break;\n }\n }\n if (newChar !== constants_1.TERMINAL) {\n queue.push({\n pointer: wordPointer + offset + pointer,\n depth: node.depth + 1,\n memo: node.memo + newChar\n });\n }\n }\n var last = chunk & lastMask;\n if (last) {\n break;\n } else {\n wordPointer += 1;\n }\n }\n }\n return first ? null : matches;\n }\n }]);\n\n return PackedTrie;\n }();\n\n exports.default = PackedTrie;\n});\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/webpack/buildin/module.js */ \"./node_modules/webpack/buildin/module.js\")(module)))\n\n//# sourceURL=webpack://TinyTrie/./lib/PackedTrie.ts?");
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/***/ }),
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/***/ "./lib/base64.ts":
/*!***********************!*\
!*** ./lib/base64.ts ***!
\***********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/**
* Extract a window of bits from a Base64 encoded sequence
* @param {String} binary - base64 encoded sequence
* @param {Number} start - first bit to read
* @param {Number} len - number of bits to read
* @return {Number} - bits from string, as number
*/
function readBits(binary, start, len) {
var startChar = ~ ~(start / 6);
var startBitOffset = start % 6;
var endBit = startBitOffset + len;
var charLen = Math.ceil(endBit / 6);
var mask = (0x1 << len) - 1;
var chunk = 0;
"use strict";
eval("/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\n(function (factory) {\n if (( false ? undefined : _typeof(module)) === \"object\" && _typeof(module.exports) === \"object\") {\n var v = factory(__webpack_require__(\"./lib sync recursive\"), exports);\n if (v !== undefined) module.exports = v;\n } else if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n})(function (require, exports) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.BASE64_INT_TO_CHAR = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\".split('');\n exports.BASE64_CHAR_TO_INT = exports.BASE64_INT_TO_CHAR.reduce(function (agg, char, i) {\n agg[char] = i;\n return agg;\n }, {});\n});\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/webpack/buildin/module.js */ \"./node_modules/webpack/buildin/module.js\")(module)))\n\n//# sourceURL=webpack://TinyTrie/./lib/base64.ts?");
for (var i = 0; i < charLen; i++) {
chunk <<= 6;
chunk |= _base.BASE64_CHAR_TO_INT[binary[startChar + i]];
}
/***/ }),
var rightPadding = endBit % 6;
if (rightPadding) {
chunk >>= 6 - rightPadding;
}
/***/ "./lib/constants.ts":
/*!**************************!*\
!*** ./lib/constants.ts ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
return chunk & mask;
}
"use strict";
eval("/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\n(function (factory) {\n if (( false ? undefined : _typeof(module)) === \"object\" && _typeof(module.exports) === \"object\") {\n var v = factory(__webpack_require__(\"./lib sync recursive\"), exports);\n if (v !== undefined) module.exports = v;\n } else if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n})(function (require, exports) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.TERMINAL = '\\0';\n exports.TERMINUS = Object.create(null);\n exports.VERSION = 0;\n exports.HEADER_WIDTH_FIELD = 10;\n exports.VERSION_FIELD = 10;\n exports.OFFSET_SIGN_FIELD = 1;\n exports.OFFSET_VAL_FIELD = 21;\n exports.CHAR_WIDTH_FIELD = 8;\n exports.POINTER_WIDTH_FIELD = 8;\n});\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/webpack/buildin/module.js */ \"./node_modules/webpack/buildin/module.js\")(module)))\n\n//# sourceURL=webpack://TinyTrie/./lib/constants.ts?");
/**
* Class for interacting with an encoded trie. The class performs lookups
* virtually just as fast as a regular trie. The binary data never actually
* have to be processed as a whole, so instantiation time and memory usage are
* phenomenally low.
* @class
*/
/***/ }),
var PackedTrie = (function () {
/***/ "./node_modules/webpack/buildin/module.js":
/*!***********************************!*\
!*** (webpack)/buildin/module.js ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* Instantiate a packed binary trie, parsing its headers to configure the
* instance for queries.
* @constructor
* @param {String} binary - binary string from {@link Trie#encode}
* @return {PackedTrie}
*/
eval("module.exports = function(module) {\r\n\tif (!module.webpackPolyfill) {\r\n\t\tmodule.deprecate = function() {};\r\n\t\tmodule.paths = [];\r\n\t\t// module.parent = undefined by default\r\n\t\tif (!module.children) module.children = [];\r\n\t\tObject.defineProperty(module, \"loaded\", {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function() {\r\n\t\t\t\treturn module.l;\r\n\t\t\t}\r\n\t\t});\r\n\t\tObject.defineProperty(module, \"id\", {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function() {\r\n\t\t\t\treturn module.i;\r\n\t\t\t}\r\n\t\t});\r\n\t\tmodule.webpackPolyfill = 1;\r\n\t}\r\n\treturn module;\r\n};\r\n\n\n//# sourceURL=webpack://TinyTrie/(webpack)/buildin/module.js?");
function PackedTrie(binary) {
_classCallCheck(this, PackedTrie);
/***/ })
var ptr = 0;
// Split binary into header and content by checking first field
var headerCharCount = readBits(binary, ptr, _constants.HEADER_WIDTH_FIELD);
ptr += _constants.HEADER_WIDTH_FIELD;
var header = binary.substr(0, headerCharCount);
var version = readBits(binary, ptr, _constants.VERSION_FIELD);
ptr += _constants.VERSION_FIELD;
if (version !== _constants.VERSION) {
throw new Error('Version mismatch! Binary: ' + version + ', Reader: ' + _constants.VERSION);
}
/**
* Binary string encoded as Base64 representing Trie
* @type {String}
*/
this.data = binary.substr(headerCharCount);
// compute pointer offset
var offsetSign = readBits(header, ptr, _constants.OFFSET_SIGN_FIELD);
ptr += _constants.OFFSET_SIGN_FIELD;
var offset = readBits(header, ptr, _constants.OFFSET_VAL_FIELD);
ptr += _constants.OFFSET_VAL_FIELD;
if (offsetSign) {
offset = -offset;
}
/**
* Pointer offset. Add this to every pointer read from every word in
* the trie to obtain the true value of the pointer. This offset is
* used to avoid signed integers in the word.
* @type {Number}
*/
this.offset = offset;
// interpret the field width within each word
var charWidth = readBits(header, ptr, _constants.CHAR_WIDTH_FIELD);
ptr += _constants.CHAR_WIDTH_FIELD;
var pointerWidth = readBits(header, ptr, _constants.POINTER_WIDTH_FIELD);
ptr += _constants.POINTER_WIDTH_FIELD;
// Interpret the rest of the header as the charTable
var headerFieldChars = Math.ceil(ptr / 6);
var charTable = header.substr(headerFieldChars);
/**
* Character table, mapping character to an integer ID
* @type {Object}
*/
this.table = charTable.split('').reduce(function (agg, char, i) {
agg[char] = i + 1;
return agg;
}, _defineProperty({}, _constants.TERMINAL, 0));
/**
* Inverse of character table, mapping integer ID to character.
* @type {Array}
*/
this.inverseTable = [_constants.TERMINAL].concat(charTable.split(''));
/**
* Number of bits in one word
* @type {Number}
*/
this.wordWidth = charWidth + pointerWidth + 1;
/**
* Mask for reading the "last block" flag in a word
* @type {Number}
*/
this.lastMask = 0x1;
/**
* Mask for reading the pointer value from a word
* @type {Number}
*/
this.pointerMask = (0x1 << pointerWidth) - 1;
/**
* Offset of pointer field in a word
* @type {Number}
*/
this.pointerShift = 1;
/**
* Mask for reading the charTable index in a word
* @type {Number}
*/
this.charMask = (0x1 << charWidth) - 1;
/**
* Offset of charTable index field in a word
* @type {Number}
*/
this.charShift = 1 + pointerWidth;
}
/**
* Test membership in the trie.
* @param {String} string - Search query
* @param {String?} opts.wildcard - See PackedTrie#search wildcard doc
* @param {Boolean?} opts.prefix - See PackedTrie#search prefix doc
* @return {Boolean}
*/
_createClass(PackedTrie, [{
key: 'test',
value: function test(string) {
var _ref = arguments.length <= 1 || arguments[1] === undefined ? { wildcard: null, prefix: false } : arguments[1];
var wildcard = _ref.wildcard;
var prefix = _ref.prefix;
// Delegate to #search with early exit. Could write an optimized path,
// especially for the prefix search case.
return this.search(string, { wildcard: wildcard, prefix: prefix, first: true }) !== null;
}
/**
* Query for matching words in the trie.
* @param {String} string - Search query
* @param {String?} opts.wildcard - Wildcard to use for fuzzy matching.
* Default is no wildcard; only match
* literal query.
* @param {Boolean?} opts.prefix - Perform prefix search (returns true if
* any word exists in the trie starts with
* the search query). Default is false;
* only match the full query.
* @param {Boolean} opts.first - Return only first match that is found,
* short-circuiting the search. Default is
* false; return all matches.
* @return {String?|String[]} - Return an optional string result when in
* first-only mode; otherwise return a list
* of strings that match the query.
*/
}, {
key: 'search',
value: function search(string) {
var _ref2 = arguments.length <= 1 || arguments[1] === undefined ? { wildcard: null, prefix: false, first: false } : arguments[1];
var wildcard = _ref2.wildcard;
var prefix = _ref2.prefix;
var first = _ref2.first;
if (wildcard && wildcard.length !== 1) {
throw new Error('Wilcard must be a single character; got ' + wildcard);
}
var data = this.data;
var offset = this.offset;
var table = this.table;
var inverseTable = this.inverseTable;
var wordWidth = this.wordWidth;
var lastMask = this.lastMask;
var pointerShift = this.pointerShift;
var pointerMask = this.pointerMask;
var charShift = this.charShift;
var charMask = this.charMask;
// List of matches found in the search.
var matches = [];
// Search queue.
var queue = [{ pointer: 0, memo: '', depth: 0 }];
var lastDepth = string.length;
// Do a BFS over nodes for the search query.
while (queue.length) {
var node = queue.shift();
var isLast = node.depth >= lastDepth;
var token = isLast ? _constants.TERMINAL : string[node.depth];
// Flag for matching anything. Note that the overflow beyond the
// length of the query in a prefix search behaves as a wildcard.
var isWild = token === wildcard || prefix && isLast;
// We're committed to an O(N) scan over the entire node even in
// the simple literal-search case, since our structure doesn't
// currently guarantee any child ordering.
// TODO(joen) ordering is a potential future format optimization.
var wordPointer = node.pointer;
while (true) {
// Optimization: Exit immediately if the char was not found in
// the table (meaning there can't be any children in the trie
// with this character). Exception is wildcards.
if (!isWild && !table.hasOwnProperty(token)) {
break;
}
var bits = wordPointer * wordWidth;
var chunk = readBits(data, bits, wordWidth);
// Read the character index
var charIdx = chunk >> charShift & charMask;
// If this character is matched, jump to the pointer given in
// this node.
if (isWild || charIdx === table[token]) {
var pointer = chunk >> pointerShift & pointerMask;
// Find the next char with an inverse map, since we might
// be using a wildcard search.
var newChar = inverseTable[charIdx];
// Stopping condition: searching last block and we hit a terminal
if (isLast && newChar === _constants.TERMINAL) {
// Optimization: early exit if we only need first match.
if (first) {
return node.memo;
}
// Store this match.
matches.push(node.memo);
// If we're not matching everything, break out of the
// inner loop.
if (!isWild) {
break;
}
}
// Push next node for search, if it's non-terminal.
if (newChar !== _constants.TERMINAL) {
queue.push({
pointer: wordPointer + offset + pointer,
depth: node.depth + 1,
memo: node.memo + newChar
});
}
}
// If this wasn't a match, check if this was the last key in
// the block.
var last = chunk & lastMask;
// If this was the last node, the word was not found.
if (last) {
break;
}
// Otherwise increment the pointer to the next sibling key
else {
wordPointer += 1;
}
}
}
// If first was requested it should have returned by now. Otherwise
// return the matches list, which may be empty.
return first ? null : matches;
}
}]);
return PackedTrie;
})();
exports.default = PackedTrie;
/***/ },
/* 1 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* @file Lookup tables for Base64 conversions
*/
/**
* Lookup table for transforming a 6-bit binary integer into a Base-64 ASCII
* character.
* @constant {String[]}
*/
var BASE64_INT_TO_CHAR = exports.BASE64_INT_TO_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
/**
* Inverse lookup table for transformating a Base-64 ASCII character into the
* corresponding integer value.
* @constant {Object}
*/
var BASE64_CHAR_TO_INT = exports.BASE64_CHAR_TO_INT = BASE64_INT_TO_CHAR.reduce(function (agg, char, i) {
agg[char] = i;
return agg;
}, {});
/***/ },
/* 2 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* @file Parameters used for encoding
*/
/**
* String terminal character
* @constant {String}
*/
var TERMINAL = exports.TERMINAL = '\0';
/**
* Terminal edge
* @constant {Object}
*/
var TERMINUS = exports.TERMINUS = Object.create(null);
/**
* Encoding version. Bump when breaking encoding changes are introduced.
* @constant {Number}
*/
var VERSION = exports.VERSION = 0;
/**
* Width of header field storing entire header width (including char table).
* Value is given in Base64 characters (i.e., every six bits)
* @constant {Number}
*/
var HEADER_WIDTH_FIELD = exports.HEADER_WIDTH_FIELD = 10;
/**
* Width of version field
* @type {Number}
*/
var VERSION_FIELD = exports.VERSION_FIELD = 10;
/**
* Width of header field representing sign of offset
* @constant {Number}
*/
var OFFSET_SIGN_FIELD = exports.OFFSET_SIGN_FIELD = 1;
/**
* Width of header field representing unsigned value of offset
* @constant {Number}
*/
var OFFSET_VAL_FIELD = exports.OFFSET_VAL_FIELD = 21;
/**
* Width of header field representing the width of the char index in a word
* @constant {Number}
*/
var CHAR_WIDTH_FIELD = exports.CHAR_WIDTH_FIELD = 8;
/**
* Width of header field representing the width of the offset pointer in a word
* @constant {Number}
*/
var POINTER_WIDTH_FIELD = exports.POINTER_WIDTH_FIELD = 8;
/***/ }
/******/ ])
});
;
/******/ });
});

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.TinyTrie=t():e.TinyTrie=t()}(this,function(){return function(e){function t(i){if(r[i])return r[i].exports;var n=r[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t,r){for(var i=~~(t/6),n=t%6,a=n+r,o=Math.ceil(a/6),u=(1<<r)-1,f=0,c=0;o>c;c++)f<<=6,f|=s.BASE64_CHAR_TO_INT[e[i+c]];var l=a%6;return l&&(f>>=6-l),f&u}var o=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();Object.defineProperty(t,"__esModule",{value:!0});var s=r(1),u=r(2),f=function(){function e(t){n(this,e);var r=0,o=a(t,r,u.HEADER_WIDTH_FIELD);r+=u.HEADER_WIDTH_FIELD;var s=t.substr(0,o),f=a(t,r,u.VERSION_FIELD);if(r+=u.VERSION_FIELD,f!==u.VERSION)throw new Error("Version mismatch! Binary: "+f+", Reader: "+u.VERSION);this.data=t.substr(o);var c=a(s,r,u.OFFSET_SIGN_FIELD);r+=u.OFFSET_SIGN_FIELD;var l=a(s,r,u.OFFSET_VAL_FIELD);r+=u.OFFSET_VAL_FIELD,c&&(l=-l),this.offset=l;var h=a(s,r,u.CHAR_WIDTH_FIELD);r+=u.CHAR_WIDTH_FIELD;var E=a(s,r,u.POINTER_WIDTH_FIELD);r+=u.POINTER_WIDTH_FIELD;var I=Math.ceil(r/6),d=s.substr(I);this.table=d.split("").reduce(function(e,t,r){return e[t]=r+1,e},i({},u.TERMINAL,0)),this.inverseTable=[u.TERMINAL].concat(d.split("")),this.wordWidth=h+E+1,this.lastMask=1,this.pointerMask=(1<<E)-1,this.pointerShift=1,this.charMask=(1<<h)-1,this.charShift=1+E}return o(e,[{key:"test",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?{wildcard:null,prefix:!1}:arguments[1],r=t.wildcard,i=t.prefix;return null!==this.search(e,{wildcard:r,prefix:i,first:!0})}},{key:"search",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?{wildcard:null,prefix:!1,first:!1}:arguments[1],r=t.wildcard,i=t.prefix,n=t.first;if(r&&1!==r.length)throw new Error("Wilcard must be a single character; got "+r);for(var o=this.data,s=this.offset,f=this.table,c=this.inverseTable,l=this.wordWidth,h=this.lastMask,E=this.pointerShift,I=this.pointerMask,d=this.charShift,_=this.charMask,p=[],T=[{pointer:0,memo:"",depth:0}],v=e.length;T.length;)for(var D=T.shift(),F=D.depth>=v,b=F?u.TERMINAL:e[D.depth],L=b===r||i&&F,m=D.pointer;;){if(!L&&!f.hasOwnProperty(b))break;var R=m*l,O=a(o,R,l),S=O>>d&_;if(L||S===f[b]){var N=O>>E&I,A=c[S];if(F&&A===u.TERMINAL){if(n)return D.memo;if(p.push(D.memo),!L)break}A!==u.TERMINAL&&T.push({pointer:m+s+N,depth:D.depth+1,memo:D.memo+A})}var y=O&h;if(y)break;m+=1}return n?null:p}}]),e}();t["default"]=f},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=t.BASE64_INT_TO_CHAR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");t.BASE64_CHAR_TO_INT=r.reduce(function(e,t,r){return e[t]=r,e},{})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.TERMINAL="\x00",t.TERMINUS=Object.create(null),t.VERSION=0,t.HEADER_WIDTH_FIELD=10,t.VERSION_FIELD=10,t.OFFSET_SIGN_FIELD=1,t.OFFSET_VAL_FIELD=21,t.CHAR_WIDTH_FIELD=8,t.POINTER_WIDTH_FIELD=8}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TinyTrie=e():t.TinyTrie=e()}(window,function(){return function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},r.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=6)}([function(t,e){function r(t){var e=new Error('Cannot find module "'+t+'".');throw e.code="MODULE_NOT_FOUND",e}r.keys=function(){return[]},r.resolve=r,t.exports=r,r.id=0},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";(function(t){var o,n,i,f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(u){if("object"===f(t)&&"object"===f(t.exports)){var c=u(r(0),e);void 0!==c&&(t.exports=c)}else n=[r,e],void 0===(i="function"==typeof(o=u)?o.apply(e,n):o)||(t.exports=i)}(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.TERMINAL="\0",e.TERMINUS=Object.create(null),e.VERSION=0,e.HEADER_WIDTH_FIELD=10,e.VERSION_FIELD=10,e.OFFSET_SIGN_FIELD=1,e.OFFSET_VAL_FIELD=21,e.CHAR_WIDTH_FIELD=8,e.POINTER_WIDTH_FIELD=8})}).call(this,r(1)(t))},function(t,e,r){"use strict";(function(t){var o,n,i,f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(u){if("object"===f(t)&&"object"===f(t.exports)){var c=u(r(0),e);void 0!==c&&(t.exports=c)}else n=[r,e],void 0===(i="function"==typeof(o=u)?o.apply(e,n):o)||(t.exports=i)}(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.BASE64_INT_TO_CHAR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),e.BASE64_CHAR_TO_INT=e.BASE64_INT_TO_CHAR.reduce(function(t,e,r){return t[e]=r,t},{})})}).call(this,r(1)(t))},,,function(t,e,r){"use strict";(function(t){var o,n,i,f=function(){function t(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,r,o){return r&&t(e.prototype,r),o&&t(e,o),e}}(),u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(f){if("object"===u(t)&&"object"===u(t.exports)){var c=f(r(0),e);void 0!==c&&(t.exports=c)}else n=[r,e,r(3),r(2)],void 0===(i="function"==typeof(o=f)?o.apply(e,n):o)||(t.exports=i)}(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=t("./base64"),o=t("./constants");function n(t,e,o){for(var n=~~(e/6),i=e%6+o,f=Math.ceil(i/6),u=(1<<o)-1,c=0,a=0;a<f;a++)c<<=6,c|=r.BASE64_CHAR_TO_INT[t[n+a]];var l=i%6;return l&&(c>>=6-l),c&u}var i=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.lastMask=1,this.pointerShift=1;var r=0,i=n(e,r,o.HEADER_WIDTH_FIELD);r+=o.HEADER_WIDTH_FIELD;var f=e.substr(0,i),u=n(e,r,o.VERSION_FIELD);if(r+=o.VERSION_FIELD,u!==o.VERSION)throw new Error("Version mismatch! Binary: "+u+", Reader: "+o.VERSION);this.data=e.substr(i);var c=n(f,r,o.OFFSET_SIGN_FIELD),a=n(f,r+=o.OFFSET_SIGN_FIELD,o.OFFSET_VAL_FIELD);r+=o.OFFSET_VAL_FIELD,c&&(a=-a),this.offset=a;var l=n(f,r,o.CHAR_WIDTH_FIELD),s=n(f,r+=o.CHAR_WIDTH_FIELD,o.POINTER_WIDTH_FIELD);r+=o.POINTER_WIDTH_FIELD;var p,y,d,b=Math.ceil(r/6),h=f.substr(b);this.table=h.split("").reduce(function(t,e,r){return t[e]=r+1,t},(p={},y=o.TERMINAL,d=0,y in p?Object.defineProperty(p,y,{value:d,enumerable:!0,configurable:!0,writable:!0}):p[y]=d,p)),this.inverseTable=[o.TERMINAL].concat(h.split("")),this.wordWidth=l+s+1,this.pointerMask=(1<<s)-1,this.charMask=(1<<l)-1,this.charShift=1+s}return f(t,[{key:"test",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{wildcard:null,prefix:!1},r=e.wildcard,o=e.prefix;return null!==this.search(t,{wildcard:r,prefix:o,first:!0})}},{key:"search",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{wildcard:null,prefix:!1,first:!1},r=e.wildcard,i=e.prefix,f=e.first;if(r&&1!==r.length)throw new Error("Wilcard must be a single character; got "+r);for(var u=this.data,c=this.offset,a=this.table,l=this.inverseTable,s=this.wordWidth,p=this.lastMask,y=this.pointerShift,d=this.pointerMask,b=this.charShift,h=this.charMask,_=[],E=[{pointer:0,memo:"",depth:0}],I=t.length;E.length;)for(var v=E.shift(),m=v.depth>=I,T=m?o.TERMINAL:t[v.depth],S=T===r||i&&m,O=v.pointer;S||a.hasOwnProperty(T);){var D=n(u,O*s,s),F=D>>b&h;if(S||F===a[T]){var L=D>>y&d,R=l[F];if(m&&R===o.TERMINAL){if(f)return v.memo;if(_.push(v.memo),!S)break}R!==o.TERMINAL&&E.push({pointer:O+c+L,depth:v.depth+1,memo:v.memo+R})}if(D&p)break;O+=1}return f?null:_}}]),t}();e.default=i})}).call(this,r(1)(t))}])});

@@ -10,923 +10,171 @@ (function webpackUniversalModuleDefinition(root, factory) {

root["TinyTrie"] = factory();
})(this, function() {
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ module.l = 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;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ return __webpack_require__(__webpack_require__.s = "./lib/index.ts");
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/******/ ({
'use strict';
/***/ "./lib sync recursive":
/*!******************!*\
!*** ./lib sync ***!
\******************/
/*! no static exports found */
/***/ (function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Trie = undefined;
eval("function webpackEmptyContext(req) {\n\tvar e = new Error('Cannot find module \"' + req + '\".');\n\te.code = 'MODULE_NOT_FOUND';\n\tthrow e;\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nmodule.exports = webpackEmptyContext;\nwebpackEmptyContext.id = \"./lib sync recursive\";\n\n//# sourceURL=webpack://TinyTrie/./lib_sync?");
var _Trie = __webpack_require__(3);
/***/ }),
Object.defineProperty(exports, 'Trie', {
enumerable: true,
get: function get() {
return _Trie.default;
}
});
exports.createSync = createSync;
exports.createFrozenSync = createFrozenSync;
/***/ "./lib/BinaryString.ts":
/*!*****************************!*\
!*** ./lib/BinaryString.ts ***!
\*****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var _Trie2 = _interopRequireDefault(_Trie);
"use strict";
eval("/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nvar _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\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n(function (factory) {\n if (( false ? undefined : _typeof(module)) === \"object\" && _typeof(module.exports) === \"object\") {\n var v = factory(__webpack_require__(\"./lib sync recursive\"), exports);\n if (v !== undefined) module.exports = v;\n } else if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ./floor_log2 */ \"./lib/floor_log2.ts\"), __webpack_require__(/*! ./base64 */ \"./lib/base64.ts\")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n})(function (require, exports) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", { value: true });\n var floor_log2_1 = require(\"./floor_log2\");\n var base64_1 = require(\"./base64\");\n\n var BinaryString = function () {\n function BinaryString() {\n _classCallCheck(this, BinaryString);\n\n this.buffer = 0;\n this.pointer = 0;\n this.data = '';\n }\n\n _createClass(BinaryString, [{\n key: \"write\",\n value: function write(val) {\n var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n\n var buf = this.buffer;\n var len = width || floor_log2_1.default(val) + 1;\n if (width && val >= 0x1 << width) {\n throw new Error(\"Can't write \" + val + \" in only \" + width + \" bits\");\n }\n this.buffer = buf << len | val;\n this.pointer += len;\n this._digest();\n }\n }, {\n key: \"flush\",\n value: function flush() {\n var buffer = this.buffer;\n var pointer = this.pointer;\n while (pointer && pointer < 6) {\n buffer <<= 1;\n pointer += 1;\n }\n this.pointer = pointer;\n this.buffer = buffer;\n this._digest();\n }\n }, {\n key: \"getData\",\n value: function getData() {\n this.flush();\n return this.data;\n }\n }, {\n key: \"_digest\",\n value: function _digest() {\n var buffer = this.buffer;\n var pointer = this.pointer;\n var newData = '';\n while (pointer >= 6) {\n var remainder = pointer - 6;\n var code = buffer >> remainder;\n buffer = buffer ^ code << remainder;\n pointer = remainder;\n newData += base64_1.BASE64_INT_TO_CHAR[code];\n }\n this.pointer = pointer;\n this.buffer = buffer;\n this.data += newData;\n }\n }]);\n\n return BinaryString;\n }();\n\n exports.default = BinaryString;\n});\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/webpack/buildin/module.js */ \"./node_modules/webpack/buildin/module.js\")(module)))\n\n//# sourceURL=webpack://TinyTrie/./lib/BinaryString.ts?");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/***/ }),
/**
* Synchronously construct a new Trie out of the given strings.
* @param {String[]} words
* @return {Trie}
*/
function createSync(strings) {
var trie = new _Trie2.default();
/***/ "./lib/Trie.ts":
/*!*********************!*\
!*** ./lib/Trie.ts ***!
\*********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
strings.forEach(function (s) {
return trie.insert(s);
});
"use strict";
eval("/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nvar _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\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n(function (factory) {\n if (( false ? undefined : _typeof(module)) === \"object\" && _typeof(module.exports) === \"object\") {\n var v = factory(__webpack_require__(\"./lib sync recursive\"), exports);\n if (v !== undefined) module.exports = v;\n } else if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ./floor_log2 */ \"./lib/floor_log2.ts\"), __webpack_require__(/*! ./BinaryString */ \"./lib/BinaryString.ts\"), __webpack_require__(/*! ./constants */ \"./lib/constants.ts\")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n})(function (require, exports) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", { value: true });\n var floor_log2_1 = require(\"./floor_log2\");\n var BinaryString_1 = require(\"./BinaryString\");\n var constants_1 = require(\"./constants\");\n\n var Trie = function () {\n function Trie() {\n var tree = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n _classCallCheck(this, Trie);\n\n this.root = tree;\n this.frozen = false;\n }\n\n _createClass(Trie, [{\n key: \"insert\",\n value: function insert(str) {\n if (this.frozen) {\n throw new SyntaxError(\"Can't insert into frozen Trie\");\n }\n var lastNode = str.split('').reduce(function (node, char) {\n if (char === constants_1.TERMINAL) {\n throw new TypeError(\"Illegal string character \" + constants_1.TERMINAL);\n }\n var nextNode = node.hasOwnProperty(char) ? node[char] : node[char] = {};\n return nextNode;\n }, this.root);\n lastNode[constants_1.TERMINAL] = constants_1.TERMINUS;\n return this;\n }\n }, {\n key: \"test\",\n value: function test(str) {\n var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { wildcard: null, prefix: false },\n wildcard = _ref.wildcard,\n prefix = _ref.prefix;\n\n if (!wildcard) {\n var node = this.root;\n var match = str.split('').every(function (char) {\n return !!(node = node[char]);\n });\n return !!match && (prefix || node.hasOwnProperty(constants_1.TERMINAL));\n }\n return !!this.search(str, { wildcard: wildcard, prefix: prefix, first: true });\n }\n }, {\n key: \"search\",\n value: function search(str) {\n var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { wildcard: null, prefix: false, first: false },\n wildcard = _ref2.wildcard,\n prefix = _ref2.prefix,\n first = _ref2.first;\n\n if (wildcard && wildcard.length !== 1) {\n throw new Error(\"Wildcard length must be 1; got \" + wildcard.length);\n }\n var matches = [];\n var queue = [{ data: this.root, depth: 0, memo: '' }];\n var lastDepth = str.length;\n\n var _loop = function _loop() {\n var node = queue.shift();\n if (node.depth >= lastDepth) {\n if (node.data.hasOwnProperty(constants_1.TERMINAL)) {\n if (first) {\n return {\n v: node.memo\n };\n }\n matches.push(node.memo);\n }\n if (!prefix) {\n return \"continue\";\n }\n }\n var isPfXOverflow = prefix && node.depth >= lastDepth;\n var token = str[node.depth];\n if (token === wildcard || isPfXOverflow) {\n Object.keys(node.data).forEach(function (n) {\n if (n !== constants_1.TERMINAL) {\n queue.push({\n data: node.data[n],\n depth: node.depth + 1,\n memo: node.memo + n\n });\n }\n });\n } else {\n if (node.data.hasOwnProperty(token)) {\n queue.push({\n data: node.data[token],\n depth: node.depth + 1,\n memo: node.memo + token\n });\n }\n }\n };\n\n while (queue.length) {\n var _ret = _loop();\n\n switch (_ret) {\n case \"continue\":\n continue;\n\n default:\n if ((typeof _ret === \"undefined\" ? \"undefined\" : _typeof(_ret)) === \"object\") return _ret.v;\n }\n }\n return first ? null : matches;\n }\n }, {\n key: \"clone\",\n value: function clone() {\n return new Trie(this.toJSON());\n }\n }, {\n key: \"freeze\",\n value: function freeze() {\n if (this.frozen) {\n return this;\n }\n var suffixTree = {};\n var node = this.root;\n var stack = [];\n var depthStack = [node];\n while (depthStack.length) {\n node = depthStack.pop();\n Object.keys(node).forEach(function (char) {\n if (char[1] === '_') {\n return;\n }\n var current = node[char];\n stack.push({\n current: current,\n char: char,\n parent: node\n });\n depthStack.push(current);\n });\n }\n\n var _loop2 = function _loop2() {\n var _stack$pop = stack.pop(),\n char = _stack$pop.char,\n parent = _stack$pop.parent,\n current = _stack$pop.current;\n\n if (suffixTree.hasOwnProperty(char)) {\n var suffixMeta = suffixTree[char];\n var match = suffixMeta.find(function (other) {\n var oKeys = Object.keys(other);\n var cKeys = Object.keys(current);\n return oKeys.length === cKeys.length && oKeys.every(function (key) {\n return other[key] === current[key];\n });\n });\n if (match) {\n parent[char] = match;\n } else {\n suffixMeta.push(current);\n }\n } else {\n suffixTree[char] = [current];\n }\n };\n\n while (stack.length) {\n _loop2();\n }\n this.frozen = true;\n return this;\n }\n }, {\n key: \"encode\",\n value: function encode() {\n var chunks = [];\n var queue = [this.root];\n var charTable = new Set();\n var visitCode = Date.now();\n var offsetMin = Infinity;\n var offsetMax = -Infinity;\n\n var _loop3 = function _loop3() {\n var node = queue.shift();\n var keys = Object.keys(node).filter(function (k) {\n return k[1] !== '_';\n });\n var n = keys.length;\n node.__visited__ = visitCode;\n var nodeChunkIndex = node.__idx__ = chunks.length;\n if (node.__parents__) {\n node.__parents__.forEach(function (chunk) {\n var offset = chunk.offset = nodeChunkIndex - chunk.idx;\n if (offset < offsetMin) {\n offsetMin = offset;\n }\n if (offset > offsetMax) {\n offsetMax = offset;\n }\n });\n }\n keys.forEach(function (char, i) {\n var child = node[char];\n var chunkIdx = chunks.length;\n var lastInLevel = i === n - 1;\n var newChunk = {\n char: char,\n idx: chunkIdx,\n offset: null,\n last: lastInLevel\n };\n if (child.__visited__ === visitCode) {\n var idx = child.__idx__;\n var offset = newChunk.offset = idx - chunkIdx;\n if (offset < offsetMin) {\n offsetMin = offset;\n }\n if (offset > offsetMax) {\n offsetMax = offset;\n }\n } else {\n if (child.__willVisit__ === visitCode) {\n child.__parents__.push(newChunk);\n } else {\n child.__willVisit__ = visitCode;\n child.__parents__ = [newChunk];\n }\n queue.push(child);\n }\n chunks.push(newChunk);\n charTable.add(char);\n });\n };\n\n while (queue.length) {\n _loop3();\n }\n var charTableAsArray = Array.from(charTable).filter(function (char) {\n return char !== constants_1.TERMINAL;\n });\n var charMap = charTableAsArray.reduce(function (agg, char, i) {\n agg[char] = i + 1;\n return agg;\n }, _defineProperty({}, constants_1.TERMINAL, 0));\n var charEncodingWidth = floor_log2_1.default(charTableAsArray.length) + 1;\n var pointerRange = offsetMax - offsetMin;\n var pointerEncodingWidth = floor_log2_1.default(pointerRange) + 1;\n var encodedTrie = new BinaryString_1.default();\n chunks.forEach(function (chunk) {\n var char = chunk.char,\n offset = chunk.offset,\n last = chunk.last;\n\n encodedTrie.write(charMap[char], charEncodingWidth);\n encodedTrie.write(offset - offsetMin, pointerEncodingWidth);\n encodedTrie.write(+last, 1);\n });\n encodedTrie.flush();\n var headerString = new BinaryString_1.default();\n var outputCharTable = charTableAsArray.join('');\n var headerWidth = Math.ceil((constants_1.HEADER_WIDTH_FIELD + constants_1.VERSION_FIELD + constants_1.OFFSET_SIGN_FIELD + constants_1.OFFSET_VAL_FIELD + constants_1.CHAR_WIDTH_FIELD + constants_1.POINTER_WIDTH_FIELD) / 6) + outputCharTable.length;\n var offsetSign = +(offsetMin < 0);\n headerString.write(headerWidth, constants_1.HEADER_WIDTH_FIELD);\n headerString.write(constants_1.VERSION, constants_1.VERSION_FIELD);\n headerString.write(offsetSign, constants_1.OFFSET_SIGN_FIELD);\n headerString.write(offsetSign ? -offsetMin : offsetMin, constants_1.OFFSET_VAL_FIELD);\n headerString.write(charEncodingWidth, constants_1.CHAR_WIDTH_FIELD);\n headerString.write(pointerEncodingWidth, constants_1.POINTER_WIDTH_FIELD);\n headerString.flush();\n return \"\" + headerString.getData() + outputCharTable + encodedTrie.getData();\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n var str = JSON.stringify(this.root, function (k, v) {\n if (k[1] === '_') {\n return undefined;\n }\n return v;\n });\n return JSON.parse(str);\n }\n }]);\n\n return Trie;\n }();\n\n exports.default = Trie;\n});\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/webpack/buildin/module.js */ \"./node_modules/webpack/buildin/module.js\")(module)))\n\n//# sourceURL=webpack://TinyTrie/./lib/Trie.ts?");
return trie;
}
/***/ }),
/**
* Create a frozen Trie out of given words
* @param {String[]} words
* @return {Trie}
*/
function createFrozenSync(string) {
return createSync(string).freeze();
}
/***/ "./lib/base64.ts":
/*!***********************!*\
!*** ./lib/base64.ts ***!
\***********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/***/ },
/* 1 */
/***/ function(module, exports) {
"use strict";
eval("/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\n(function (factory) {\n if (( false ? undefined : _typeof(module)) === \"object\" && _typeof(module.exports) === \"object\") {\n var v = factory(__webpack_require__(\"./lib sync recursive\"), exports);\n if (v !== undefined) module.exports = v;\n } else if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n})(function (require, exports) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.BASE64_INT_TO_CHAR = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\".split('');\n exports.BASE64_CHAR_TO_INT = exports.BASE64_INT_TO_CHAR.reduce(function (agg, char, i) {\n agg[char] = i;\n return agg;\n }, {});\n});\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/webpack/buildin/module.js */ \"./node_modules/webpack/buildin/module.js\")(module)))\n\n//# sourceURL=webpack://TinyTrie/./lib/base64.ts?");
'use strict';
/***/ }),
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* @file Lookup tables for Base64 conversions
*/
/***/ "./lib/constants.ts":
/*!**************************!*\
!*** ./lib/constants.ts ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/**
* Lookup table for transforming a 6-bit binary integer into a Base-64 ASCII
* character.
* @constant {String[]}
*/
var BASE64_INT_TO_CHAR = exports.BASE64_INT_TO_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
"use strict";
eval("/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\n(function (factory) {\n if (( false ? undefined : _typeof(module)) === \"object\" && _typeof(module.exports) === \"object\") {\n var v = factory(__webpack_require__(\"./lib sync recursive\"), exports);\n if (v !== undefined) module.exports = v;\n } else if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n})(function (require, exports) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.TERMINAL = '\\0';\n exports.TERMINUS = Object.create(null);\n exports.VERSION = 0;\n exports.HEADER_WIDTH_FIELD = 10;\n exports.VERSION_FIELD = 10;\n exports.OFFSET_SIGN_FIELD = 1;\n exports.OFFSET_VAL_FIELD = 21;\n exports.CHAR_WIDTH_FIELD = 8;\n exports.POINTER_WIDTH_FIELD = 8;\n});\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/webpack/buildin/module.js */ \"./node_modules/webpack/buildin/module.js\")(module)))\n\n//# sourceURL=webpack://TinyTrie/./lib/constants.ts?");
/**
* Inverse lookup table for transformating a Base-64 ASCII character into the
* corresponding integer value.
* @constant {Object}
*/
var BASE64_CHAR_TO_INT = exports.BASE64_CHAR_TO_INT = BASE64_INT_TO_CHAR.reduce(function (agg, char, i) {
agg[char] = i;
return agg;
}, {});
/***/ }),
/***/ },
/* 2 */
/***/ function(module, exports) {
/***/ "./lib/floor_log2.ts":
/*!***************************!*\
!*** ./lib/floor_log2.ts ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
"use strict";
eval("/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\n(function (factory) {\n if (( false ? undefined : _typeof(module)) === \"object\" && _typeof(module.exports) === \"object\") {\n var v = factory(__webpack_require__(\"./lib sync recursive\"), exports);\n if (v !== undefined) module.exports = v;\n } else if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n})(function (require, exports) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", { value: true });\n function floor_log2(x) {\n var n = 0;\n while (x >>= 1) {\n n++;\n }\n return n;\n }\n exports.default = floor_log2;\n});\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/webpack/buildin/module.js */ \"./node_modules/webpack/buildin/module.js\")(module)))\n\n//# sourceURL=webpack://TinyTrie/./lib/floor_log2.ts?");
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* @file Parameters used for encoding
*/
/***/ }),
/**
* String terminal character
* @constant {String}
*/
var TERMINAL = exports.TERMINAL = '\0';
/***/ "./lib/index.ts":
/*!**********************!*\
!*** ./lib/index.ts ***!
\**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/**
* Terminal edge
* @constant {Object}
*/
var TERMINUS = exports.TERMINUS = Object.create(null);
"use strict";
eval("/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\n(function (factory) {\n if (( false ? undefined : _typeof(module)) === \"object\" && _typeof(module.exports) === \"object\") {\n var v = factory(__webpack_require__(\"./lib sync recursive\"), exports);\n if (v !== undefined) module.exports = v;\n } else if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ./Trie */ \"./lib/Trie.ts\"), __webpack_require__(/*! ./Trie */ \"./lib/Trie.ts\")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n})(function (require, exports) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", { value: true });\n var Trie_1 = require(\"./Trie\");\n var Trie_2 = require(\"./Trie\");\n exports.Trie = Trie_2.default;\n function createSync(strings) {\n var trie = new Trie_1.default();\n strings.forEach(function (s) {\n return trie.insert(s);\n });\n return trie;\n }\n exports.createSync = createSync;\n function createFrozenSync(words) {\n return createSync(words).freeze();\n }\n exports.createFrozenSync = createFrozenSync;\n});\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/webpack/buildin/module.js */ \"./node_modules/webpack/buildin/module.js\")(module)))\n\n//# sourceURL=webpack://TinyTrie/./lib/index.ts?");
/**
* Encoding version. Bump when breaking encoding changes are introduced.
* @constant {Number}
*/
var VERSION = exports.VERSION = 0;
/***/ }),
/**
* Width of header field storing entire header width (including char table).
* Value is given in Base64 characters (i.e., every six bits)
* @constant {Number}
*/
var HEADER_WIDTH_FIELD = exports.HEADER_WIDTH_FIELD = 10;
/***/ "./node_modules/webpack/buildin/module.js":
/*!***********************************!*\
!*** (webpack)/buildin/module.js ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* Width of version field
* @type {Number}
*/
var VERSION_FIELD = exports.VERSION_FIELD = 10;
eval("module.exports = function(module) {\r\n\tif (!module.webpackPolyfill) {\r\n\t\tmodule.deprecate = function() {};\r\n\t\tmodule.paths = [];\r\n\t\t// module.parent = undefined by default\r\n\t\tif (!module.children) module.children = [];\r\n\t\tObject.defineProperty(module, \"loaded\", {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function() {\r\n\t\t\t\treturn module.l;\r\n\t\t\t}\r\n\t\t});\r\n\t\tObject.defineProperty(module, \"id\", {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function() {\r\n\t\t\t\treturn module.i;\r\n\t\t\t}\r\n\t\t});\r\n\t\tmodule.webpackPolyfill = 1;\r\n\t}\r\n\treturn module;\r\n};\r\n\n\n//# sourceURL=webpack://TinyTrie/(webpack)/buildin/module.js?");
/**
* Width of header field representing sign of offset
* @constant {Number}
*/
var OFFSET_SIGN_FIELD = exports.OFFSET_SIGN_FIELD = 1;
/***/ })
/**
* Width of header field representing unsigned value of offset
* @constant {Number}
*/
var OFFSET_VAL_FIELD = exports.OFFSET_VAL_FIELD = 21;
/**
* Width of header field representing the width of the char index in a word
* @constant {Number}
*/
var CHAR_WIDTH_FIELD = exports.CHAR_WIDTH_FIELD = 8;
/**
* Width of header field representing the width of the offset pointer in a word
* @constant {Number}
*/
var POINTER_WIDTH_FIELD = exports.POINTER_WIDTH_FIELD = 8;
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
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; }; })(); /**
* @file Provides the Trie class
*/
Object.defineProperty(exports, "__esModule", {
value: true
});
var _floor_log = __webpack_require__(4);
var _floor_log2 = _interopRequireDefault(_floor_log);
var _BinaryString = __webpack_require__(5);
var _BinaryString2 = _interopRequireDefault(_BinaryString);
var _constants = __webpack_require__(2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* A structure to provide efficient membership tests for a set of strings
* @class
*/
var Trie = (function () {
/**
* Typically no arguments are needed, but it's possible to instantiate a
* Trie from a JSON object that represents it (@see Trie#toJSON).
* @constructor
* @param {Object} tree - a trie given as a vanilla JS tree. This will be
* used as the root node.
* @return {Trie}
*/
function Trie() {
var tree = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
_classCallCheck(this, Trie);
this.root = tree;
this.frozen = false;
}
/**
* Insert a word into the trie. Insertions into a frozen trie will throw
* an error. The
* @param {String} string - string to insert. Note the \u0000 character is
* disallowed.
* @return {Trie} - this
*/
_createClass(Trie, [{
key: 'insert',
value: function insert(string) {
// This trie insert algorithm can't guarantee safe inserts on the DAWG
// produced by freezing.
if (this.frozen) {
throw new SyntaxError("Can't insert into frozen Trie");
}
var lastNode = string.split('').reduce(function (node, char) {
if (char === _constants.TERMINAL) {
throw new TypeError('Illegal string character ' + _constants.TERMINAL);
}
var nextNode = node.hasOwnProperty(char) ? node[char] : node[char] = {};
return nextNode;
}, this.root);
// Terminate the string. Using a constant terminus is not necessary
// (and is not be possible in cloned tries), but it uses slightly less
// memory and could make certain bugs more obvious.
lastNode[_constants.TERMINAL] = _constants.TERMINUS;
return this;
}
/**
* Test membership in the trie.
* @param {String} string - Search query
* @param {String?} opts.wildcard - See Trie#search wildcard doc
* @param {Boolean?} opts.prefix - See Trie#search prefix doc
* @return {Boolean}
*/
}, {
key: 'test',
value: function test(string) {
var _this = this;
var _ref = arguments.length <= 1 || arguments[1] === undefined ? { wildcard: null, prefix: false } : arguments[1];
var wildcard = _ref.wildcard;
var prefix = _ref.prefix;
// When there are no wildcards we can use an optimized search.
if (!wildcard) {
var _ret = (function () {
var node = _this.root;
var match = string.split('').every(function (char) {
return node = node[char];
});
return {
v: !!match && (prefix || node.hasOwnProperty(_constants.TERMINAL))
};
})();
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
}
// Unoptimized path: delegate to #search with short-circuiting.
return !!this.search(string, { wildcard: wildcard, prefix: prefix, first: true });
}
/**
* Query for matching words in the trie.
* @param {String} string - Search query
* @param {String?} opts.wildcard - Wildcard to use for fuzzy matching.
* Default is no wildcard; only match
* literal query.
* @param {Boolean?} opts.prefix - Perform prefix search (returns true if
* any word exists in the trie starts with
* the search query). Default is false;
* only match the full query.
* @param {Boolean} opts.first - Return only first match that is found,
* short-circuiting the search. Default is
* false; return all matches.
* @return {String?|String[]} - Return an optional string result when in
* first-only mode; otherwise return a list
* of strings that match the query.
*/
}, {
key: 'search',
value: function search(string) {
var _ref2 = arguments.length <= 1 || arguments[1] === undefined ? { wildcard: null, prefix: false, first: false } : arguments[1];
var wildcard = _ref2.wildcard;
var prefix = _ref2.prefix;
var first = _ref2.first;
// Validate wildcard matching.
if (wildcard && wildcard.length !== 1) {
throw new Error('Wildcard length must be 1; got ' + wildcard.length);
}
// List of search hits. Note: not used in `first` mode.
var matches = [];
// Do a BFS over nodes to with fuzzy-matching on the wildcard.
var queue = [{ data: this.root, depth: 0, memo: '' }];
var lastDepth = string.length;
while (queue.length) {
var node = queue.shift();
// The search is a hit if we've reached the proper depth and the
// node is terminal. The search can break if the query was for
// first-only.
if (node.depth >= lastDepth) {
if (node.data.hasOwnProperty(_constants.TERMINAL)) {
if (first) {
return node.memo;
}
// Otherwise store this result and continue searching.
matches.push(node.memo);
}
// Discard the node and move on if we can; prefix matches need
// to traverse everything.
if (!prefix) {
continue;
}
}
// Special case: prefix searches overflow the length of the search
// queries. Treat these overflowing chars as wildcards.
var isPfXOverflow = prefix && node.depth >= lastDepth;
// Add any candidate children nodes to the search queue.
var token = string[node.depth];
// Wildcard could be any child (except terminal).
if (token === wildcard || isPfXOverflow) {
Object.keys(node.data).forEach(function (n) {
if (n !== _constants.TERMINAL) {
queue.push({
data: node.data[n],
depth: node.depth + 1,
memo: node.memo + n
});
}
});
} else {
if (node.data.hasOwnProperty(token)) {
queue.push({
data: node.data[token],
depth: node.depth + 1,
memo: node.memo + token
});
}
}
}
// A `first` search will have broken out and returned a literal by now;
// other searches just return whatever is in matches.
return first ? null : matches;
}
/**
* Clone a Trie. This will unfreeze a frozen trie.
* @return {Trie}
*/
}, {
key: 'clone',
value: function clone() {
return new Trie(this.toJSON());
}
/**
* Freeze the Trie, deduping suffixes. Given the assumption that there will
* not be new entries into a trie, redundant suffix branches can be merged.
* @return {Trie} - This trie (freezing modifies it in place)
*/
}, {
key: 'freeze',
value: function freeze() {
// Freezing is idempotent
if (this.frozen) {
return this;
}
// Create a store for fast lookup of matching suffixes during walk
var suffixTree = {};
// Walk the entire trie depth first, de-duping suffixes
var node = this.root;
var stack = [];
var depthStack = [node];
// Iterate over tree nodes, pushing children onto the depthStack so
// that the items pushed on to the main `stack` are in the correct
// order for a second traversal.
while (depthStack.length) {
node = depthStack.pop();
Object.keys(node).forEach(function (char) {
if (char[1] === '_') {
return;
}
var current = node[char];
stack.push({
current: current,
char: char,
parent: node
});
depthStack.push(current);
});
}
// Now do node processing, joining / deduping suffix lines.
var _loop = function _loop() {
var _stack$pop = stack.pop();
var char = _stack$pop.char;
var parent = _stack$pop.parent;
var current = _stack$pop.current;
// Find potential suffix duplicates with a char lookup
if (suffixTree.hasOwnProperty(char)) {
var suffixMeta = suffixTree[char];
// Find a matching suffix by comparing children. Since
// deduping is depth-first, comparing children by identity
// is a valid way to check if this node is a duplicate.
var match = suffixMeta.find(function (other) {
var oKeys = Object.keys(other);
var cKeys = Object.keys(current);
return oKeys.length === cKeys.length && oKeys.every(function (key) {
return other[key] === current[key];
});
});
// If this node is a dupe, update its parent reference to
// point to the cached match.
if (match) {
parent[char] = match;
}
// If the node is novel, cache it for future checks.
else {
suffixMeta.push(current);
}
}
// If this char is novel, create a new suffixMeta entry
else {
suffixTree[char] = [current];
}
};
while (stack.length) {
_loop();
}
// Flag the tree as frozen
this.frozen = true;
return this;
}
/**
* Encode the Trie in a binary format. This format stores the trie or DAWG
* efficiently and still allows for fast queries.
* @return {Object}
*/
}, {
key: 'encode',
value: function encode() {
var chunks = [];
var queue = [this.root];
var charTable = new Set();
var visitCode = Date.now();
var offsetMin = Infinity;
var offsetMax = -Infinity;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Encode trie
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var _loop2 = function _loop2() {
var node = queue.shift();
var keys = Object.keys(node).filter(function (k) {
return k[1] !== '_';
});
var n = keys.length;
node.__visited__ = visitCode;
var nodeChunkIndex = node.__idx__ = chunks.length;
// Fill in the parent chunks that are waiting to find out what
// index this chunk gets assigned
if (node.__parents__) {
node.__parents__.forEach(function (chunk) {
var offset = chunk.offset = nodeChunkIndex - chunk.idx;
if (offset < offsetMin) {
offsetMin = offset;
}
if (offset > offsetMax) {
offsetMax = offset;
}
});
}
keys.forEach(function (char, i) {
var child = node[char];
var chunkIdx = chunks.length;
var lastInLevel = i === n - 1;
var newChunk = {
char: char,
idx: chunkIdx,
offset: null,
last: lastInLevel
};
// If the child has been visited, jump directly to that node
// instead of creating a new entry.
if (child.__visited__ === visitCode) {
var idx = child.__idx__;
var offset = newChunk.offset = idx - chunkIdx;
if (offset < offsetMin) {
offsetMin = offset;
}
if (offset > offsetMax) {
offsetMax = offset;
}
}
// If child is novel, add it to the process queue and add an
// instruction to jump there.
else {
if (child.__willVisit__ === visitCode) {
child.__parents__.push(newChunk);
} else {
child.__willVisit__ = visitCode;
child.__parents__ = [newChunk];
}
queue.push(child);
}
// Add a new chunk to the array
chunks.push(newChunk);
// Ensure that the char is in the chartable
charTable.add(char);
});
};
while (queue.length) {
_loop2();
}
// Assign a unique integer ID to each character. The actual ID is
// arbitrary. For the convenience of not having to serialize the \0
// character, the TERMINAL is always encoded at the 0 index, and it is
// not included in the charTable.
var charTableAsArray = Array.from(charTable).filter(function (char) {
return char !== _constants.TERMINAL;
});
var charMap = charTableAsArray.reduce(function (agg, char, i) {
agg[char] = i + 1;
return agg;
}, _defineProperty({}, _constants.TERMINAL, 0));
// Determine the number of bits that can index the entire charTable.
var charEncodingWidth = (0, _floor_log2.default)(charTableAsArray.length) + 1;
var pointerRange = offsetMax - offsetMin;
var pointerEncodingWidth = (0, _floor_log2.default)(pointerRange) + 1;
// The binary with of node encodings is variable. There are three parts
// that get encoded:
//
// 1) character index (corresponding to character table),
// 2) pointer (as offset from start of word to next node),
// 3) last (flag to indicate whether this is the last block in this
// subtree)
//
// The width of the first two items are determined as the binary width
// of the unsigned integer representing the maximum in the range. The
// width of the third is a constant 1 binary digit.
//
// E.g., if the charTable is 28 characters in length, then the binary
// digit representing 27 (the last item in the array) is:
//
// 1 1011
//
// So the width is determined to be 5. If the pointer range has a
// maximum of 250, represented in binary as:
//
// 1111 1010
//
// Giving a width of 8. With these specifications, a node such as:
//
// charIndex: 8, pointer: 100, last: false
//
// Would be encoded as:
//
// --A---|----B-----|C|XXXXX
// 0100 0|011 0010 0|1|00 00
//
// Which can be represented in Base64 as:
//
// QyQ==
//
// TODO could be more clever and combine the first two fields.
var encodedTrie = new _BinaryString2.default();
chunks.forEach(function (chunk) {
var char = chunk.char;
var offset = chunk.offset;
var last = chunk.last;
encodedTrie.write(charMap[char], charEncodingWidth);
encodedTrie.write(offset - offsetMin, pointerEncodingWidth);
encodedTrie.write(+last, 1);
});
encodedTrie.flush();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Encode header
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var headerString = new _BinaryString2.default();
var outputCharTable = charTableAsArray.join('');
// Header width designates the ASCII-character count at the beginning
// of the file that encodes the header.
var headerWidth = Math.ceil((_constants.HEADER_WIDTH_FIELD + _constants.VERSION_FIELD + _constants.OFFSET_SIGN_FIELD + _constants.OFFSET_VAL_FIELD + _constants.CHAR_WIDTH_FIELD + _constants.POINTER_WIDTH_FIELD) / 6) + outputCharTable.length;
// Mark the offset as positive or negative
var offsetSign = +(offsetMin < 0);
headerString.write(headerWidth, _constants.HEADER_WIDTH_FIELD);
headerString.write(_constants.VERSION, _constants.VERSION_FIELD);
headerString.write(offsetSign, _constants.OFFSET_SIGN_FIELD);
headerString.write(offsetSign ? -offsetMin : offsetMin, _constants.OFFSET_VAL_FIELD);
headerString.write(charEncodingWidth, _constants.CHAR_WIDTH_FIELD);
headerString.write(pointerEncodingWidth, _constants.POINTER_WIDTH_FIELD);
headerString.flush();
// Concat the header, charTable, and trie
return '' + headerString.getData() + outputCharTable + encodedTrie.getData();
}
/**
* Implement JSON API for serialization. Tries can be serialized and
* restored using JSON and the constructor. Note that tries (even frozen
* ones) *do not serialize efficiently in JSON*. For memory-efficient
* tries, @see Trie#encode.
*
* @example
* > trie = new Trie();
* > ['foo', 'fudge', 'nudge'].forEach(s => trie.insert(s));
* > let jsonStr = JSON.stringify(trie);
* > let restored = new Trie(JSON.parse(jsonStr));
* > ['foo', 'fudge', 'nudge'].every(s => restored.test(s));
* // -> true
*
* @return {Object} Vanilla JS object
*/
}, {
key: 'toJSON',
value: function toJSON() {
// Remove any private fields on serialization, e.g. __visited__
var str = JSON.stringify(this.root, function (k, v) {
if (k[1] === '_') {
return undefined;
}
return v;
});
return JSON.parse(str);
}
}]);
return Trie;
})();
exports.default = Trie;
/***/ },
/* 4 */
/***/ function(module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = floor_log2;
/**
* @file Provides a fast floor_log2 function
*/
/**
* Fast floor(log2(x)) operation
* @param {Number} x
* @return {Number}
*/
function floor_log2(x) {
var n = 0;
while (x >>= 1) {
n++;
}
return n;
}
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
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; }; })(); /**
* @file Provide an interface for writing binary data into a Base64-encoded
* string.
*/
Object.defineProperty(exports, "__esModule", {
value: true
});
var _floor_log = __webpack_require__(4);
var _floor_log2 = _interopRequireDefault(_floor_log);
var _base = __webpack_require__(1);
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"); } }
/**
* Interface for writing binary data into a Base64-encoded string
* @class
*/
var BinaryString = (function () {
/**
* No arguments are necessary.
* @constructor
* @return {BinaryString}
*/
function BinaryString() {
_classCallCheck(this, BinaryString);
/**
* Data buffer
* @type {Number?}
*/
this.buffer = 0;
/**
* Word pointer for buffer. With every entry into the buffer, the
* pointer gets incremented by the entry's width. Every six characters
* may be encoded, so when the pointer exceeds 6, the buffer can be
* emptied until the pointer is back under 6.
* @type {Number}
*/
this.pointer = 0;
/**
* Encoded data as a string of base64 characters
* @type {String}
*/
this.data = '';
}
/**
* Write a value to the binary string. This value should be thought of as
* an integer representing the binary data to write.
* @param {Integer} val - data to write
* @param {Integer} [width] - optionally specify a width for this data.
* if none is given, width will be inferred
* automatically. An error will be thrown if
* the width is too small to contain the data.
*/
_createClass(BinaryString, [{
key: 'write',
value: function write(val) {
var width = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
var buf = this.buffer;
var len = width || (0, _floor_log2.default)(val) + 1;
if (width && val >= 0x1 << width) {
throw new Error('Can\'t write ' + val + ' in only ' + width + ' bits');
}
this.buffer = buf << len | val;
this.pointer += len;
this._digest();
}
/**
* Encode the remaining items in the buffer. Use this when the input stream
* is finished to ensure that all data has been encoded.
*/
}, {
key: 'flush',
value: function flush() {
var buffer = this.buffer;
var pointer = this.pointer;
// NB if pointer is at 0, there's nothing to flush.
while (pointer && pointer < 6) {
buffer <<= 1;
pointer += 1;
}
this.pointer = pointer;
this.buffer = buffer;
this._digest();
}
/**
* Get the binary data as base64. This output does not include padding
* characters. This procedure flushes the buffer.
* @return {String}
*/
}, {
key: 'getData',
value: function getData() {
this.flush();
return this.data;
}
/**
* Write values from the buffer into the binary encoded string until the
* pointer is below 6. Use @link BinaryString#flush to print out all values
* regardless of whether they are complete and return the pointer to 0.
*
* This method is used internally during writes and does not need to be
* called explicitly.
* @private
*/
}, {
key: '_digest',
value: function _digest() {
var buffer = this.buffer;
var pointer = this.pointer;
var newData = '';
while (pointer >= 6) {
var remainder = pointer - 6;
var code = buffer >> remainder;
buffer = buffer ^ code << remainder;
pointer = remainder;
newData += _base.BASE64_INT_TO_CHAR[code];
}
this.pointer = pointer;
this.buffer = buffer;
this.data += newData;
}
}]);
return BinaryString;
})();
exports.default = BinaryString;
/***/ }
/******/ ])
});
;
/******/ });
});

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.TinyTrie=t():e.TinyTrie=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e){var t=new a["default"];return e.forEach(function(e){return t.insert(e)}),t}function u(e){return i(e).freeze()}Object.defineProperty(t,"__esModule",{value:!0}),t.Trie=void 0;var o=r(3);Object.defineProperty(t,"Trie",{enumerable:!0,get:function(){return o["default"]}}),t.createSync=i,t.createFrozenSync=u;var a=n(o)},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=t.BASE64_INT_TO_CHAR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");t.BASE64_CHAR_TO_INT=r.reduce(function(e,t,r){return e[t]=r,e},{})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.TERMINAL="\x00",t.TERMINUS=Object.create(null),t.VERSION=0,t.HEADER_WIDTH_FIELD=10,t.VERSION_FIELD=10,t.OFFSET_SIGN_FIELD=1,t.OFFSET_VAL_FIELD=21,t.CHAR_WIDTH_FIELD=8,t.POINTER_WIDTH_FIELD=8},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(t,"__esModule",{value:!0});var f=r(4),s=n(f),c=r(5),l=n(c),h=r(2),_=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];o(this,e),this.root=t,this.frozen=!1}return a(e,[{key:"insert",value:function(e){if(this.frozen)throw new SyntaxError("Can't insert into frozen Trie");var t=e.split("").reduce(function(e,t){if(t===h.TERMINAL)throw new TypeError("Illegal string character "+h.TERMINAL);var r=e.hasOwnProperty(t)?e[t]:e[t]={};return r},this.root);return t[h.TERMINAL]=h.TERMINUS,this}},{key:"test",value:function(e){var t=this,r=arguments.length<=1||void 0===arguments[1]?{wildcard:null,prefix:!1}:arguments[1],n=r.wildcard,i=r.prefix;if(!n){var o=function(){var r=t.root,n=e.split("").every(function(e){return r=r[e]});return{v:!!n&&(i||r.hasOwnProperty(h.TERMINAL))}}();if("object"===("undefined"==typeof o?"undefined":u(o)))return o.v}return!!this.search(e,{wildcard:n,prefix:i,first:!0})}},{key:"search",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?{wildcard:null,prefix:!1,first:!1}:arguments[1],r=t.wildcard,n=t.prefix,i=t.first;if(r&&1!==r.length)throw new Error("Wildcard length must be 1; got "+r.length);for(var u=[],o=[{data:this.root,depth:0,memo:""}],a=e.length;o.length;){var f=o.shift();if(f.depth>=a){if(f.data.hasOwnProperty(h.TERMINAL)){if(i)return f.memo;u.push(f.memo)}if(!n)continue}var s=n&&f.depth>=a,c=e[f.depth];c===r||s?Object.keys(f.data).forEach(function(e){e!==h.TERMINAL&&o.push({data:f.data[e],depth:f.depth+1,memo:f.memo+e})}):f.data.hasOwnProperty(c)&&o.push({data:f.data[c],depth:f.depth+1,memo:f.memo+c})}return i?null:u}},{key:"clone",value:function(){return new e(this.toJSON())}},{key:"freeze",value:function(){if(this.frozen)return this;for(var e={},t=this.root,r=[],n=[t];n.length;)t=n.pop(),Object.keys(t).forEach(function(e){if("_"!==e[1]){var i=t[e];r.push({current:i,"char":e,parent:t}),n.push(i)}});for(var i=function(){var t=r.pop(),n=t["char"],i=t.parent,u=t.current;if(e.hasOwnProperty(n)){var o=e[n],a=o.find(function(e){var t=Object.keys(e),r=Object.keys(u);return t.length===r.length&&t.every(function(t){return e[t]===u[t]})});a?i[n]=a:o.push(u)}else e[n]=[u]};r.length;)i();return this.frozen=!0,this}},{key:"encode",value:function(){for(var e=[],t=[this.root],r=new Set,n=Date.now(),u=1/0,o=-(1/0),a=function(){var i=t.shift(),a=Object.keys(i).filter(function(e){return"_"!==e[1]}),f=a.length;i.__visited__=n;var s=i.__idx__=e.length;i.__parents__&&i.__parents__.forEach(function(e){var t=e.offset=s-e.idx;u>t&&(u=t),t>o&&(o=t)}),a.forEach(function(a,s){var c=i[a],l=e.length,h=s===f-1,_={"char":a,idx:l,offset:null,last:h};if(c.__visited__===n){var d=c.__idx__,p=_.offset=d-l;u>p&&(u=p),p>o&&(o=p)}else c.__willVisit__===n?c.__parents__.push(_):(c.__willVisit__=n,c.__parents__=[_]),t.push(c);e.push(_),r.add(a)})};t.length;)a();var f=Array.from(r).filter(function(e){return e!==h.TERMINAL}),c=f.reduce(function(e,t,r){return e[t]=r+1,e},i({},h.TERMINAL,0)),_=(0,s["default"])(f.length)+1,d=o-u,p=(0,s["default"])(d)+1,v=new l["default"];e.forEach(function(e){var t=e["char"],r=e.offset,n=e.last;v.write(c[t],_),v.write(r-u,p),v.write(+n,1)}),v.flush();var E=new l["default"],y=f.join(""),I=Math.ceil((h.HEADER_WIDTH_FIELD+h.VERSION_FIELD+h.OFFSET_SIGN_FIELD+h.OFFSET_VAL_FIELD+h.CHAR_WIDTH_FIELD+h.POINTER_WIDTH_FIELD)/6)+y.length,g=+(0>u);return E.write(I,h.HEADER_WIDTH_FIELD),E.write(h.VERSION,h.VERSION_FIELD),E.write(g,h.OFFSET_SIGN_FIELD),E.write(g?-u:u,h.OFFSET_VAL_FIELD),E.write(_,h.CHAR_WIDTH_FIELD),E.write(p,h.POINTER_WIDTH_FIELD),E.flush(),""+E.getData()+y+v.getData()}},{key:"toJSON",value:function(){var e=JSON.stringify(this.root,function(e,t){return"_"===e[1]?void 0:t});return JSON.parse(e)}}]),e}();t["default"]=_},function(e,t){"use strict";function r(e){for(var t=0;e>>=1;)t++;return t}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),a=n(o),f=r(1),s=function(){function e(){i(this,e),this.buffer=0,this.pointer=0,this.data=""}return u(e,[{key:"write",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?null:arguments[1],r=this.buffer,n=t||(0,a["default"])(e)+1;if(t&&e>=1<<t)throw new Error("Can't write "+e+" in only "+t+" bits");this.buffer=r<<n|e,this.pointer+=n,this._digest()}},{key:"flush",value:function(){for(var e=this.buffer,t=this.pointer;t&&6>t;)e<<=1,t+=1;this.pointer=t,this.buffer=e,this._digest()}},{key:"getData",value:function(){return this.flush(),this.data}},{key:"_digest",value:function(){for(var e=this.buffer,t=this.pointer,r="";t>=6;){var n=t-6,i=e>>n;e^=i<<n,t=n,r+=f.BASE64_INT_TO_CHAR[i]}this.pointer=t,this.buffer=e,this.data+=r}}]),e}();t["default"]=s}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TinyTrie=e():t.TinyTrie=e()}(window,function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=8)}([function(t,e){function n(t){var e=new Error('Cannot find module "'+t+'".');throw e.code="MODULE_NOT_FOUND",e}n.keys=function(){return[]},n.resolve=n,t.exports=n,n.id=0},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){"use strict";(function(t){var o,r,i,f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(u){if("object"===f(t)&&"object"===f(t.exports)){var c=u(n(0),e);void 0!==c&&(t.exports=c)}else r=[n,e],void 0===(i="function"==typeof(o=u)?o.apply(e,r):o)||(t.exports=i)}(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.TERMINAL="\0",e.TERMINUS=Object.create(null),e.VERSION=0,e.HEADER_WIDTH_FIELD=10,e.VERSION_FIELD=10,e.OFFSET_SIGN_FIELD=1,e.OFFSET_VAL_FIELD=21,e.CHAR_WIDTH_FIELD=8,e.POINTER_WIDTH_FIELD=8})}).call(this,n(1)(t))},function(t,e,n){"use strict";(function(t){var o,r,i,f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(u){if("object"===f(t)&&"object"===f(t.exports)){var c=u(n(0),e);void 0!==c&&(t.exports=c)}else r=[n,e],void 0===(i="function"==typeof(o=u)?o.apply(e,r):o)||(t.exports=i)}(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.BASE64_INT_TO_CHAR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),e.BASE64_CHAR_TO_INT=e.BASE64_INT_TO_CHAR.reduce(function(t,e,n){return t[e]=n,t},{})})}).call(this,n(1)(t))},function(t,e,n){"use strict";(function(t){var o,r,i,f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(u){if("object"===f(t)&&"object"===f(t.exports)){var c=u(n(0),e);void 0!==c&&(t.exports=c)}else r=[n,e],void 0===(i="function"==typeof(o=u)?o.apply(e,r):o)||(t.exports=i)}(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){for(var e=0;t>>=1;)e++;return e}})}).call(this,n(1)(t))},function(t,e,n){"use strict";(function(t){var o,r,i,f=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(f){if("object"===u(t)&&"object"===u(t.exports)){var c=f(n(0),e);void 0!==c&&(t.exports=c)}else r=[n,e,n(4),n(7),n(2)],void 0===(i="function"==typeof(o=f)?o.apply(e,r):o)||(t.exports=i)}(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=t("./floor_log2"),o=t("./BinaryString"),r=t("./constants"),i=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.root=e,this.frozen=!1}return f(t,[{key:"insert",value:function(t){if(this.frozen)throw new SyntaxError("Can't insert into frozen Trie");return t.split("").reduce(function(t,e){if(e===r.TERMINAL)throw new TypeError("Illegal string character "+r.TERMINAL);return t.hasOwnProperty(e)?t[e]:t[e]={}},this.root)[r.TERMINAL]=r.TERMINUS,this}},{key:"test",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{wildcard:null,prefix:!1},n=e.wildcard,o=e.prefix;if(!n){var i=this.root;return!!t.split("").every(function(t){return!!(i=i[t])})&&(o||i.hasOwnProperty(r.TERMINAL))}return!!this.search(t,{wildcard:n,prefix:o,first:!0})}},{key:"search",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{wildcard:null,prefix:!1,first:!1},n=e.wildcard,o=e.prefix,i=e.first;if(n&&1!==n.length)throw new Error("Wildcard length must be 1; got "+n.length);for(var f=[],c=[{data:this.root,depth:0,memo:""}],a=t.length,l=function(){var e=c.shift();if(e.depth>=a){if(e.data.hasOwnProperty(r.TERMINAL)){if(i)return{v:e.memo};f.push(e.memo)}if(!o)return"continue"}var u=o&&e.depth>=a,l=t[e.depth];l===n||u?Object.keys(e.data).forEach(function(t){t!==r.TERMINAL&&c.push({data:e.data[t],depth:e.depth+1,memo:e.memo+t})}):e.data.hasOwnProperty(l)&&c.push({data:e.data[l],depth:e.depth+1,memo:e.memo+l})};c.length;){var s=l();switch(s){case"continue":continue;default:if("object"===(void 0===s?"undefined":u(s)))return s.v}}return i?null:f}},{key:"clone",value:function(){return new t(this.toJSON())}},{key:"freeze",value:function(){if(this.frozen)return this;for(var t={},e=this.root,n=[],o=[e];o.length;)e=o.pop(),Object.keys(e).forEach(function(t){if("_"!==t[1]){var r=e[t];n.push({current:r,char:t,parent:e}),o.push(r)}});for(var r=function(){var e=n.pop(),o=e.char,r=e.parent,i=e.current;if(t.hasOwnProperty(o)){var f=t[o],u=f.find(function(t){var e=Object.keys(t),n=Object.keys(i);return e.length===n.length&&e.every(function(e){return t[e]===i[e]})});u?r[o]=u:f.push(i)}else t[o]=[i]};n.length;)r();return this.frozen=!0,this}},{key:"encode",value:function(){for(var t=[],e=[this.root],i=new Set,f=Date.now(),u=1/0,c=-1/0,a=function(){var n=e.shift(),o=Object.keys(n).filter(function(t){return"_"!==t[1]}),r=o.length;n.__visited__=f;var a=n.__idx__=t.length;n.__parents__&&n.__parents__.forEach(function(t){var e=t.offset=a-t.idx;e<u&&(u=e),e>c&&(c=e)}),o.forEach(function(o,a){var l=n[o],s=t.length,p={char:o,idx:s,offset:null,last:a===r-1};if(l.__visited__===f){var y=l.__idx__,d=p.offset=y-s;d<u&&(u=d),d>c&&(c=d)}else l.__willVisit__===f?l.__parents__.push(p):(l.__willVisit__=f,l.__parents__=[p]),e.push(l);t.push(p),i.add(o)})};e.length;)a();var l,s,p,y=Array.from(i).filter(function(t){return t!==r.TERMINAL}),d=y.reduce(function(t,e,n){return t[e]=n+1,t},(l={},s=r.TERMINAL,p=0,s in l?Object.defineProperty(l,s,{value:p,enumerable:!0,configurable:!0,writable:!0}):l[s]=p,l)),h=n.default(y.length)+1,_=c-u,b=n.default(_)+1,v=new o.default;t.forEach(function(t){var e=t.char,n=t.offset,o=t.last;v.write(d[e],h),v.write(n-u,b),v.write(+o,1)}),v.flush();var m=new o.default,E=y.join(""),S=Math.ceil((r.HEADER_WIDTH_FIELD+r.VERSION_FIELD+r.OFFSET_SIGN_FIELD+r.OFFSET_VAL_FIELD+r.CHAR_WIDTH_FIELD+r.POINTER_WIDTH_FIELD)/6)+E.length,I=+(u<0);return m.write(S,r.HEADER_WIDTH_FIELD),m.write(r.VERSION,r.VERSION_FIELD),m.write(I,r.OFFSET_SIGN_FIELD),m.write(I?-u:u,r.OFFSET_VAL_FIELD),m.write(h,r.CHAR_WIDTH_FIELD),m.write(b,r.POINTER_WIDTH_FIELD),m.flush(),""+m.getData()+E+v.getData()}},{key:"toJSON",value:function(){var t=JSON.stringify(this.root,function(t,e){if("_"!==t[1])return e});return JSON.parse(t)}}]),t}();e.default=i})}).call(this,n(1)(t))},,function(t,e,n){"use strict";(function(t){var o,r,i,f=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(f){if("object"===u(t)&&"object"===u(t.exports)){var c=f(n(0),e);void 0!==c&&(t.exports=c)}else r=[n,e,n(4),n(3)],void 0===(i="function"==typeof(o=f)?o.apply(e,r):o)||(t.exports=i)}(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=t("./floor_log2"),o=t("./base64"),r=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.buffer=0,this.pointer=0,this.data=""}return f(t,[{key:"write",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=this.buffer,r=e||n.default(t)+1;if(e&&t>=1<<e)throw new Error("Can't write "+t+" in only "+e+" bits");this.buffer=o<<r|t,this.pointer+=r,this._digest()}},{key:"flush",value:function(){for(var t=this.buffer,e=this.pointer;e&&e<6;)t<<=1,e+=1;this.pointer=e,this.buffer=t,this._digest()}},{key:"getData",value:function(){return this.flush(),this.data}},{key:"_digest",value:function(){for(var t=this.buffer,e=this.pointer,n="";e>=6;){var r=e-6,i=t>>r;t^=i<<r,e=r,n+=o.BASE64_INT_TO_CHAR[i]}this.pointer=e,this.buffer=t,this.data+=n}}]),t}();e.default=r})}).call(this,n(1)(t))},function(t,e,n){"use strict";(function(t){var o,r,i,f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(u){if("object"===f(t)&&"object"===f(t.exports)){var c=u(n(0),e);void 0!==c&&(t.exports=c)}else r=[n,e,n(5),n(5)],void 0===(i="function"==typeof(o=u)?o.apply(e,r):o)||(t.exports=i)}(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=t("./Trie"),o=t("./Trie");function r(t){var e=new n.default;return t.forEach(function(t){return e.insert(t)}),e}e.Trie=o.default,e.createSync=r,e.createFrozenSync=function(t){return r(t).freeze()}})}).call(this,n(1)(t))}])});
{
"source": "./lib",
"destination": "./doc"
"destination": "./docs"
}
{
"name": "tiny-trie",
"version": "0.2.0",
"version": "0.2.1",
"description": "JS Trie / DAWG classes",
"main": "lib/index.js",
"scripts": {
"lint": "$(npm bin)/eslint ./lib",
"lint": "$(npm bin)/tslint lib/**/*.ts",
"build": "$(npm bin)/webpack",
"build-min": "NODE_ENV=production $(npm bin)/webpack",
"build-doc": "$(npm bin)/esdoc -c esdoc.json",
"build-doc": "$(npm bin)/typedoc --out docs/",
"build-all": "npm run build && npm run build-min && npm run build-doc",
"test": "npm run lint && $(npm bin)/mocha --compilers js:babel-core/register lib/*.test.js"
"test": "npm run lint && $(npm bin)/mocha --compilers ts:ts-node/register lib/*.test.ts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jnu/tiny-tree.git"
"url": "git+https://github.com/jnu/tiny-trie.git"
},

@@ -28,18 +28,26 @@ "keywords": [

"bugs": {
"url": "https://github.com/jnu/tiny-tree/issues"
"url": "https://github.com/jnu/tiny-trie/issues"
},
"homepage": "https://github.com/jnu/tiny-tree#readme",
"homepage": "https://github.com/jnu/tiny-trie#readme",
"devDependencies": {
"babel": "^6.0.15",
"babel-cli": "^6.1.1",
"babel-core": "^6.0.20",
"babel-loader": "^6.0.1",
"@types/chai": "^4.1.2",
"@types/mocha": "^2.2.48",
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-preset-es2015": "^6.0.15",
"benchmark": "^1.0.0",
"esdoc": "^0.4.3",
"eslint": "^1.8.0",
"chai": "^4.1.2",
"mocha": "^2.3.3",
"tap": "^2.2.0",
"webpack": "^1.12.2"
}
"ts-loader": "^4.0.1",
"ts-node": "^5.0.1",
"tslint": "^5.9.1",
"typedoc": "^0.11.1",
"typescript": "^2.7.2",
"webpack": "^4.1.1",
"webpack-cli": "^2.0.12"
},
"dependencies": {}
}

@@ -32,4 +32,8 @@ tiny-trie

## Usage
## Docs
See complete docs at https://jnu.github.io/tiny-trie/
## Quick Usage
```js

@@ -36,0 +40,0 @@ const words = ['spit', 'spat', 'spot', 'spits', 'spats', 'spots'];

/* eslint-env node */
var UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
var path = require('path');

@@ -9,22 +8,31 @@

var plugins = [];
if (!DEBUG) {
plugins.push(new UglifyJsPlugin());
}
module.exports = {
entry: {
'tiny-trie': './lib/index.js',
'packed-trie': './lib/PackedTrie.js'
'tiny-trie': './lib/index.ts',
'packed-trie': './lib/PackedTrie.ts'
},
mode: DEBUG ? 'development' : 'production',
module: {
loaders: [
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel?cacheDirectory'
}
]
exclude: [/node_modules/],
use: [{
loader: 'babel-loader',
options: {cacheDirectory: true}
}]
},
{
test: /\.ts$/,
exclude: [/node_modules/],
use: [{
loader: 'babel-loader',
options: {cacheDirectory: true}
}, {
loader: 'ts-loader'
}]
},
],
},
plugins: plugins,
output: {

@@ -35,3 +43,7 @@ path: path.join(__dirname, 'dist'),

library: 'TinyTrie'
},
resolve: {
extensions: ['.js', '.ts'],
modules: [path.join(__dirname, 'lib'), 'node_modules']
}
};
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc