UNPKG

html-entities-decode

Version:
19 lines (18 loc) 592 B
"use strict"; /* IMPORT */ var entities_1 = require("./entities"); /* HTML ENTITIES DECODE */ var re = /&(?:([a-zA-Z0-9]+)|#([0-9]{1,6})|#[xX]([a-fA-F0-9]{1,6}));/g; function decode(str) { return str.replace(re, function (match, $1, $2, $3) { if ($1) return entities_1.default[$1] || match; if ($2) return String.fromCodePoint(parseInt($2)); return String.fromCodePoint(parseInt($3, 16)); }); } /* EXPORT */ module.exports = decode; module.exports.default = decode; Object.defineProperty(module.exports, "__esModule", { value: true });