UNPKG

@maphubs/tokml

Version:
24 lines (18 loc) 575 B
/* istanbul ignore file */ // originally from https://github.com/miketheprogrammer/xml-escape var escape = (module.exports = function escape(string, ignore) { var pattern if (string === null || string === undefined) return ignore = (ignore || '').replace(/[^&"<>\']/g, '') pattern = '([&"<>\'])'.replace(new RegExp('[' + ignore + ']', 'g'), '') return string.replace(new RegExp(pattern, 'g'), function (str, item) { return escape.map[item] }) }) var map = (escape.map = { '>': '&gt;', '<': '&lt;', "'": '&apos;', '"': '&quot;', '&': '&amp;' })