informed
Version:
A lightweight framework and utility for building powerful forms in React applications
9 lines (7 loc) • 470 B
JavaScript
// fallback for browsers that don't support `structuredClone` yet
// this comes with some limitations in what can be cloned, but this should be fine for most use cases
// `structuredClone` can also be polyfilled using https://www.npmjs.com/package/@ungap/structured-clone
var structuredCloneShim = typeof structuredClone === 'function' ? structuredClone : function (obj) {
return JSON.parse(JSON.stringify(obj));
};
export { structuredCloneShim as structuredClone };