@maizzle/framework
Version:
Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.
21 lines (20 loc) • 819 B
JavaScript
//#region src/utils/cloneConfig.ts
/**
* Deep-clone plain objects so per-template config mutations stay isolated.
*
* Arrays, functions, and class instances (Date, RegExp, Vite plugins, …) pass
* through by reference — only nested plain-object props are copied, which is
* what `beforeRender` mutations (`config.url.base`, `config.css.inline`, …)
* touch. Sharing arrays by reference matches the parallel worker's merge.
*/
function cloneConfig(value) {
if (value === null || typeof value !== "object") return value;
if (Array.isArray(value)) return value;
if (Object.getPrototypeOf(value) !== Object.prototype) return value;
const out = {};
for (const key of Object.keys(value)) out[key] = cloneConfig(value[key]);
return out;
}
//#endregion
export { cloneConfig };
//# sourceMappingURL=cloneConfig.js.map