mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 12:49:10 +00:00
feat(extensions/web): add structuredClone function (#11572)
Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
parent
02c74fb709
commit
16ae4a0d57
9 changed files with 107 additions and 36 deletions
17
extensions/web/lib.deno_web.d.ts
vendored
17
extensions/web/lib.deno_web.d.ts
vendored
|
@ -673,7 +673,15 @@ declare class MessageEvent<T = any> extends Event {
|
|||
|
||||
type Transferable = ArrayBuffer | MessagePort;
|
||||
|
||||
interface PostMessageOptions {
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* This type has been renamed to StructuredSerializeOptions. Use that type for
|
||||
* new code.
|
||||
*/
|
||||
type PostMessageOptions = StructuredSerializeOptions;
|
||||
|
||||
interface StructuredSerializeOptions {
|
||||
transfer?: Transferable[];
|
||||
}
|
||||
|
||||
|
@ -710,7 +718,7 @@ declare class MessagePort extends EventTarget {
|
|||
* objects or port, or if message could not be cloned.
|
||||
*/
|
||||
postMessage(message: any, transfer: Transferable[]): void;
|
||||
postMessage(message: any, options?: PostMessageOptions): void;
|
||||
postMessage(message: any, options?: StructuredSerializeOptions): void;
|
||||
/**
|
||||
* Begins dispatching messages received on the port. This is implictly called
|
||||
* when assiging a value to `this.onmessage`.
|
||||
|
@ -737,3 +745,8 @@ declare class MessagePort extends EventTarget {
|
|||
options?: boolean | EventListenerOptions,
|
||||
): void;
|
||||
}
|
||||
|
||||
declare function structuredClone(
|
||||
value: any,
|
||||
options?: StructuredSerializeOptions,
|
||||
): any;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue