| 1 | import {deserialize} from './deserialize.js'; |
| 2 | import {serialize} from './serialize.js'; |
| 3 | |
| 4 | /** |
| 5 | * @typedef {Array<string,any>} Record a type representation |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Returns an array of serialized Records. |
| 10 | * @param {any} any a serializable value. |
| 11 | * @param {{transfer?: any[], json?: boolean, lossy?: boolean}?} options an object with |
| 12 | * a transfer option (ignored when polyfilled) and/or non standard fields that |
| 13 | * fallback to the polyfill if present. |
| 14 | * @returns {Record[]} |
| 15 | */ |
| 16 | export default typeof structuredClone === "function" ? |
| 17 | /* c8 ignore start */ |
| 18 | (any, options) => ( |
| 19 | options && ('json' in options || 'lossy' in options) ? |
| 20 | deserialize(serialize(any, options)) : structuredClone(any) |
| 21 | ) : |
| 22 | (any, options) => deserialize(serialize(any, options)); |
| 23 | /* c8 ignore stop */ |
| 24 | |
| 25 | export {deserialize, serialize}; |