Files
klz-cables.com/.pnpm-store/v10/files/31/3b224612edb66217032b703a235fc5384d0d750a34c6d42aaa9d60861b96029f09efbdae1816911ae37f8e90dc816eb51788eabfc9bfaca82deca49ea8ec1e
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

82 lines
2.5 KiB
Plaintext

import { memoize, strategies } from "@formatjs/fast-memoize";
export function repeat(s, times) {
if (typeof s.repeat === "function") {
return s.repeat(times);
}
const arr = Array.from({ length: times });
for (let i = 0; i < arr.length; i++) {
arr[i] = s;
}
return arr.join("");
}
export function setInternalSlot(map, pl, field, value) {
if (!map.get(pl)) {
map.set(pl, Object.create(null));
}
const slots = map.get(pl);
slots[field] = value;
}
export function setMultiInternalSlots(map, pl, props) {
for (const k of Object.keys(props)) {
setInternalSlot(map, pl, k, props[k]);
}
}
export function getInternalSlot(map, pl, field) {
return getMultiInternalSlots(map, pl, field)[field];
}
export function getMultiInternalSlots(map, pl, ...fields) {
const slots = map.get(pl);
if (!slots) {
throw new TypeError(`${pl} InternalSlot has not been initialized`);
}
return fields.reduce((all, f) => {
all[f] = slots[f];
return all;
}, Object.create(null));
}
export function isLiteralPart(patternPart) {
return patternPart.type === "literal";
}
/*
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value
is a String.
Unless otherwise specified, the name property of a built-in Function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
*/
export function defineProperty(target, name, { value }) {
Object.defineProperty(target, name, {
configurable: true,
enumerable: false,
writable: true,
value
});
}
/**
* 7.3.5 CreateDataProperty
* @param target
* @param name
* @param value
*/
export function createDataProperty(target, name, value) {
Object.defineProperty(target, name, {
configurable: true,
enumerable: true,
writable: true,
value
});
}
export const UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
export function invariant(condition, message, Err = Error) {
if (!condition) {
throw new Err(message);
}
}
export const createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
export const createMemoizedPluralRules = memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
export const createMemoizedLocale = memoize((...args) => new Intl.Locale(...args), { strategy: strategies.variadic });
export const createMemoizedListFormat = memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });