Files
klz-cables.com/.pnpm-store/v10/files/d1/292466d2380b72442717473f2a4a029099cb397e60c724b64f93b82568a7e6c6b096ad5fffdf5b6fcd12b3aba225a04b67249b402b648c77d7286a07712363
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

32 lines
770 B
Plaintext

import { ToString } from "./262.js";
/**
* https://tc39.es/ecma402/#sec-getoption
* @param opts
* @param prop
* @param type
* @param values
* @param fallback
*/
export function GetOption(opts, prop, type, values, fallback) {
if (typeof opts !== "object") {
throw new TypeError("Options must be an object");
}
let value = opts[prop];
if (value !== undefined) {
if (type !== "boolean" && type !== "string") {
throw new TypeError("invalid type");
}
if (type === "boolean") {
value = Boolean(value);
}
if (type === "string") {
value = ToString(value);
}
if (values !== undefined && !values.filter((val) => val == value).length) {
throw new RangeError(`${value} is not within ${values.join(", ")}`);
}
return value;
}
return fallback;
}