es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
17 lines (13 loc) • 319 B
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const htmlEscapes = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": ''',
};
function escape(str) {
return str.replace(/[&<>"']/g, match => htmlEscapes[match]);
}
exports.escape = escape;