Skip to content

Commit

Permalink
Merge dd29a01 into b2d88f4
Browse files Browse the repository at this point in the history
  • Loading branch information
hemanth committed Dec 8, 2014
2 parents b2d88f4 + dd29a01 commit d424f28
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 2 deletions.
21 changes: 20 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var str = { prototype: {} };

// String.prototype HTML methods.
[
'anchor','big','bold','fixed','fontcolor','fontsize','italics',
'anchor','big','bold','fixed','fontcolor','fontsize','italics',
'link', 'small', 'strike', 'sub', 'sup'
].forEach(function(attr){
str.prototype[attr] = isFunction(String.prototype[attr]);
Expand Down Expand Up @@ -118,6 +118,24 @@ var klass = (function(){
}
}());

// Map.
var map = (function(){
if(isFunction(Map)){
var map = { 'prototype': {} };
[
"get", "has", "set",
"delete", "keys", "values",
"clear", "forEach", "entries"
].forEach(function(attr){
map.prototype[attr] = isFunction(Map.prototype[attr]);
});
map.prototype['size'] = !~~Object.getOwnPropertyDescriptor(Map.prototype,'size')
return map;
} else {
return false;
}
}());

// Export them all
exports.Object = obj;
exports.String = str;
Expand All @@ -127,3 +145,4 @@ exports.RegExp = regex;
exports.Promise = typeof Promise !== 'undefined' && isFunction(Promise.all);
exports.Function = func;
exports.class = klass;
exports.Map = map;
106 changes: 105 additions & 1 deletion test/enable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ describe('enable.test.js', function () {

it("should detect HTML methods of String.prototype", function(){
[
'anchor','big','bold','fixed','fontcolor','fontsize','italics',
'anchor','big','bold','fixed','fontcolor','fontsize','italics',
'link', 'small', 'strike', 'sub', 'sup'
].forEach(function(attr){
enable.String.prototype[attr].should.be.a.Boolean;
Expand Down Expand Up @@ -488,4 +488,108 @@ describe('enable.test.js', function () {
}
});

it("should detect Map", function(){
if (process.version.indexOf('v0.10.') === 0) {
enable.Map.should.be.Boolean;
enable.Map.should.equal(false);
}
if (process.version.indexOf('v0.11.') === 0) {
enable.Map.should.be.Object;
console.log("meow",enable.Map);
Object.keys(enable.Map).length.should.equal(1);
}
});

if(enable.Map) {
it("should detect Map.prototype.size", function() {
enable.Map.prototype.size.should.be.Boolean;
if (process.version.indexOf('v0.10.') === 0) {
enable.Map.prototype.size.should.equal(false);
}
if (process.version.indexOf('v0.11.') === 0) {
enable.Map.prototype.size.should.equal(true);
}
});
it("should detect Map.prototype.get", function() {
enable.Map.prototype.get.should.be.Boolean;
if (process.version.indexOf('v0.10.') === 0) {
enable.Map.prototype.get.should.equal(false);
}
if (process.version.indexOf('v0.11.') === 0) {
enable.Map.prototype.get.should.equal(true);
}
});
it("should detect Map.prototype.has", function() {
enable.Map.prototype.has.should.be.Boolean;
if (process.version.indexOf('v0.10.') === 0) {
enable.Map.prototype.has.should.equal(false);
}
if (process.version.indexOf('v0.11.') === 0) {
enable.Map.prototype.has.should.equal(true);
}
});
it("should detect Map.prototype.set", function() {
enable.Map.prototype.set.should.be.Boolean;
if (process.version.indexOf('v0.10.') === 0) {
enable.Map.prototype.set.should.equal(false);
}
if (process.version.indexOf('v0.11.') === 0) {
enable.Map.prototype.set.should.equal(false);
}
});
it("should detect Map.prototype.delete", function() {
enable.Map.prototype.delete.should.be.Boolean;
if (process.version.indexOf('v0.10.') === 0) {
enable.Map.prototype.delete.should.equal(false);
}
if (process.version.indexOf('v0.11.') === 0) {
enable.Map.prototype.delete.should.equal(true);
}
});
it("should detect Map.prototype.keys", function() {
enable.Map.prototype.keys.should.be.Boolean;
if (process.version.indexOf('v0.10.') === 0) {
enable.Map.prototype.keys.should.equal(false);
}
if (process.version.indexOf('v0.11.') === 0) {
enable.Map.prototype.keys.should.equal(false);
}
});
it("should detect Map.prototype.values", function() {
enable.Map.prototype.values.should.be.Boolean;
if (process.version.indexOf('v0.10.') === 0) {
enable.Map.prototype.values.should.equal(false);
}
if (process.version.indexOf('v0.11.') === 0) {
enable.Map.prototype.values.should.equal(false);
}
});
it("should detect Map.prototype.clear", function() {
enable.Map.prototype.clear.should.be.Boolean;
if (process.version.indexOf('v0.10.') === 0) {
enable.Map.prototype.clear.should.equal(false);
}
if (process.version.indexOf('v0.11.') === 0) {
enable.Map.prototype.clear.should.equal(true);
}
});
it("should detect Map.prototype.forEach", function() {
enable.Map.prototype.forEach.should.be.Boolean;
if (process.version.indexOf('v0.10.') === 0) {
enable.Map.prototype.forEach.should.equal(false);
}
if (process.version.indexOf('v0.11.') === 0) {
enable.Map.prototype.forEach.should.equal(true);
}
});
it("should detect Map.prototype.entries", function() {
enable.Map.prototype.entries.should.be.Boolean;
if (process.version.indexOf('v0.10.') === 0) {
enable.Map.prototype.entries.should.equal(false);
}
if (process.version.indexOf('v0.11.') === 0) {
enable.Map.prototype.entries.should.equal(false);
}
});
}
});

0 comments on commit d424f28

Please sign in to comment.