UNPKG

wampy

Version:

Amazingly fast, feature-rich, lightweight WAMP Javascript client (for browser and node.js)

30 lines (28 loc) 1.09 kB
/** * Deferred promise object with exposed resolve and reject callbacks. */ interface Deferred<T = unknown> { promise: Promise<T>; onSuccess: (value: T) => void | Promise<void>; onError: (reason?: unknown) => void | Promise<void>; } /** * Configuration object for getWebSocket. */ interface GetWebSocketConfig { url?: string; protocols?: string[]; options?: { ws?: { new (url: string, protocols?: string[], origin?: null, headers?: Record<string, string>, requestOptions?: Record<string, unknown>): WebSocket; }; additionalHeaders?: Record<string, string>; wsRequestOptions?: Record<string, unknown>; }; isBrowserMock?: boolean; } /** Get a WebSocket object according to the user's current environment */ declare function getWebSocket({ url, protocols, options, isBrowserMock }?: GetWebSocketConfig): WebSocket | null; /** Create a new deferred promise with exposed resolve and reject callbacks */ declare function getNewPromise<T = unknown>(): Deferred<T>; export { type Deferred, getNewPromise, getWebSocket };