Files
klz-cables.com/.pnpm-store/v10/files/5c/4f4512a9418a51640a7f1ff36dd898328b2287db68eeef5b34c0308fce8b4bb0231d79b782f63bd408d2311a7a6191d206d17ec8ee520a1d59b63f9a339fc9
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

72 lines
1.5 KiB
Plaintext

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
/** @typedef {import("../Cache").Etag} Etag */
class MergedEtag {
/**
* @param {Etag} a first
* @param {Etag} b second
*/
constructor(a, b) {
this.a = a;
this.b = b;
}
toString() {
return `${this.a.toString()}|${this.b.toString()}`;
}
}
/** @type {WeakMap<Etag, WeakMap<Etag, MergedEtag>>} */
const dualObjectMap = new WeakMap();
/** @type {WeakMap<Etag, WeakMap<Etag, MergedEtag>>} */
const objectStringMap = new WeakMap();
/**
* @param {Etag} a first
* @param {Etag} b second
* @returns {string | MergedEtag} result
*/
const mergeEtags = (a, b) => {
if (typeof a === "string") {
if (typeof b === "string") {
return `${a}|${b}`;
}
const temp = b;
b = a;
a = temp;
} else if (typeof b !== "string") {
// both a and b are objects
let map = dualObjectMap.get(a);
if (map === undefined) {
dualObjectMap.set(a, (map = new WeakMap()));
}
const mergedEtag = map.get(b);
if (mergedEtag === undefined) {
const newMergedEtag = new MergedEtag(a, b);
map.set(b, newMergedEtag);
return newMergedEtag;
}
return mergedEtag;
}
// a is object, b is string
let map = objectStringMap.get(a);
if (map === undefined) {
objectStringMap.set(a, (map = new Map()));
}
const mergedEtag = map.get(b);
if (mergedEtag === undefined) {
const newMergedEtag = new MergedEtag(a, b);
map.set(b, newMergedEtag);
return newMergedEtag;
}
return mergedEtag;
};
module.exports = mergeEtags;