Files
klz-cables.com/.pnpm-store/v10/files/72/6d04313c65a5a922bccfdc55137a252c5c3bdd7a3e12453b458950e5db84ee5230b24cbe2febfbf3693959dca275ee67a2eab779e8056af268ee41834e8917
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

54 lines
1.2 KiB
Plaintext

/*
MIT License http://www.opensource.org/licenses/mit-license.php
*/
"use strict";
/** @typedef {import("./ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("./ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
/** @typedef {string[]} Keys */
class NullPrototypeObjectSerializer {
/**
* @template {object} T
* @param {T} obj null object
* @param {ObjectSerializerContext} context context
*/
serialize(obj, context) {
/** @type {Keys} */
const keys = Object.keys(obj);
for (const key of keys) {
context.write(key);
}
context.write(null);
for (const key of keys) {
context.write(obj[/** @type {keyof T} */ (key)]);
}
}
/**
* @template {object} T
* @param {ObjectDeserializerContext} context context
* @returns {T} null object
*/
deserialize(context) {
/** @type {T} */
const obj = Object.create(null);
/** @type {Keys} */
const keys = [];
/** @type {Keys[number] | null} */
let key = context.read();
while (key !== null) {
keys.push(key);
key = context.read();
}
for (const key of keys) {
obj[/** @type {keyof T} */ (key)] = context.read();
}
return obj;
}
}
module.exports = NullPrototypeObjectSerializer;