elm/core-js/String.js
evancz e33d3290e3 Introduce basic optimizations.
Reduces the size of string-heavy code dramatically! 70% decrease in the
size of the the elm-lang.org home page.
2012-05-22 18:07:21 -04:00

23 lines
No EOL
567 B
JavaScript

var String = function() {
var properEscape = function(str) {
str.replace('"', """);
str.replace("&", "&");
str.replace("'", "'");
str.replace("<", "&#60;");
str.replace(">", "&#62;");
return str;
};
var toText = function(elmList) {
if (typeof elmList === "string") return elmList;
var a = [];
while (elmList[0] === "Cons") {
a.push(elmList[1]);
elmList = elmList[2];
}
return String.properEscape(a.join(''));
};
return {toText : toText,
properEscape : properEscape };
}();