Skip to content

Instantly share code, notes, and snippets.

@prdanelli
Created June 11, 2013 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prdanelli/5758551 to your computer and use it in GitHub Desktop.
Save prdanelli/5758551 to your computer and use it in GitHub Desktop.
Example JS Module example.
// module...
// encapculates the properties of the function
// returns the function
String.method('deentity', function(){
var entities = {
quote: '"',
lt: '<',
gt: '>'
};
return function(){
return this.replace(/&([^&;]+);/g, function(a, b){
var r = entities[b];
return typeof r === 'string' ? r : a;
});
}
});
document.writeln('&quot;This is the test &gt;&gt;&gt;&gt;....&quot;');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment