Skip to content

Instantly share code, notes, and snippets.

@vestige
Created February 10, 2011 12:14
Show Gist options
  • Save vestige/820426 to your computer and use it in GitHub Desktop.
Save vestige/820426 to your computer and use it in GitHub Desktop.
Function.prototype.method = function(name, func)
{
this.prototype[name] = func;
return this;
};
String.method('deentityify', function()
{
var entity = {
quot: '"',
lt: '<',
gt: '>'
};
return function() {
return this.replace(/&([^&;]+);/g,
function(a,b) {
var r = entity[b];
return typeof r === 'string' ? r : a;
}
);
}
} () );
alert('aaa'.deentityify());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment