source: trip-planner-front/node_modules/engine.io-parser/build/cjs/index.js@ bdd6491

Last change on this file since bdd6491 was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

  • Property mode set to 100644
File size: 1.6 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = void 0;
4const encodePacket_js_1 = require("./encodePacket.js");
5exports.encodePacket = encodePacket_js_1.default;
6const decodePacket_js_1 = require("./decodePacket.js");
7exports.decodePacket = decodePacket_js_1.default;
8const SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
9const encodePayload = (packets, callback) => {
10 // some packets may be added to the array while encoding, so the initial length must be saved
11 const length = packets.length;
12 const encodedPackets = new Array(length);
13 let count = 0;
14 packets.forEach((packet, i) => {
15 // force base64 encoding for binary packets
16 (0, encodePacket_js_1.default)(packet, false, encodedPacket => {
17 encodedPackets[i] = encodedPacket;
18 if (++count === length) {
19 callback(encodedPackets.join(SEPARATOR));
20 }
21 });
22 });
23};
24exports.encodePayload = encodePayload;
25const decodePayload = (encodedPayload, binaryType) => {
26 const encodedPackets = encodedPayload.split(SEPARATOR);
27 const packets = [];
28 for (let i = 0; i < encodedPackets.length; i++) {
29 const decodedPacket = (0, decodePacket_js_1.default)(encodedPackets[i], binaryType);
30 packets.push(decodedPacket);
31 if (decodedPacket.type === "error") {
32 break;
33 }
34 }
35 return packets;
36};
37exports.decodePayload = decodePayload;
38exports.protocol = 4;
Note: See TracBrowser for help on using the repository browser.