commons.js 768 B

12345678910111213141516171819
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.ERROR_PACKET = exports.PACKET_TYPES_REVERSE = exports.PACKET_TYPES = void 0;
  4. const PACKET_TYPES = Object.create(null); // no Map = no polyfill
  5. exports.PACKET_TYPES = PACKET_TYPES;
  6. PACKET_TYPES["open"] = "0";
  7. PACKET_TYPES["close"] = "1";
  8. PACKET_TYPES["ping"] = "2";
  9. PACKET_TYPES["pong"] = "3";
  10. PACKET_TYPES["message"] = "4";
  11. PACKET_TYPES["upgrade"] = "5";
  12. PACKET_TYPES["noop"] = "6";
  13. const PACKET_TYPES_REVERSE = Object.create(null);
  14. exports.PACKET_TYPES_REVERSE = PACKET_TYPES_REVERSE;
  15. Object.keys(PACKET_TYPES).forEach(key => {
  16. PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
  17. });
  18. const ERROR_PACKET = { type: "error", data: "parser error" };
  19. exports.ERROR_PACKET = ERROR_PACKET;