Files
klz-cables.com/.pnpm-store/v10/files/e3/61a2718e3112423d25749b6b47889e0d31d689674ab9c89b62f48b4c3020ecaa5d6cbe0861cb71d818be1ed09da876adab875136dc291e529d50d193950809
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

20 lines
954 B
Plaintext

/**
* Safely stringify a value and truncate it to a maximum length.
*
* Converts any value to a JSON string representation and truncates the resulting
* string if it exceeds the maximum length. If truncation occurs, an ellipsis (…)
* is appended to indicate incomplete output.
*
* @param value - The value to stringify (can be any type including objects, arrays, primitives)
* @param maxLength - The maximum character length of the output string
* @returns A JSON string representation, truncated with "…" if it exceeds maxLength
*/export function stringifyTruncated(value, maxLength) {
const stringifiedJSON = JSON.stringify(value);
const totalChars = stringifiedJSON.length;
// Only truncate if the string is significantly longer (>1.5x the max length)
if (totalChars / maxLength > 1.5) {
return `${stringifiedJSON.substring(0, maxLength)}\u2026`;
}
return stringifiedJSON;
}
//# sourceMappingURL=stringifyTruncated.js.map