* Safely clone an object using structuredClone with JSON fallback. * structuredClone can throw for functions, circular refs, etc.
(value)
| 236 | * structuredClone can throw for functions, circular refs, etc. |
| 237 | */ |
| 238 | function safeClone(value) { |
| 239 | try { |
| 240 | return typeof structuredClone === "function" |
| 241 | ? structuredClone(value) |
| 242 | : JSON.parse(JSON.stringify(value)); |
| 243 | } catch { |
| 244 | return JSON.parse(JSON.stringify(value)); |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | const cloned = { |
| 249 | localeOptions: safeClone(localeOptions), |