Skip to content

Commit

Permalink
Merge pull request #24 from node-modules/sets
Browse files Browse the repository at this point in the history
Set related checks.
  • Loading branch information
hemanth committed Dec 10, 2014
2 parents efd05e1 + eeb9c62 commit 0e50301
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ __WeakMap related:__
* WeakMap.prototype.delete
* WeakMap.prototype.clear

__Set related:__

* Set
* Set.prototype.constructor
* Set.prototype.size
* Set.prototype.add
* Set.prototype.has
* Set.prototype.delete
* Set.prototype.clear
* Set.prototype.forEach
* Set.prototype.entries
* Set.prototype.keys
* Set.prototype.values

__Others:__

* generator.
Expand Down
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ var wm = (function(){
}
}());

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

// Export them all
exports.Object = obj;
exports.String = str;
Expand All @@ -164,3 +182,4 @@ exports.Function = func;
exports.class = klass;
exports.Map = map;
exports.WeakMap = wm;
exports.Set = set;
103 changes: 103 additions & 0 deletions test/enable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,4 +666,107 @@ describe('enable.test.js', function () {
}
});
}

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

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

0 comments on commit 0e50301

Please sign in to comment.