1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-15 16:43:44 -05:00
denoland-deno/cli/tests/workers/worker_structured_cloning.ts
Tim Ramlot 635253bd3a
feat(runtime/worker): Structured cloning worker message passing (#9323)
This commit upgrade "Worker.postMessage()" implementation to use 
structured clone algorithm instead of non-spec compliant JSON serialization.
2021-05-11 21:09:09 +02:00

15 lines
437 B
TypeScript

// More info on structured cloning can be found here:
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
self.onmessage = () => {
const arr = ["a", true, 432];
const set = new Set([1, 3, 5, 7, 9]);
const selfReference = {
a: arr,
b: arr,
c: set,
};
// deno-lint-ignore no-explicit-any
(selfReference as any).self = selfReference;
self.postMessage(selfReference);
};