Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/thunderbird/util/promisified_message_port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import type { IMessagePort } from "src/ghosttext-runner"
import { PromisifyingQueue } from "src/util/promisifying_queue"

/**
* Create a pair of PromisifiedMessagePort from a MessageChannel.
* @template TRequest The type of messages which port1 can sends, and port2 expects to receive
* @template TResponse The type of messages which port1 expects to receive, and port2 can send
* Creates a pair of promisified message ports from a MessageChannel.
*
* @template TRequest The type of messages the first returned port can send and the second expects to receive
* @template TResponse The type of messages the first returned port expects to receive and the second can send
* @returns A tuple `[IMessagePort<TRequest, TResponse>, IMessagePort<TResponse, TRequest>]` where the first element is a promisified port for sending `TRequest` and receiving `TResponse`, and the second element is a promisified port for sending `TResponse` and receiving `TRequest`
*/
export function promisifyMessageChannel<TRequest extends object | string, TResponse extends object | string>({
port1,
Expand Down