Skip to content

Commit

Permalink
jslintify
Browse files Browse the repository at this point in the history
  • Loading branch information
drhodes committed Apr 23, 2010
1 parent eb85518 commit 7d02f4b
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions set.js
Expand Up @@ -43,7 +43,7 @@ Set.prototype.fromArray = function(arr){
// instantiate a set given an array
for (var el in arr){
this.add(arr[el]);
}
};
return this;
}

Expand All @@ -52,7 +52,7 @@ Set.prototype.toArray = function(){
var arr = [];
for (var el in this.store){
arr.push(el);
}
};
return arr;
}

Expand All @@ -73,7 +73,7 @@ Set.prototype.copy = function(){
var temp = new Set();
for (var el in this.store){
temp.add(this.store(el));
}
};
return temp;
}

Expand All @@ -82,14 +82,16 @@ Set.prototype.clone = function(){
// this function stolen from ConroyP @ stackoverflow
// http://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-clone-a-javascript-object
function clone(obj){

if(obj == null || typeof(obj) != 'object')
if(obj == null || typeof(obj) != 'object'){
return obj;
}

var temp = obj.constructor();

for(var el in obj)
temp[el] = clone(obj[el]);
for(var el in obj){
temp[el] = clone(obj[el]);
};

return temp;
}

Expand All @@ -113,7 +115,7 @@ Set.prototype.difference = function(other){
if (!other.contains(el)){
diff.add(el);
}
}
};
return diff;
}

Expand All @@ -130,7 +132,7 @@ Set.prototype.differenceUpdate = function(other){
// Remove all elements of the other set from this set.
for( var el in other.store ){
this.remove(el);
}
};
return this;
}

Expand All @@ -139,7 +141,7 @@ Set.prototype.foreach = function(fn){
var result = new Set();
for( var el in this.store ){
result.add( fn(el) );
}
};
return result;
}

Expand All @@ -150,7 +152,7 @@ Set.prototype.intersection = function(other){
if (other.contains(el)){
result.add(el);
}
}
};
return result;
}

Expand All @@ -160,7 +162,7 @@ Set.prototype.intersectionUpdate = function(other){
if (!other.contains(el)){
this.remove(el);
}
}
};
return this;
}

Expand All @@ -175,7 +177,7 @@ Set.prototype.isSubset = function(other){
if (!other.contains(el)){
return false;
}
}
};
return true;
}

Expand All @@ -194,23 +196,23 @@ Set.prototype.union = function(other){
var result = this.clone();
for (var el in other.store){
result.add(el);
}
};
return result;
}

Set.prototype.unionUpdate = function(other){
// return a set containing all elements from both sets.
for (var el in other.store){
this.add(el);
}
};
return this;
}

Set.prototype.toString = function(){
var result = [];
for (var el in this.store){
result.push(el.toString());
}
};
return "Set<"+ result.join(", ") + ">";
}

Expand Down

0 comments on commit 7d02f4b

Please sign in to comment.