-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSet.js
38 lines (28 loc) · 927 Bytes
/
Set.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(function(define) {
define(['./pile', './MutableCollection', './Map'],
function(pile, MutableCollection, Map) {
var mapProto, forEach, add, contains, remove;
// Borrow from Map
mapProto = Map.prototype;
forEach = mapProto.forEach;
add = mapProto.add;
contains = mapProto.contains;
remove = mapProto.remove;
function Set(hasher) {
Map.call(this, hasher);
}
Set.prototype = pile.extend(MutableCollection, {
forEach: function(forEachFunc) {
return forEach.call(this, function(k, v) {
forEachFunc(v);
});
},
add: function(item) {
return add.call(this, item, item);
},
contains: contains,
remove: remove
});
return Set;
});
})(typeof define != 'undefined' ? define : function(deps, factory) { module.exports = factory.apply(this, deps.map(require)); });