UNPKG

nodejs-polars

Version:

Polars: Blazingly fast DataFrames in Rust, Python, Node.js, R and SQL

19 lines (18 loc) 549 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.escapeHTML = escapeHTML; const rawToEntityEntries = [ ["&", "&amp;"], ["<", "&lt;"], [">", "&gt;"], ['"', "&quot;"], ["'", "&#39;"], ]; 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); }