npm install escape2
<script src="node_modules/escape2/index.js"></script>;
var escape2=require('escape2');
var enc = escape2.encode('<&>');
var dec = escape2.decode(enc);
escape2={ | |
encode:function(text){ | |
text = text.replace(/&/g,'&'); | |
text = text.replace(/</g, '<'); | |
text = text.replace(/>/g, '>'); | |
return text; | |
}, | |
decode:function(text){ | |
text = text.replace( />/g,'>'); | |
text = text.replace( /</g,'<'); | |
text = text.replace(/&/g,'&'); | |
return text; | |
} | |
}; | |
module.exports=escape2; |
{ | |
"name":"escape2", | |
"description":"HTML encoding / decoding", | |
"repository":"https://gist.github.com/val314159/9ab1fd1a551679d958b5c42e43732696", | |
"main":"index.js", | |
"license":"MIT", | |
"version":"0.0.2" | |
} |