You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
511 B

4 years ago
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.default = unesc;
  4. var HEX_ESC = /\\(?:([0-9a-fA-F]{6})|([0-9a-fA-F]{1,5})(?: |(?![0-9a-fA-F])))/g;
  5. var OTHER_ESC = /\\(.)/g;
  6. function unesc(str) {
  7. str = str.replace(HEX_ESC, function (_, hex1, hex2) {
  8. var hex = hex1 || hex2;
  9. var code = parseInt(hex, 16);
  10. return String.fromCharCode(code);
  11. });
  12. str = str.replace(OTHER_ESC, function (_, char) {
  13. return char;
  14. });
  15. return str;
  16. }
  17. module.exports = exports["default"];