You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
6.6 KiB
1 line
6.6 KiB
5 months ago
|
{"version":3,"file":"bundle.cjs","sources":["es5/index.js"],"sourcesContent":["// A [trie](https://en.wikipedia.org/wiki/Trie) data structure that holds\n// object keys weakly, yet can also hold non-object keys, unlike the\n// native `WeakMap`.\n// If no makeData function is supplied, the looked-up data will be an empty,\n// null-prototype Object.\nvar defaultMakeData = function () { return Object.create(null); };\n// Useful for processing arguments objects as well as arrays.\nvar _a = Array.prototype, forEach = _a.forEach, slice = _a.slice;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar Trie = /** @class */ (function () {\n function Trie(weakness, makeData) {\n if (weakness === void 0) { weakness = true; }\n if (makeData === void 0) { makeData = defaultMakeData; }\n this.weakness = weakness;\n this.makeData = makeData;\n }\n Trie.prototype.lookup = function () {\n return this.lookupArray(arguments);\n };\n Trie.prototype.lookupArray = function (array) {\n var node = this;\n forEach.call(array, function (key) { return node = node.getChildTrie(key); });\n return hasOwnProperty.call(node, \"data\")\n ? node.data\n : node.data = this.makeData(slice.call(array));\n };\n Trie.prototype.peek = function () {\n return this.peekArray(arguments);\n };\n Trie.prototype.peekArray = function (array) {\n var node = this;\n for (var i = 0, len = array.length; node && i < len; ++i) {\n var map = node.mapFor(array[i], false);\n node = map && map.get(array[i]);\n }\n return node && node.data;\n };\n Trie.prototype.remove = function () {\n return this.removeArray(arguments);\n };\n Trie.prototype.removeArray = function (array) {\n var data;\n if (array.length) {\n var head = array[0];\n var map = this.mapFor(head, false);\n var child = map && map.get(head);\n if (child) {\n data = child.removeArray(slice.call(array, 1));\n if (!child.data && !child.weak && !(child.strong && child.strong.size)) {\n map.delete(head);\n }\n }\n }\n else {\n data = this.data;\n delete this.data;\n }\n return data;\n };\n Trie.prototype.getChildTrie = function (key) {\n var map = this.mapFor(key, true);\n var child = map.get(key);\n if (!child)\n map.set(key, child = new Trie(this.weakness, this.makeData));\n return child;\n };\n Trie.prototype.mapFor = function (key, create) {\n return this.weakness && isObjRef(key)\n ? this.weak || (create ? this.weak = new WeakMap : void 0)\n : this.strong || (create ? this.strong = new Map : void 0);\n };\n return Trie;\n}());\nexport { Trie };\nfunction isObjRef(value) {\n switch (typeof value) {\n case \"object\":\n if (value === null)\n break;\n // Fall through to return true...\n case \"function\":\n return true;\n }\n return false;\n}\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,IAAI,eAAe,GAAG,YAAY,EAAE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;AAClE;AACA,IAAI,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC;AACjE,IAAI,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AAClD,IAAC,IAAI,kBAAkB,YAAY;AACtC,IAAI,SAAS,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE;AACtC,QAAQ,IAAI,QAAQ,KAAK,KAAK,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAAC,EAAE;AACrD,QAAQ,IAAI,QAAQ,KAAK,KAAK,CAAC,EAAE,EAAE,QAAQ,GAAG,eAAe,CAAC,EAAE;AAChE,QAAQ,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACjC,QAAQ,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACjC,KAAK;AACL,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,YAAY;AACxC,QAAQ,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;AAC3C,KAAK,CAAC;AACN,IAAI,IAAI,CAAC,SAAS,CAAC,WAAW,GAAG,UAAU,KAAK,EAAE;AAClD,QAAQ,IAAI,IAAI,GAAG,IAAI,CAAC;AACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,UAA
|