Skip to content

Commit

Permalink
Merge pull request #15 from node-modules/String.prototype-html-methods
Browse files Browse the repository at this point in the history
String.prototype's HTML methods.
  • Loading branch information
hemanth committed Nov 17, 2014
2 parents b9985f3 + e68e277 commit 1792a6b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ __String realted:__
* String.prototype.startsWith
* String.prototype.endsWith
* String.prototype.contains
* String.prototype.anchor
* String.prototype.big
* String.prototype.bold
* String.prototype.fixed
* String.prototype.fontcolor
* String.prototype.fontsize
* String.prototype.italics
* String.prototype.link
* String.prototype.small
* String.prototype.strike
* String.prototype.sub
* String.prototype.sup

__Number realted:__

Expand Down Expand Up @@ -104,6 +116,7 @@ __Others:__
* let.
* const.
* Promise.
* RegExp.

## Test

Expand Down
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,20 @@ var str = { prototype: {} };
['raw','fromCodePoint'].forEach(function(attr){
str[attr] = isFunction(String[attr]);
});

// Prototype methods of Strings.
['codePointAt','normalize','repeat','startsWith','endsWith','contains'].forEach(function(attr){
str.prototype[attr] = isFunction(String.prototype[attr]);
});

// String.prototype HTML methods.
[
'anchor','big','bold','fixed','fontcolor','fontsize','italics',
'link', 'small', 'strike', 'sub', 'sup'
].forEach(function(attr){
str.prototype[attr] = isFunction(String.prototype[attr]);
});

// Number methods.
var num = {};
[
Expand Down
10 changes: 10 additions & 0 deletions test/enable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ describe('enable.test.js', function () {
}
});

it("should detect HTML methods of String.prototype", function(){
[
'anchor','big','bold','fixed','fontcolor','fontsize','italics',
'link', 'small', 'strike', 'sub', 'sup'
].forEach(function(attr){
enable.String.prototype[attr].should.be.a.Boolean;
enable.String.prototype[attr].should.equal(true);
});
});

it("should detect Number.isFinite", function(){
enable.Number.isFinite.should.be.a.Boolean;
if (process.version.indexOf('v0.10.') === 0) {
Expand Down

0 comments on commit 1792a6b

Please sign in to comment.