* @param {string} url * @param {string|string[]} protocols
(url, protocols = [])
| 18283 | }), |
| 18284 | callback: cb, |
| 18285 | frame: null |
| 18286 | }; |
| 18287 | __privateGet(this, _queue).push(node); |
| 18288 | if (!__privateGet(this, _running)) { |
| 18289 | __privateMethod(this, _run, run_fn).call(this); |
| 18290 | } |
| 18291 | } |
| 18292 | }; |
| 18293 | _queue = new WeakMap(); |
| 18294 | _running = new WeakMap(); |
| 18295 | _socket = new WeakMap(); |
| 18296 | _run = new WeakSet(); |
| 18297 | run_fn = function() { |
| 18298 | return __async(this, null, function* () { |
| 18299 | __privateSet(this, _running, true); |
| 18300 | const queue = __privateGet(this, _queue); |
| 18301 | while (!queue.isEmpty()) { |
| 18302 | const node = queue.shift(); |
| 18303 | if (node.promise !== null) { |
| 18304 | yield node.promise; |
| 18305 | } |
| 18306 | __privateGet(this, _socket).write(node.frame, node.callback); |
| 18307 | node.callback = node.frame = null; |
| 18308 | } |
| 18309 | __privateSet(this, _running, false); |
| 18310 | }); |
| 18311 | }; |
| 18312 | function createFrame(data, hint) { |
| 18313 | return new WebsocketFrameSend(toBuffer(data, hint)).createFrame(hint === sendHints.string ? opcodes.TEXT : opcodes.BINARY); |
| 18314 | } |
| 18315 | function toBuffer(data, hint) { |
| 18316 | switch (hint) { |
| 18317 | case sendHints.string: |
| 18318 | return Buffer.from(data); |
| 18319 | case sendHints.arrayBuffer: |
| 18320 | case sendHints.blob: |
| 18321 | return new FastBuffer(data); |
| 18322 | case sendHints.typedArray: |
| 18323 | return new FastBuffer(data.buffer, data.byteOffset, data.byteLength); |
| 18324 | } |
| 18325 | } |
| 18326 | module.exports = { SendQueue }; |
| 18327 | } |
| 18328 | }); |
| 18329 | |
| 18330 | // |
| 18331 | var require_websocket = __commonJS({ |
| 18332 | ""(exports, module) { |
| 18333 | "use strict"; |
| 18334 | var { webidl } = require_webidl(); |
| 18335 | var { URLSerializer } = require_data_url(); |
| 18336 | var { environmentSettingsObject } = require_util2(); |
| 18337 | var { staticPropertyDescriptors, states, sentCloseFrameState, sendHints } = require_constants5(); |
| 18338 | var { |
| 18339 | kWebSocketURL, |
| 18340 | kReadyState, |
| 18341 | kController, |
| 18342 | kBinaryType, |
nothing calls this directly
no test coverage detected