nodejs-polars
Version:
Polars: Blazingly fast DataFrames in Rust, Python, Node.js, R and SQL
19 lines (18 loc) • 549 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.escapeHTML = escapeHTML;
const rawToEntityEntries = [
["&", "&"],
["<", "<"],
[">", ">"],
['"', """],
["'", "'"],
];
const rawToEntity = new Map(rawToEntityEntries);
const rawRe = new RegExp(`[${[...rawToEntity.keys()].join("")}]`, "g");
/**
* Escapes text for safe interpolation into HTML text content and quoted attributes
*/
function escapeHTML(str) {
return str.replaceAll(rawRe, (m) => rawToEntity.get(m) ?? m);
}
;