@player-ui/partial-match-registry 0.14.1-next.6 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Registry.native.js +3 -3
- package/dist/Registry.native.js.map +1 -1
- package/dist/cjs/index.cjs +3 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/matcher.test.ts +2 -2
- package/src/deep-partial-matcher.ts +6 -2
- package/src/index.ts +2 -2
- package/types/deep-partial-matcher.d.ts +6 -2
- package/types/index.d.ts +1 -1
package/dist/Registry.native.js
CHANGED
|
@@ -86,7 +86,7 @@ var Registry = function() {
|
|
|
86
86
|
for(e = e.split ? e.split(".") : e, n = 0; n < e.length; n++)t = t ? t[e[n]] : r;
|
|
87
87
|
return t === r ? l : t;
|
|
88
88
|
};
|
|
89
|
-
var
|
|
89
|
+
var createObjectMatcher = function createObjectMatcher(partialObj) {
|
|
90
90
|
var pairs = traverseObj(partialObj);
|
|
91
91
|
var matchFunction = function(searchObj) {
|
|
92
92
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -278,7 +278,7 @@ var Registry = function() {
|
|
|
278
278
|
return Registry;
|
|
279
279
|
},
|
|
280
280
|
createObjectMatcher: function() {
|
|
281
|
-
return
|
|
281
|
+
return createObjectMatcher;
|
|
282
282
|
}
|
|
283
283
|
});
|
|
284
284
|
var import_sorted_array = __toESM(require_sorted_array());
|
|
@@ -334,7 +334,7 @@ var Registry = function() {
|
|
|
334
334
|
{
|
|
335
335
|
/** Add match -> value mapping to the registry */ key: "set",
|
|
336
336
|
value: function set(match, value) {
|
|
337
|
-
var matcher = (typeof match === "undefined" ? "undefined" : _type_of(match)) === "object" ?
|
|
337
|
+
var matcher = (typeof match === "undefined" ? "undefined" : _type_of(match)) === "object" ? createObjectMatcher(match) : createBasicMatcher(match);
|
|
338
338
|
this.store.insert({
|
|
339
339
|
key: match,
|
|
340
340
|
value: value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2469/execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/dist/index.global.js","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/dlv@1.1.3/node_modules/dlv/index.js","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/sorted-array@2.0.4/node_modules/sorted-array/sorted-array.js"],"names":["Registry","dlv_es_default","obj","key","def","p","undef","split","length","createMatcher","partialObj","pairs","traverseObj","matchFunction","searchObj","Array","from","entry","path","value","count","size","createBasicMatcher","seed","matcher","match","__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__commonJS","cb","mod","__require","exports","__export","target","all","name","get","enumerable","__copyProps","to","except","desc","call","__toESM","isNodeMode","__esModule","__toCommonJS","require_sorted_array","module","SortedArray","defclass","array","compare","compareDefault","index","insert","element","high","low","pos","ordering","push","search","remove","splice","comparing","property","a","b","constructor","define","amd","src_exports","createObjectMatcher","import_sorted_array","object","Map","keys","val","nestedPath","set","createSortedArray","c","initialSet","store","forEach","query","callbackfn","clear","isRegistryEmpty"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,WAA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;uBAAAA,SAAAA,IAAIpE,KAAA,EAAYN,KAAA;oBACd,IAAMK,UACJ,CAAA,OAAOC,sCAAP,SAAOA,MAAA,MAAU,WACbhB,cAAoBgB,SACpBH,mBAAmBG;oBAEzB,IAAA,CAAKwE,KAAA,CAAM7B,MAAA,CAAO;wBAChBjE,KAAKsB;wBACLN,OAAAA;wBACAK,SAAAA;oBACF;gBACF;;;gBAAA,yCAAA,GAGAyB,KAAAA;uBAAAA,SAAAA,IAAIkD,KAAA;wBACF,kCAAA,2BAAA;;wBAAA,QAAA,YAAoB,IAAA,CAAKF,KAAA,CAAMjC,KAAA,qBAA/B,SAAA,6BAAA,QAAA,yBAAA,iCAAsC;4BAAtC,IAAW/C,QAAX;4BACE,IAAIA,MAAMO,OAAA,CAAQ2E,QAAQ;gCACxB,OAAOlF,MAAME,KAAA;4BACf;wBACF;;wBAJA;wBAAA;;;iCAAA,6BAAA;gCAAA;;;gCAAA;sCAAA;;;;gBAKF;;;gBAAA,2CAAA,GAGA+E,KAAAA;uBAAAA,SAAAA,QAAQE,UAAA;wBACN,kCAAA,2BAAA;;wBAAA,QAAA,YAAoB,IAAA,CAAKH,KAAA,CAAMjC,KAAA,qBAA/B,SAAA,6BAAA,QAAA,yBAAA,iCAAsC;4BAAtC,IAAW/C,QAAX;4BACEmF,WAAWnF;wBACb;;wBAFA;wBAAA;;;iCAAA,6BAAA;gCAAA;;;gCAAA;sCAAA;;;;gBAGF;;;gBAAA,oCAAA,GAGAoF,KAAAA;uBAAAA,SAAAA;oBACE,IAAA,CAAKJ,KAAA,GAAQH;gBACf;;;gBAAA,kCAAA,GAGAQ,KAAAA;uBAAAA,SAAAA;oBACE,OAAO,IAAA,CAAKL,KAAA,CAAMjC,KAAA,CAAMxD,MAAA,KAAW;gBACrC;;;;;IHuIA,OAAOmD,aAAa0B;AACtB","sourcesContent":["\"use strict\";\nvar Registry = (() => {\n var __create = Object.create;\n var __defProp = Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __getProtoOf = Object.getPrototypeOf;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __commonJS = (cb, mod) => function __require() {\n return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;\n };\n var __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n };\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n };\n var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n ));\n var __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/sorted-array@2.0.4/node_modules/sorted-array/sorted-array.js\n var require_sorted_array = __commonJS({\n \"../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/sorted-array@2.0.4/node_modules/sorted-array/sorted-array.js\"(exports, module) {\n \"use strict\";\n var SortedArray2 = function() {\n var SortedArray3 = defclass({\n constructor: function(array, compare) {\n this.array = [];\n this.compare = compare || compareDefault;\n var length = array.length, index = 0;\n while (index < length)\n this.insert(array[index++]);\n },\n insert: function(element) {\n var array = this.array, compare = this.compare, high = array.length - 1, low = 0, pos = -1, index, ordering;\n while (high >= low) {\n index = (high + low) / 2 >>> 0;\n ordering = compare(array[index], element);\n if (ordering < 0)\n low = index + 1;\n else if (ordering > 0)\n high = index - 1;\n else {\n pos = index;\n break;\n }\n ;\n }\n if (pos === -1) {\n pos = high;\n }\n pos++;\n high = array.length - 1;\n while (pos < high && compare(element, array[pos]) === 0) {\n pos++;\n }\n index = array.length;\n array.push(element);\n while (index > pos) {\n array[index] = array[--index];\n }\n array[pos] = element;\n return this;\n },\n search: function(element) {\n var array = this.array, compare = this.compare, high = array.length - 1, low = 0, index, ordering;\n while (high >= low) {\n index = (high + low) / 2 >>> 0;\n ordering = compare(array[index], element);\n if (ordering < 0)\n low = index + 1;\n else if (ordering > 0)\n high = index - 1;\n else\n return index;\n }\n return -1;\n },\n remove: function(element) {\n var index = this.search(element);\n if (index >= 0)\n this.array.splice(index, 1);\n return this;\n }\n });\n SortedArray3.comparing = function(property, array) {\n return new SortedArray3(array, function(a, b) {\n return compareDefault(a[property], b[property]);\n });\n };\n return SortedArray3;\n function defclass(prototype) {\n var constructor = prototype.constructor;\n constructor.prototype = prototype;\n return constructor;\n }\n function compareDefault(a, b) {\n if (a < b)\n return -1;\n else if (a > b)\n return 1;\n else\n return 0;\n }\n }();\n if (typeof module === \"object\")\n module.exports = SortedArray2;\n if (typeof define === \"function\" && define.amd)\n define(function() {\n return SortedArray2;\n });\n }\n });\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts\n var src_exports = {};\n __export(src_exports, {\n Registry: () => Registry,\n createObjectMatcher: () => createMatcher\n });\n var import_sorted_array = __toESM(require_sorted_array());\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/dlv@1.1.3/node_modules/dlv/dist/dlv.es.js\n function dlv_es_default(t, e, l, n, r) {\n for (e = e.split ? e.split(\".\") : e, n = 0; n < e.length; n++)\n t = t ? t[e[n]] : r;\n return t === r ? l : t;\n }\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts\n function traverseObj(object, path = [], pairs = /* @__PURE__ */ new Map()) {\n for (const key of Object.keys(object)) {\n const val = object[key];\n const nestedPath = [...path, key];\n if (typeof val === \"object\") {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n return pairs;\n }\n function createMatcher(partialObj) {\n const pairs = traverseObj(partialObj);\n const matchFunction = (searchObj) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n if (dlv_es_default(searchObj, path) !== value) {\n return false;\n }\n }\n return true;\n };\n matchFunction.count = pairs.size;\n return matchFunction;\n }\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts\n function createBasicMatcher(seed) {\n const matcher = (match) => seed === match;\n matcher.count = 1;\n return matcher;\n }\n var createSortedArray = () => new import_sorted_array.default([], (c) => c.matcher.count);\n var Registry = class {\n constructor(initialSet) {\n this.store = createSortedArray();\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n /** Add match -> value mapping to the registry */\n set(match, value) {\n const matcher = typeof match === \"object\" ? createMatcher(match) : createBasicMatcher(match);\n this.store.insert({\n key: match,\n value,\n matcher\n });\n }\n /** Fetch the best match in the registry */\n get(query) {\n for (const entry of this.store.array) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n }\n /** Loop over all entries and run callback */\n forEach(callbackfn) {\n for (const entry of this.store.array) {\n callbackfn(entry);\n }\n }\n /** Reset the items in the registry */\n clear() {\n this.store = createSortedArray();\n }\n /** Check if the registry is empty*/\n isRegistryEmpty() {\n return this.store.array.length === 0;\n }\n };\n return __toCommonJS(src_exports);\n})();\n","export default function dlv(obj, key, def, p, undef) {\n\tkey = key.split ? key.split('.') : key;\n\tfor (p = 0; p < key.length; p++) {\n\t\tobj = obj ? obj[key[p]] : undef;\n\t}\n\treturn obj === undef ? def : obj;\n}\n","import dlv from \"dlv\";\n\n/** A function that checks overlapping properties against a reference value */\nexport type Matcher = ((searchObj: object) => boolean) & {\n /** The count represents the specificity of this matcher */\n count: number;\n};\n\n/** Traverse an object and collect any key/value pairs including nested keys */\nfunction traverseObj(\n object: Record<any, any>,\n path: string[] = [],\n pairs: Map<string[], any> = new Map(),\n): Map<string[], any> {\n for (const key of Object.keys(object)) {\n const val: any = object[key];\n const nestedPath = [...path, key];\n\n if (typeof val === \"object\") {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n\n return pairs;\n}\n\n/** Given an object, create a function that compares any set key/value pairs in the given object against a new value */\nexport default function createMatcher(partialObj: object): Matcher {\n // Convert the partial object into a list of [key, value] pairs;\n const pairs = traverseObj(partialObj);\n\n /** Generate a function to match against all of the properties we care about */\n const matchFunction = (searchObj: object) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n\n if (dlv(searchObj, path) !== value) {\n return false;\n }\n }\n\n return true;\n };\n\n // Keep track of the specificity of the comparator\n matchFunction.count = pairs.size;\n\n return matchFunction;\n}\n","import SortedArray from \"sorted-array\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport createObjectMatcher from \"./deep-partial-matcher\";\n\nexport { default as createObjectMatcher } from \"./deep-partial-matcher\";\n\n/** create a matcher function that matches exactly */\nfunction createBasicMatcher(seed: any): Matcher {\n /** a simple matcher function that only matches itself */\n const matcher = (match: any) => seed === match;\n matcher.count = 1;\n\n return matcher;\n}\n\ninterface RegistryIndex<V> {\n /** The original object we wanted to match on */\n key: object;\n\n /** The value to return */\n value: V;\n\n /** The matcher function for this entry */\n matcher: Matcher;\n}\n\n/** create an empty sorted array using the matcher count */\nconst createSortedArray = <V>() =>\n new SortedArray<RegistryIndex<V>>([], (c) => c.matcher.count);\n\n/**\n * A partial match registry is a map that uses an object to \"match\" against keys.\n * More specific matches take precedence over less specific ones.\n */\nexport class Registry<V> {\n private store = createSortedArray<V>();\n\n constructor(initialSet?: Array<[any, V]>) {\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n\n /** Add match -> value mapping to the registry */\n set(match: any, value: V) {\n const matcher =\n typeof match === \"object\"\n ? createObjectMatcher(match)\n : createBasicMatcher(match);\n\n this.store.insert({\n key: match,\n value,\n matcher,\n });\n }\n\n /** Fetch the best match in the registry */\n get(query: any): V | undefined {\n for (const entry of this.store.array) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n }\n\n /** Loop over all entries and run callback */\n forEach(callbackfn: (value: RegistryIndex<V>) => void): void {\n for (const entry of this.store.array) {\n callbackfn(entry);\n }\n }\n\n /** Reset the items in the registry */\n clear() {\n this.store = createSortedArray<V>();\n }\n\n /** Check if the registry is empty*/\n isRegistryEmpty() {\n return this.store.array.length === 0;\n }\n}\n","var SortedArray = (function () {\n var SortedArray = defclass({\n\n constructor: function (array, compare) {\n this.array = [];\n this.compare = compare || compareDefault;\n var length = array.length,\n index = 0;\n while (index < length) this.insert(array[index++]);\n },\n insert: function (element) {\n var array = this.array,\n compare = this.compare,\n high = array.length-1,\n low = 0,\n pos = -1,\n index,\n ordering;\n\n // The array is sorted. You must find the position of new element in O(log(n)), not O(n).\n while (high >= low) {\n index = (high + low) / 2 >>> 0;\n ordering = compare(array[index], element); \n if (ordering < 0) low = index + 1;\n else if (ordering > 0) high = index - 1;\n else {\n pos = index;\n break;\n };\n }\n\n if (pos === -1) {\n // if element was not found, high < low.\n pos = high;\n }\n // This assures that equal elements inserted after will be in a higher position in array.\n // They can be equal for comparison purposes, but different objects with different data.\n // Respecting the chronological order can be important for many applications.\n pos++;\n high = array.length-1;\n while ((pos < high) && (compare(element, array[pos]) === 0)){\n pos++;\n }\n index = array.length;\n // Just to increase array size.\n array.push(element); \n // Much faster. No need to elements swap.\n while (index > pos) {\n array[index] = array[--index];\n }\n // Set the new element on its correct position.\n array[pos] = element;\n\n return this;\n },\n search: function (element) {\n var array = this.array,\n compare = this.compare,\n high = array.length-1,\n low = 0,\n // In most languages, inner variable declaration makes the code slower.\n index,\n ordering;\n\n while (high >= low) {\n index = (high + low) / 2 >>> 0;\n ordering = compare(array[index], element);\n\n if (ordering < 0) low = index + 1;\n else if (ordering > 0) high = index - 1;\n else return index;\n }\n\n return -1;\n },\n remove: function (element) {\n var index = this.search(element);\n if (index >= 0) this.array.splice(index, 1);\n return this;\n }\n });\n\n SortedArray.comparing = function (property, array) {\n return new SortedArray(array, function (a, b) {\n // This should be faster than calling functions.\n // Besides, this way it is not needed to create useless function to return property value.\n return compareDefault(a[property], b[property]);\n });\n };\n\n return SortedArray;\n\n function defclass(prototype) {\n var constructor = prototype.constructor;\n constructor.prototype = prototype;\n return constructor;\n }\n\n function compareDefault(a, b) {\n // Equality has a very low chance to happen. It should be the last option.\n if (a < b)\n return -1;\n else if (a > b)\n return 1;\n else\n return 0;\n }\n}());\n\nif (typeof module === \"object\") module.exports = SortedArray;\nif (typeof define === \"function\" && define.amd)\n define(function () { return SortedArray; });\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2494/execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/dist/index.global.js","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/dlv@1.1.3/node_modules/dlv/index.js","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/sorted-array@2.0.4/node_modules/sorted-array/sorted-array.js"],"names":["Registry","dlv_es_default","obj","key","def","p","undef","split","length","createObjectMatcher","partialObj","pairs","traverseObj","matchFunction","searchObj","Array","from","entry","path","value","count","size","createBasicMatcher","seed","matcher","match","__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__commonJS","cb","mod","__require","exports","__export","target","all","name","get","enumerable","__copyProps","to","except","desc","call","__toESM","isNodeMode","__esModule","__toCommonJS","require_sorted_array","module","SortedArray","defclass","array","compare","compareDefault","index","insert","element","high","low","pos","ordering","push","search","remove","splice","comparing","property","a","b","constructor","define","amd","src_exports","import_sorted_array","object","Map","keys","val","nestedPath","set","createSortedArray","c","initialSet","store","forEach","query","callbackfn","clear","isRegistryEmpty"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,WAAW,AAAC;QCDDC,iBDuIb,kJAAkJ;ICvIrI,SAAAA,eAAaC,CAAAA,EAAKC,CAAAA,EAAKC,CAAAA,EAAKC,CAAAA,EAAGC,CAAAA;QAAAA,IAC7CH,IAAMA,EAAII,KAAAA,GAAQJ,EAAII,KAAAA,CAAM,OAAOJ,GAC9BE,IAAI,GAAGA,IAAIF,EAAIK,MAAAA,EAAQH,IAC3BH,IAAMA,IAAMA,CAAAA,CAAIC,CAAAA,CAAIE,EAAAA,CAAAA,GAAMC;QAAAA,OAEpBJ,MAAQI,IAAQF,IAAMF;IAAAA;QC4BdO,sBAAT,SAASA,oBAAoBC,UAAA;QAElC,IAAMC,QAAQC,YAAYF;QAG1B,IAAMG,gBAAgB,SAACC;gBACrB,kCAAA,2BAAA;;gBAAA,QAAA,YAAoBC,MAAMC,IAAA,CAAKL,2BAA/B,SAAA,6BAAA,QAAA,yBAAA,iCAAuC;oBAAvC,IAAWM,QAAX;oBACE,IAAsBA,0BAAAA,WAAfC,OAAeD,WAATE,QAASF;oBAEtB,IAAIhB,eAAIa,WAAWI,UAAUC,OAAO;wBAClC,OAAO;oBACT;gBACF;;gBANA;gBAAA;;;yBAAA,6BAAA;wBAAA;;;w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A,QAAA,yBAAA,iCAAsC;4BAAtC,IAAW/C,QAAX;4BACEkF,WAAWlF;wBACb;;wBAFA;wBAAA;;;iCAAA,6BAAA;gCAAA;;;gCAAA;sCAAA;;;;gBAGF;;;gBAAA,oCAAA,GAGAmF,KAAAA;uBAAAA,SAAAA;oBACE,IAAA,CAAKJ,KAAA,GAAQH;gBACf;;;gBAAA,kCAAA,GAGAQ,KAAAA;uBAAAA,SAAAA;oBACE,OAAO,IAAA,CAAKL,KAAA,CAAMhC,KAAA,CAAMxD,MAAA,KAAW;gBACrC;;;;;IHuIA,OAAOmD,aAAa0B;AACtB","sourcesContent":["\"use strict\";\nvar Registry = (() => {\n var __create = Object.create;\n var __defProp = Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __getProtoOf = Object.getPrototypeOf;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __commonJS = (cb, mod) => function __require() {\n return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;\n };\n var __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n };\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n };\n var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n ));\n var __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/sorted-array@2.0.4/node_modules/sorted-array/sorted-array.js\n var require_sorted_array = __commonJS({\n \"../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/sorted-array@2.0.4/node_modules/sorted-array/sorted-array.js\"(exports, module) {\n \"use strict\";\n var SortedArray2 = function() {\n var SortedArray3 = defclass({\n constructor: function(array, compare) {\n this.array = [];\n this.compare = compare || compareDefault;\n var length = array.length, index = 0;\n while (index < length)\n this.insert(array[index++]);\n },\n insert: function(element) {\n var array = this.array, compare = this.compare, high = array.length - 1, low = 0, pos = -1, index, ordering;\n while (high >= low) {\n index = (high + low) / 2 >>> 0;\n ordering = compare(array[index], element);\n if (ordering < 0)\n low = index + 1;\n else if (ordering > 0)\n high = index - 1;\n else {\n pos = index;\n break;\n }\n ;\n }\n if (pos === -1) {\n pos = high;\n }\n pos++;\n high = array.length - 1;\n while (pos < high && compare(element, array[pos]) === 0) {\n pos++;\n }\n index = array.length;\n array.push(element);\n while (index > pos) {\n array[index] = array[--index];\n }\n array[pos] = element;\n return this;\n },\n search: function(element) {\n var array = this.array, compare = this.compare, high = array.length - 1, low = 0, index, ordering;\n while (high >= low) {\n index = (high + low) / 2 >>> 0;\n ordering = compare(array[index], element);\n if (ordering < 0)\n low = index + 1;\n else if (ordering > 0)\n high = index - 1;\n else\n return index;\n }\n return -1;\n },\n remove: function(element) {\n var index = this.search(element);\n if (index >= 0)\n this.array.splice(index, 1);\n return this;\n }\n });\n SortedArray3.comparing = function(property, array) {\n return new SortedArray3(array, function(a, b) {\n return compareDefault(a[property], b[property]);\n });\n };\n return SortedArray3;\n function defclass(prototype) {\n var constructor = prototype.constructor;\n constructor.prototype = prototype;\n return constructor;\n }\n function compareDefault(a, b) {\n if (a < b)\n return -1;\n else if (a > b)\n return 1;\n else\n return 0;\n }\n }();\n if (typeof module === \"object\")\n module.exports = SortedArray2;\n if (typeof define === \"function\" && define.amd)\n define(function() {\n return SortedArray2;\n });\n }\n });\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts\n var src_exports = {};\n __export(src_exports, {\n Registry: () => Registry,\n createObjectMatcher: () => createObjectMatcher\n });\n var import_sorted_array = __toESM(require_sorted_array());\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/dlv@1.1.3/node_modules/dlv/dist/dlv.es.js\n function dlv_es_default(t, e, l, n, r) {\n for (e = e.split ? e.split(\".\") : e, n = 0; n < e.length; n++)\n t = t ? t[e[n]] : r;\n return t === r ? l : t;\n }\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts\n function traverseObj(object, path = [], pairs = /* @__PURE__ */ new Map()) {\n for (const key of Object.keys(object)) {\n const val = object[key];\n const nestedPath = [...path, key];\n if (typeof val === \"object\") {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n return pairs;\n }\n function createObjectMatcher(partialObj) {\n const pairs = traverseObj(partialObj);\n const matchFunction = (searchObj) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n if (dlv_es_default(searchObj, path) !== value) {\n return false;\n }\n }\n return true;\n };\n matchFunction.count = pairs.size;\n return matchFunction;\n }\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts\n function createBasicMatcher(seed) {\n const matcher = (match) => seed === match;\n matcher.count = 1;\n return matcher;\n }\n var createSortedArray = () => new import_sorted_array.default([], (c) => c.matcher.count);\n var Registry = class {\n constructor(initialSet) {\n this.store = createSortedArray();\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n /** Add match -> value mapping to the registry */\n set(match, value) {\n const matcher = typeof match === \"object\" ? createObjectMatcher(match) : createBasicMatcher(match);\n this.store.insert({\n key: match,\n value,\n matcher\n });\n }\n /** Fetch the best match in the registry */\n get(query) {\n for (const entry of this.store.array) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n }\n /** Loop over all entries and run callback */\n forEach(callbackfn) {\n for (const entry of this.store.array) {\n callbackfn(entry);\n }\n }\n /** Reset the items in the registry */\n clear() {\n this.store = createSortedArray();\n }\n /** Check if the registry is empty*/\n isRegistryEmpty() {\n return this.store.array.length === 0;\n }\n };\n return __toCommonJS(src_exports);\n})();\n","export default function dlv(obj, key, def, p, undef) {\n\tkey = key.split ? key.split('.') : key;\n\tfor (p = 0; p < key.length; p++) {\n\t\tobj = obj ? obj[key[p]] : undef;\n\t}\n\treturn obj === undef ? def : obj;\n}\n","import dlv from \"dlv\";\n\n/** A function that checks overlapping properties against a reference value */\nexport type Matcher = ((searchObj: object) => boolean) & {\n /** The count represents the specificity of this matcher */\n count: number;\n};\n\n/** Traverse an object and collect any key/value pairs including nested keys */\nfunction traverseObj(\n object: Record<any, any>,\n path: string[] = [],\n pairs: Map<string[], any> = new Map(),\n): Map<string[], any> {\n for (const key of Object.keys(object)) {\n const val: any = object[key];\n const nestedPath = [...path, key];\n\n if (typeof val === \"object\") {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n\n return pairs;\n}\n\n/**\n * Given a partial object, create a matcher function that checks if another object matches the specified properties\n * @param partialObj The partial object to match against\n * @returns A matcher function that checks if an object matches the partial object\n */\nexport function createObjectMatcher(partialObj: object): Matcher {\n // Convert the partial object into a list of [key, value] pairs;\n const pairs = traverseObj(partialObj);\n\n /** Generate a function to match against all of the properties we care about */\n const matchFunction = (searchObj: object) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n\n if (dlv(searchObj, path) !== value) {\n return false;\n }\n }\n\n return true;\n };\n\n // Keep track of the specificity of the comparator\n matchFunction.count = pairs.size;\n\n return matchFunction;\n}\n","import SortedArray from \"sorted-array\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport { createObjectMatcher } from \"./deep-partial-matcher\";\n\nexport { createObjectMatcher } from \"./deep-partial-matcher\";\n\n/** create a matcher function that matches exactly */\nfunction createBasicMatcher(seed: any): Matcher {\n /** a simple matcher function that only matches itself */\n const matcher = (match: any) => seed === match;\n matcher.count = 1;\n\n return matcher;\n}\n\ninterface RegistryIndex<V> {\n /** The original object we wanted to match on */\n key: object;\n\n /** The value to return */\n value: V;\n\n /** The matcher function for this entry */\n matcher: Matcher;\n}\n\n/** create an empty sorted array using the matcher count */\nconst createSortedArray = <V>() =>\n new SortedArray<RegistryIndex<V>>([], (c) => c.matcher.count);\n\n/**\n * A partial match registry is a map that uses an object to \"match\" against keys.\n * More specific matches take precedence over less specific ones.\n */\nexport class Registry<V> {\n private store = createSortedArray<V>();\n\n constructor(initialSet?: Array<[any, V]>) {\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n\n /** Add match -> value mapping to the registry */\n set(match: any, value: V) {\n const matcher =\n typeof match === \"object\"\n ? createObjectMatcher(match)\n : createBasicMatcher(match);\n\n this.store.insert({\n key: match,\n value,\n matcher,\n });\n }\n\n /** Fetch the best match in the registry */\n get(query: any): V | undefined {\n for (const entry of this.store.array) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n }\n\n /** Loop over all entries and run callback */\n forEach(callbackfn: (value: RegistryIndex<V>) => void): void {\n for (const entry of this.store.array) {\n callbackfn(entry);\n }\n }\n\n /** Reset the items in the registry */\n clear() {\n this.store = createSortedArray<V>();\n }\n\n /** Check if the registry is empty*/\n isRegistryEmpty() {\n return this.store.array.length === 0;\n }\n}\n","var SortedArray = (function () {\n var SortedArray = defclass({\n\n constructor: function (array, compare) {\n this.array = [];\n this.compare = compare || compareDefault;\n var length = array.length,\n index = 0;\n while (index < length) this.insert(array[index++]);\n },\n insert: function (element) {\n var array = this.array,\n compare = this.compare,\n high = array.length-1,\n low = 0,\n pos = -1,\n index,\n ordering;\n\n // The array is sorted. You must find the position of new element in O(log(n)), not O(n).\n while (high >= low) {\n index = (high + low) / 2 >>> 0;\n ordering = compare(array[index], element); \n if (ordering < 0) low = index + 1;\n else if (ordering > 0) high = index - 1;\n else {\n pos = index;\n break;\n };\n }\n\n if (pos === -1) {\n // if element was not found, high < low.\n pos = high;\n }\n // This assures that equal elements inserted after will be in a higher position in array.\n // They can be equal for comparison purposes, but different objects with different data.\n // Respecting the chronological order can be important for many applications.\n pos++;\n high = array.length-1;\n while ((pos < high) && (compare(element, array[pos]) === 0)){\n pos++;\n }\n index = array.length;\n // Just to increase array size.\n array.push(element); \n // Much faster. No need to elements swap.\n while (index > pos) {\n array[index] = array[--index];\n }\n // Set the new element on its correct position.\n array[pos] = element;\n\n return this;\n },\n search: function (element) {\n var array = this.array,\n compare = this.compare,\n high = array.length-1,\n low = 0,\n // In most languages, inner variable declaration makes the code slower.\n index,\n ordering;\n\n while (high >= low) {\n index = (high + low) / 2 >>> 0;\n ordering = compare(array[index], element);\n\n if (ordering < 0) low = index + 1;\n else if (ordering > 0) high = index - 1;\n else return index;\n }\n\n return -1;\n },\n remove: function (element) {\n var index = this.search(element);\n if (index >= 0) this.array.splice(index, 1);\n return this;\n }\n });\n\n SortedArray.comparing = function (property, array) {\n return new SortedArray(array, function (a, b) {\n // This should be faster than calling functions.\n // Besides, this way it is not needed to create useless function to return property value.\n return compareDefault(a[property], b[property]);\n });\n };\n\n return SortedArray;\n\n function defclass(prototype) {\n var constructor = prototype.constructor;\n constructor.prototype = prototype;\n return constructor;\n }\n\n function compareDefault(a, b) {\n // Equality has a very low chance to happen. It should be the last option.\n if (a < b)\n return -1;\n else if (a > b)\n return 1;\n else\n return 0;\n }\n}());\n\nif (typeof module === \"object\") module.exports = SortedArray;\nif (typeof define === \"function\" && define.amd)\n define(function () { return SortedArray; });\n"]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
Registry: () => Registry,
|
|
34
|
-
createObjectMatcher: () =>
|
|
34
|
+
createObjectMatcher: () => createObjectMatcher
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(src_exports);
|
|
37
37
|
var import_sorted_array = __toESM(require("sorted-array"));
|
|
@@ -50,7 +50,7 @@ function traverseObj(object, path = [], pairs = /* @__PURE__ */ new Map()) {
|
|
|
50
50
|
}
|
|
51
51
|
return pairs;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function createObjectMatcher(partialObj) {
|
|
54
54
|
const pairs = traverseObj(partialObj);
|
|
55
55
|
const matchFunction = (searchObj) => {
|
|
56
56
|
for (const entry of Array.from(pairs)) {
|
|
@@ -81,7 +81,7 @@ var Registry = class {
|
|
|
81
81
|
}
|
|
82
82
|
/** Add match -> value mapping to the registry */
|
|
83
83
|
set(match, value) {
|
|
84
|
-
const matcher = typeof match === "object" ?
|
|
84
|
+
const matcher = typeof match === "object" ? createObjectMatcher(match) : createBasicMatcher(match);
|
|
85
85
|
this.store.insert({
|
|
86
86
|
key: match,
|
|
87
87
|
value,
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts"],"sourcesContent":["import SortedArray from \"sorted-array\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport createObjectMatcher from \"./deep-partial-matcher\";\n\nexport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts"],"sourcesContent":["import SortedArray from \"sorted-array\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport { createObjectMatcher } from \"./deep-partial-matcher\";\n\nexport { createObjectMatcher } from \"./deep-partial-matcher\";\n\n/** create a matcher function that matches exactly */\nfunction createBasicMatcher(seed: any): Matcher {\n /** a simple matcher function that only matches itself */\n const matcher = (match: any) => seed === match;\n matcher.count = 1;\n\n return matcher;\n}\n\ninterface RegistryIndex<V> {\n /** The original object we wanted to match on */\n key: object;\n\n /** The value to return */\n value: V;\n\n /** The matcher function for this entry */\n matcher: Matcher;\n}\n\n/** create an empty sorted array using the matcher count */\nconst createSortedArray = <V>() =>\n new SortedArray<RegistryIndex<V>>([], (c) => c.matcher.count);\n\n/**\n * A partial match registry is a map that uses an object to \"match\" against keys.\n * More specific matches take precedence over less specific ones.\n */\nexport class Registry<V> {\n private store = createSortedArray<V>();\n\n constructor(initialSet?: Array<[any, V]>) {\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n\n /** Add match -> value mapping to the registry */\n set(match: any, value: V) {\n const matcher =\n typeof match === \"object\"\n ? createObjectMatcher(match)\n : createBasicMatcher(match);\n\n this.store.insert({\n key: match,\n value,\n matcher,\n });\n }\n\n /** Fetch the best match in the registry */\n get(query: any): V | undefined {\n for (const entry of this.store.array) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n }\n\n /** Loop over all entries and run callback */\n forEach(callbackfn: (value: RegistryIndex<V>) => void): void {\n for (const entry of this.store.array) {\n callbackfn(entry);\n }\n }\n\n /** Reset the items in the registry */\n clear() {\n this.store = createSortedArray<V>();\n }\n\n /** Check if the registry is empty*/\n isRegistryEmpty() {\n return this.store.array.length === 0;\n }\n}\n","import dlv from \"dlv\";\n\n/** A function that checks overlapping properties against a reference value */\nexport type Matcher = ((searchObj: object) => boolean) & {\n /** The count represents the specificity of this matcher */\n count: number;\n};\n\n/** Traverse an object and collect any key/value pairs including nested keys */\nfunction traverseObj(\n object: Record<any, any>,\n path: string[] = [],\n pairs: Map<string[], any> = new Map(),\n): Map<string[], any> {\n for (const key of Object.keys(object)) {\n const val: any = object[key];\n const nestedPath = [...path, key];\n\n if (typeof val === \"object\") {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n\n return pairs;\n}\n\n/**\n * Given a partial object, create a matcher function that checks if another object matches the specified properties\n * @param partialObj The partial object to match against\n * @returns A matcher function that checks if an object matches the partial object\n */\nexport function createObjectMatcher(partialObj: object): Matcher {\n // Convert the partial object into a list of [key, value] pairs;\n const pairs = traverseObj(partialObj);\n\n /** Generate a function to match against all of the properties we care about */\n const matchFunction = (searchObj: object) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n\n if (dlv(searchObj, path) !== value) {\n return false;\n }\n }\n\n return true;\n };\n\n // Keep track of the specificity of the comparator\n matchFunction.count = pairs.size;\n\n return matchFunction;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAwB;;;ACAxB,iBAAgB;AAShB,SAAS,YACP,QACA,OAAiB,CAAC,GAClB,QAA4B,oBAAI,IAAI,GAChB;AACpB,aAAW,OAAO,OAAO,KAAK,MAAM,GAAG;AACrC,UAAM,MAAW,OAAO,GAAG;AAC3B,UAAM,aAAa,CAAC,GAAG,MAAM,GAAG;AAEhC,QAAI,OAAO,QAAQ,UAAU;AAC3B,kBAAY,KAAK,YAAY,KAAK;AAAA,IACpC,OAAO;AACL,YAAM,IAAI,YAAY,GAAG;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO;AACT;AAOO,SAAS,oBAAoB,YAA6B;AAE/D,QAAM,QAAQ,YAAY,UAAU;AAGpC,QAAM,gBAAgB,CAAC,cAAsB;AAC3C,eAAW,SAAS,MAAM,KAAK,KAAK,GAAG;AACrC,YAAM,CAAC,MAAM,KAAK,IAAI;AAEtB,cAAI,WAAAA,SAAI,WAAW,IAAI,MAAM,OAAO;AAClC,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAGA,gBAAc,QAAQ,MAAM;AAE5B,SAAO;AACT;;;AD/CA,SAAS,mBAAmB,MAAoB;AAE9C,QAAM,UAAU,CAAC,UAAe,SAAS;AACzC,UAAQ,QAAQ;AAEhB,SAAO;AACT;AAcA,IAAM,oBAAoB,MACxB,IAAI,oBAAAC,QAA8B,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,KAAK;AAMvD,IAAM,WAAN,MAAkB;AAAA,EAGvB,YAAY,YAA8B;AAF1C,SAAQ,QAAQ,kBAAqB;AAGnC,gBAAY,QAAQ,CAAC,CAAC,OAAO,KAAK,MAAM;AACtC,WAAK,IAAI,OAAO,KAAK;AAAA,IACvB,CAAC;AAAA,EACH;AAAA;AAAA,EAGA,IAAI,OAAY,OAAU;AACxB,UAAM,UACJ,OAAO,UAAU,WACb,oBAAoB,KAAK,IACzB,mBAAmB,KAAK;AAE9B,SAAK,MAAM,OAAO;AAAA,MAChB,KAAK;AAAA,MACL;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA,EAGA,IAAI,OAA2B;AAC7B,eAAW,SAAS,KAAK,MAAM,OAAO;AACpC,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAO,MAAM;AAAA,MACf;AAAA,IACF;AAAA,EACF;AAAA;AAAA,EAGA,QAAQ,YAAqD;AAC3D,eAAW,SAAS,KAAK,MAAM,OAAO;AACpC,iBAAW,KAAK;AAAA,IAClB;AAAA,EACF;AAAA;AAAA,EAGA,QAAQ;AACN,SAAK,QAAQ,kBAAqB;AAAA,EACpC;AAAA;AAAA,EAGA,kBAAkB;AAChB,WAAO,KAAK,MAAM,MAAM,WAAW;AAAA,EACrC;AACF;","names":["dlv","SortedArray"]}
|
package/dist/index.legacy-esm.js
CHANGED
|
@@ -15,7 +15,7 @@ function traverseObj(object, path = [], pairs = /* @__PURE__ */ new Map()) {
|
|
|
15
15
|
}
|
|
16
16
|
return pairs;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function createObjectMatcher(partialObj) {
|
|
19
19
|
const pairs = traverseObj(partialObj);
|
|
20
20
|
const matchFunction = (searchObj) => {
|
|
21
21
|
for (const entry of Array.from(pairs)) {
|
|
@@ -46,7 +46,7 @@ var Registry = class {
|
|
|
46
46
|
}
|
|
47
47
|
/** Add match -> value mapping to the registry */
|
|
48
48
|
set(match, value) {
|
|
49
|
-
const matcher = typeof match === "object" ?
|
|
49
|
+
const matcher = typeof match === "object" ? createObjectMatcher(match) : createBasicMatcher(match);
|
|
50
50
|
this.store.insert({
|
|
51
51
|
key: match,
|
|
52
52
|
value,
|
|
@@ -78,6 +78,6 @@ var Registry = class {
|
|
|
78
78
|
};
|
|
79
79
|
export {
|
|
80
80
|
Registry,
|
|
81
|
-
|
|
81
|
+
createObjectMatcher
|
|
82
82
|
};
|
|
83
83
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ function traverseObj(object, path = [], pairs = /* @__PURE__ */ new Map()) {
|
|
|
15
15
|
}
|
|
16
16
|
return pairs;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function createObjectMatcher(partialObj) {
|
|
19
19
|
const pairs = traverseObj(partialObj);
|
|
20
20
|
const matchFunction = (searchObj) => {
|
|
21
21
|
for (const entry of Array.from(pairs)) {
|
|
@@ -46,7 +46,7 @@ var Registry = class {
|
|
|
46
46
|
}
|
|
47
47
|
/** Add match -> value mapping to the registry */
|
|
48
48
|
set(match, value) {
|
|
49
|
-
const matcher = typeof match === "object" ?
|
|
49
|
+
const matcher = typeof match === "object" ? createObjectMatcher(match) : createBasicMatcher(match);
|
|
50
50
|
this.store.insert({
|
|
51
51
|
key: match,
|
|
52
52
|
value,
|
|
@@ -78,6 +78,6 @@ var Registry = class {
|
|
|
78
78
|
};
|
|
79
79
|
export {
|
|
80
80
|
Registry,
|
|
81
|
-
|
|
81
|
+
createObjectMatcher
|
|
82
82
|
};
|
|
83
83
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts"],"sourcesContent":["import SortedArray from \"sorted-array\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport createObjectMatcher from \"./deep-partial-matcher\";\n\nexport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts"],"sourcesContent":["import SortedArray from \"sorted-array\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport { createObjectMatcher } from \"./deep-partial-matcher\";\n\nexport { createObjectMatcher } from \"./deep-partial-matcher\";\n\n/** create a matcher function that matches exactly */\nfunction createBasicMatcher(seed: any): Matcher {\n /** a simple matcher function that only matches itself */\n const matcher = (match: any) => seed === match;\n matcher.count = 1;\n\n return matcher;\n}\n\ninterface RegistryIndex<V> {\n /** The original object we wanted to match on */\n key: object;\n\n /** The value to return */\n value: V;\n\n /** The matcher function for this entry */\n matcher: Matcher;\n}\n\n/** create an empty sorted array using the matcher count */\nconst createSortedArray = <V>() =>\n new SortedArray<RegistryIndex<V>>([], (c) => c.matcher.count);\n\n/**\n * A partial match registry is a map that uses an object to \"match\" against keys.\n * More specific matches take precedence over less specific ones.\n */\nexport class Registry<V> {\n private store = createSortedArray<V>();\n\n constructor(initialSet?: Array<[any, V]>) {\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n\n /** Add match -> value mapping to the registry */\n set(match: any, value: V) {\n const matcher =\n typeof match === \"object\"\n ? createObjectMatcher(match)\n : createBasicMatcher(match);\n\n this.store.insert({\n key: match,\n value,\n matcher,\n });\n }\n\n /** Fetch the best match in the registry */\n get(query: any): V | undefined {\n for (const entry of this.store.array) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n }\n\n /** Loop over all entries and run callback */\n forEach(callbackfn: (value: RegistryIndex<V>) => void): void {\n for (const entry of this.store.array) {\n callbackfn(entry);\n }\n }\n\n /** Reset the items in the registry */\n clear() {\n this.store = createSortedArray<V>();\n }\n\n /** Check if the registry is empty*/\n isRegistryEmpty() {\n return this.store.array.length === 0;\n }\n}\n","import dlv from \"dlv\";\n\n/** A function that checks overlapping properties against a reference value */\nexport type Matcher = ((searchObj: object) => boolean) & {\n /** The count represents the specificity of this matcher */\n count: number;\n};\n\n/** Traverse an object and collect any key/value pairs including nested keys */\nfunction traverseObj(\n object: Record<any, any>,\n path: string[] = [],\n pairs: Map<string[], any> = new Map(),\n): Map<string[], any> {\n for (const key of Object.keys(object)) {\n const val: any = object[key];\n const nestedPath = [...path, key];\n\n if (typeof val === \"object\") {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n\n return pairs;\n}\n\n/**\n * Given a partial object, create a matcher function that checks if another object matches the specified properties\n * @param partialObj The partial object to match against\n * @returns A matcher function that checks if an object matches the partial object\n */\nexport function createObjectMatcher(partialObj: object): Matcher {\n // Convert the partial object into a list of [key, value] pairs;\n const pairs = traverseObj(partialObj);\n\n /** Generate a function to match against all of the properties we care about */\n const matchFunction = (searchObj: object) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n\n if (dlv(searchObj, path) !== value) {\n return false;\n }\n }\n\n return true;\n };\n\n // Keep track of the specificity of the comparator\n matchFunction.count = pairs.size;\n\n return matchFunction;\n}\n"],"mappings":";AAAA,OAAO,iBAAiB;;;ACAxB,OAAO,SAAS;AAShB,SAAS,YACP,QACA,OAAiB,CAAC,GAClB,QAA4B,oBAAI,IAAI,GAChB;AACpB,aAAW,OAAO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,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAO,MAAM;AAAA,MACf;AAAA,IACF;AAAA,EACF;AAAA;AAAA,EAGA,QAAQ,YAAqD;AAC3D,eAAW,SAAS,KAAK,MAAM,OAAO;AACpC,iBAAW,KAAK;AAAA,IAClB;AAAA,EACF;AAAA;AAAA,EAGA,QAAQ;AACN,SAAK,QAAQ,kBAAqB;AAAA,EACpC;AAAA;AAAA,EAGA,kBAAkB;AAChB,WAAO,KAAK,MAAM,MAAM,WAAW;AAAA,EACrC;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { test, expect } from "vitest";
|
|
2
|
-
import
|
|
2
|
+
import { createObjectMatcher } from "../deep-partial-matcher";
|
|
3
3
|
|
|
4
4
|
test("works on basic objects", () => {
|
|
5
|
-
const matcher =
|
|
5
|
+
const matcher = createObjectMatcher({ foo: "bar" });
|
|
6
6
|
expect(matcher({})).toBe(false);
|
|
7
7
|
expect(matcher({ foo: "bar" })).toBe(true);
|
|
8
8
|
expect(matcher({ foo: "bar", bar: "baz" })).toBe(true);
|
|
@@ -26,8 +26,12 @@ function traverseObj(
|
|
|
26
26
|
return pairs;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Given a partial object, create a matcher function that checks if another object matches the specified properties
|
|
31
|
+
* @param partialObj The partial object to match against
|
|
32
|
+
* @returns A matcher function that checks if an object matches the partial object
|
|
33
|
+
*/
|
|
34
|
+
export function createObjectMatcher(partialObj: object): Matcher {
|
|
31
35
|
// Convert the partial object into a list of [key, value] pairs;
|
|
32
36
|
const pairs = traverseObj(partialObj);
|
|
33
37
|
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import SortedArray from "sorted-array";
|
|
2
2
|
import type { Matcher } from "./deep-partial-matcher";
|
|
3
|
-
import createObjectMatcher from "./deep-partial-matcher";
|
|
3
|
+
import { createObjectMatcher } from "./deep-partial-matcher";
|
|
4
4
|
|
|
5
|
-
export {
|
|
5
|
+
export { createObjectMatcher } from "./deep-partial-matcher";
|
|
6
6
|
|
|
7
7
|
/** create a matcher function that matches exactly */
|
|
8
8
|
function createBasicMatcher(seed: any): Matcher {
|
|
@@ -3,6 +3,10 @@ export type Matcher = ((searchObj: object) => boolean) & {
|
|
|
3
3
|
/** The count represents the specificity of this matcher */
|
|
4
4
|
count: number;
|
|
5
5
|
};
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Given a partial object, create a matcher function that checks if another object matches the specified properties
|
|
8
|
+
* @param partialObj The partial object to match against
|
|
9
|
+
* @returns A matcher function that checks if an object matches the partial object
|
|
10
|
+
*/
|
|
11
|
+
export declare function createObjectMatcher(partialObj: object): Matcher;
|
|
8
12
|
//# sourceMappingURL=deep-partial-matcher.d.ts.map
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Matcher } from "./deep-partial-matcher";
|
|
2
|
-
export {
|
|
2
|
+
export { createObjectMatcher } from "./deep-partial-matcher";
|
|
3
3
|
interface RegistryIndex<V> {
|
|
4
4
|
/** The original object we wanted to match on */
|
|
5
5
|
key: object;
|