main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
829 bytes
|
Rev | Line | |
---|
[d565449] | 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};
|
---|
Note:
See
TracBrowser
for help on using the repository browser.