diff --git a/lib/set.js b/lib/set.js index 4a9dabf..d72159d 100644 --- a/lib/set.js +++ b/lib/set.js @@ -42,7 +42,7 @@ Set.prototype.diff = function(other) { var d = [] , x ; - for (x in this.members) if (!(x in other.members)) d.push(x); + for (x in this.members) if (!(x in other.members)) d.push(this.members[x]); return new Set(d); }; @@ -58,9 +58,14 @@ Set.prototype.remove = function(item) { }; Set.prototype.toArray = function() { - return Object.keys(this.members); + var ms = this.members; + return ownProps(this.members).map(function(k) { return ms[k]; }); }; Set.prototype.union = function(other) { - return new Set(ownProps(this.members).concat(ownProps(other.members))); + var ms = this.members; + , u = ownProps(this.members).map(function(k) { return ms[k]; }); + ms = other.members; + u = u.concat(ownProps(ms).map(function(k) { return ms[k]; })); + return new Set(u); };