{"ast":null,"code":"const encodePacket = require(\"./encodePacket\");\n\nconst decodePacket = require(\"./decodePacket\");\n\nconst SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text\n\nconst encodePayload = (packets, callback) => {\n  // some packets may be added to the array while encoding, so the initial length must be saved\n  const length = packets.length;\n  const encodedPackets = new Array(length);\n  let count = 0;\n  packets.forEach((packet, i) => {\n    // force base64 encoding for binary packets\n    encodePacket(packet, false, encodedPacket => {\n      encodedPackets[i] = encodedPacket;\n\n      if (++count === length) {\n        callback(encodedPackets.join(SEPARATOR));\n      }\n    });\n  });\n};\n\nconst decodePayload = (encodedPayload, binaryType) => {\n  const encodedPackets = encodedPayload.split(SEPARATOR);\n  const packets = [];\n\n  for (let i = 0; i < encodedPackets.length; i++) {\n    const decodedPacket = decodePacket(encodedPackets[i], binaryType);\n    packets.push(decodedPacket);\n\n    if (decodedPacket.type === \"error\") {\n      break;\n    }\n  }\n\n  return packets;\n};\n\nmodule.exports = {\n  protocol: 4,\n  encodePacket,\n  encodePayload,\n  decodePacket,\n  decodePayload\n};","map":{"version":3,"sources":["C:/laragon/www/iot.mksolusi/DriverOPCDA/frontend/node_modules/engine.io-parser/lib/index.js"],"names":["encodePacket","require","decodePacket","SEPARATOR","String","fromCharCode","encodePayload","packets","callback","length","encodedPackets","Array","count","forEach","packet","i","encodedPacket","join","decodePayload","encodedPayload","binaryType","split","decodedPacket","push","type","module","exports","protocol"],"mappings":"AAAA,MAAMA,YAAY,GAAGC,OAAO,CAAC,gBAAD,CAA5B;;AACA,MAAMC,YAAY,GAAGD,OAAO,CAAC,gBAAD,CAA5B;;AAEA,MAAME,SAAS,GAAGC,MAAM,CAACC,YAAP,CAAoB,EAApB,CAAlB,C,CAA2C;;AAE3C,MAAMC,aAAa,GAAG,CAACC,OAAD,EAAUC,QAAV,KAAuB;AAC3C;AACA,QAAMC,MAAM,GAAGF,OAAO,CAACE,MAAvB;AACA,QAAMC,cAAc,GAAG,IAAIC,KAAJ,CAAUF,MAAV,CAAvB;AACA,MAAIG,KAAK,GAAG,CAAZ;AAEAL,EAAAA,OAAO,CAACM,OAAR,CAAgB,CAACC,MAAD,EAASC,CAAT,KAAe;AAC7B;AACAf,IAAAA,YAAY,CAACc,MAAD,EAAS,KAAT,EAAgBE,aAAa,IAAI;AAC3CN,MAAAA,cAAc,CAACK,CAAD,CAAd,GAAoBC,aAApB;;AACA,UAAI,EAAEJ,KAAF,KAAYH,MAAhB,EAAwB;AACtBD,QAAAA,QAAQ,CAACE,cAAc,CAACO,IAAf,CAAoBd,SAApB,CAAD,CAAR;AACD;AACF,KALW,CAAZ;AAMD,GARD;AASD,CAfD;;AAiBA,MAAMe,aAAa,GAAG,CAACC,cAAD,EAAiBC,UAAjB,KAAgC;AACpD,QAAMV,cAAc,GAAGS,cAAc,CAACE,KAAf,CAAqBlB,SAArB,CAAvB;AACA,QAAMI,OAAO,GAAG,EAAhB;;AACA,OAAK,IAAIQ,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGL,cAAc,CAACD,MAAnC,EAA2CM,CAAC,EAA5C,EAAgD;AAC9C,UAAMO,aAAa,GAAGpB,YAAY,CAACQ,cAAc,CAACK,CAAD,CAAf,EAAoBK,UAApB,CAAlC;AACAb,IAAAA,OAAO,CAACgB,IAAR,CAAaD,aAAb;;AACA,QAAIA,aAAa,CAACE,IAAd,KAAuB,OAA3B,EAAoC;AAClC;AACD;AACF;;AACD,SAAOjB,OAAP;AACD,CAXD;;AAaAkB,MAAM,CAACC,OAAP,GAAiB;AACfC,EAAAA,QAAQ,EAAE,CADK;AAEf3B,EAAAA,YAFe;AAGfM,EAAAA,aAHe;AAIfJ,EAAAA,YAJe;AAKfgB,EAAAA;AALe,CAAjB","sourcesContent":["const encodePacket = require(\"./encodePacket\");\nconst decodePacket = require(\"./decodePacket\");\n\nconst SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text\n\nconst encodePayload = (packets, callback) => {\n  // some packets may be added to the array while encoding, so the initial length must be saved\n  const length = packets.length;\n  const encodedPackets = new Array(length);\n  let count = 0;\n\n  packets.forEach((packet, i) => {\n    // force base64 encoding for binary packets\n    encodePacket(packet, false, encodedPacket => {\n      encodedPackets[i] = encodedPacket;\n      if (++count === length) {\n        callback(encodedPackets.join(SEPARATOR));\n      }\n    });\n  });\n};\n\nconst decodePayload = (encodedPayload, binaryType) => {\n  const encodedPackets = encodedPayload.split(SEPARATOR);\n  const packets = [];\n  for (let i = 0; i < encodedPackets.length; i++) {\n    const decodedPacket = decodePacket(encodedPackets[i], binaryType);\n    packets.push(decodedPacket);\n    if (decodedPacket.type === \"error\") {\n      break;\n    }\n  }\n  return packets;\n};\n\nmodule.exports = {\n  protocol: 4,\n  encodePacket,\n  encodePayload,\n  decodePacket,\n  decodePayload\n};\n"]},"metadata":{},"sourceType":"script"}