MCPcopy Index your code
hub / github.com/jashkenas/underscore / createEscaper

Function createEscaper

underscore.js:838–850  ·  view source on GitHub ↗
(map)

Source from the content-addressed store, hash-verified

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

Callers 1

underscore.jsFile · 0.70

Calls 1

keysFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…