UNPKG

@ethersphere/bee-js

Version:
12 lines 362 B
export async function prepareWebsocketData(data) { if (typeof data === 'string') { return new TextEncoder().encode(data); } if (data instanceof ArrayBuffer) { return new Uint8Array(data); } if (data instanceof Blob) { return new Uint8Array(await new Response(data).arrayBuffer()); } throw new TypeError('unknown websocket data type'); }