e33d3290e3
Reduces the size of string-heavy code dramatically! 70% decrease in the size of the the elm-lang.org home page.
23 lines
No EOL
567 B
JavaScript
23 lines
No EOL
567 B
JavaScript
var String = function() {
|
|
var properEscape = function(str) {
|
|
str.replace('"', """);
|
|
str.replace("&", "&");
|
|
str.replace("'", "'");
|
|
str.replace("<", "<");
|
|
str.replace(">", ">");
|
|
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 };
|
|
}(); |