index.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.encode = exports.decodeStrict = exports.decode = void 0;
  4. var decode_1 = require("./decode");
  5. var encode_1 = require("./encode");
  6. /**
  7. * Decodes a string with entities.
  8. *
  9. * @param data String to decode.
  10. * @param level Optional level to decode at. 0 = XML, 1 = HTML. Default is 0.
  11. */
  12. function decode(data, level) {
  13. return (!level || level <= 0 ? decode_1.decodeXML : decode_1.decodeHTML)(data);
  14. }
  15. exports.decode = decode;
  16. /**
  17. * Decodes a string with entities. Does not allow missing trailing semicolons for entities.
  18. *
  19. * @param data String to decode.
  20. * @param level Optional level to decode at. 0 = XML, 1 = HTML. Default is 0.
  21. */
  22. function decodeStrict(data, level) {
  23. return (!level || level <= 0 ? decode_1.decodeXML : decode_1.decodeHTMLStrict)(data);
  24. }
  25. exports.decodeStrict = decodeStrict;
  26. /**
  27. * Encodes a string with entities.
  28. *
  29. * @param data String to encode.
  30. * @param level Optional level to encode at. 0 = XML, 1 = HTML. Default is 0.
  31. */
  32. function encode(data, level) {
  33. return (!level || level <= 0 ? encode_1.encodeXML : encode_1.encodeHTML)(data);
  34. }
  35. exports.encode = encode;
  36. var encode_2 = require("./encode");
  37. Object.defineProperty(exports, "encodeXML", { enumerable: true, get: function () { return encode_2.encodeXML; } });
  38. Object.defineProperty(exports, "encodeHTML", { enumerable: true, get: function () { return encode_2.encodeHTML; } });
  39. Object.defineProperty(exports, "escape", { enumerable: true, get: function () { return encode_2.escape; } });
  40. // Legacy aliases
  41. Object.defineProperty(exports, "encodeHTML4", { enumerable: true, get: function () { return encode_2.encodeHTML; } });
  42. Object.defineProperty(exports, "encodeHTML5", { enumerable: true, get: function () { return encode_2.encodeHTML; } });
  43. var decode_2 = require("./decode");
  44. Object.defineProperty(exports, "decodeXML", { enumerable: true, get: function () { return decode_2.decodeXML; } });
  45. Object.defineProperty(exports, "decodeHTML", { enumerable: true, get: function () { return decode_2.decodeHTML; } });
  46. Object.defineProperty(exports, "decodeHTMLStrict", { enumerable: true, get: function () { return decode_2.decodeHTMLStrict; } });
  47. // Legacy aliases
  48. Object.defineProperty(exports, "decodeHTML4", { enumerable: true, get: function () { return decode_2.decodeHTML; } });
  49. Object.defineProperty(exports, "decodeHTML5", { enumerable: true, get: function () { return decode_2.decodeHTML; } });
  50. Object.defineProperty(exports, "decodeHTML4Strict", { enumerable: true, get: function () { return decode_2.decodeHTMLStrict; } });
  51. Object.defineProperty(exports, "decodeHTML5Strict", { enumerable: true, get: function () { return decode_2.decodeHTMLStrict; } });
  52. Object.defineProperty(exports, "decodeXMLStrict", { enumerable: true, get: function () { return decode_2.decodeXML; } });