MCPcopy
hub / github.com/jashkenas/underscore / createEscaper

Function createEscaper

underscore-node-f.cjs:831–843  ·  view source on GitHub ↗
(map)

Source from the content-addressed store, hash-verified

829// Internal helper to generate functions for escaping and unescaping strings
830// to/from HTML interpolation.
831function createEscaper(map) {
832 var escaper = function(match) {
833 return map[match];
834 };
835 // Regexes for identifying a key that needs to be escaped.
836 var source = '(?:' + keys(map).join('|') + ')';
837 var testRegexp = RegExp(source);
838 var replaceRegexp = RegExp(source, 'g');
839 return function(string) {
840 string = string == null ? '' : '' + string;
841 return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
842 };
843}
844
845// Internal list of HTML entities for escaping.
846var escapeMap = {

Callers 1

Calls 1

keysFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…