const encoded = { '&': '&', '<': '<', '>': '>', '/': '/', "'": ''', '"': '"', }; export default function escape(str: string): string { return str.replace(/[&<>\/'"]/g, function (char) { return encoded[char]; }); }