mirror of
https://github.com/samsonjs/batteries.git
synced 2026-03-25 09:15:46 +00:00
make set compatible with non-strings, still very slow
This commit is contained in:
parent
d2b88f5c54
commit
92912c0678
1 changed files with 8 additions and 3 deletions
11
lib/set.js
11
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);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue