|
@@ -1,17 +1,19 @@
|
|
var AddToSetAccumulator = module.exports = (function(){
|
|
var AddToSetAccumulator = module.exports = (function(){
|
|
|
|
+
|
|
|
|
+ // DEPENDENCIES
|
|
|
|
+ var Value = require("../Value");
|
|
|
|
+ require("es6-shim");
|
|
|
|
+
|
|
// CONSTRUCTOR
|
|
// CONSTRUCTOR
|
|
/** Create an expression that finds the sum of n operands. **/
|
|
/** Create an expression that finds the sum of n operands. **/
|
|
var klass = module.exports = function AddToSetAccumulator(/* pCtx */){
|
|
var klass = module.exports = function AddToSetAccumulator(/* pCtx */){
|
|
if(arguments.length !== 0) throw new Error("zero args expected");
|
|
if(arguments.length !== 0) throw new Error("zero args expected");
|
|
- this.set = {};
|
|
|
|
|
|
+ this.set = new Map();
|
|
//this.itr = undefined; /* Shoudln't need an iterator for the set */
|
|
//this.itr = undefined; /* Shoudln't need an iterator for the set */
|
|
//this.pCtx = undefined; /* Not using the context object currently as it is related to sharding */
|
|
//this.pCtx = undefined; /* Not using the context object currently as it is related to sharding */
|
|
base.call(this);
|
|
base.call(this);
|
|
}, Accumulator = require("./Accumulator"), base = Accumulator, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
}, Accumulator = require("./Accumulator"), base = Accumulator, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
- // DEPENDENCIES
|
|
|
|
- var Value = require("../Value");
|
|
|
|
-
|
|
|
|
// PROTOTYPE MEMBERS
|
|
// PROTOTYPE MEMBERS
|
|
proto.getOpName = function getOpName(){
|
|
proto.getOpName = function getOpName(){
|
|
return "$addToSet";
|
|
return "$addToSet";
|
|
@@ -27,19 +29,14 @@ var AddToSetAccumulator = module.exports = (function(){
|
|
if ('undefined' != typeof rhs) {
|
|
if ('undefined' != typeof rhs) {
|
|
Value.verifyArray(rhs);
|
|
Value.verifyArray(rhs);
|
|
for(var i=0; i<rhs.length; i++) {
|
|
for(var i=0; i<rhs.length; i++) {
|
|
- var key = Value.hashCombine(rhs[i]);
|
|
|
|
- this.set[key] = rhs[i];
|
|
|
|
|
|
+ this.set.set(rhs[i], rhs[i]); //Sorry about variable names here... just following the rules!
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return undefined;
|
|
return undefined;
|
|
};
|
|
};
|
|
|
|
|
|
proto.getValue = function getValue() {
|
|
proto.getValue = function getValue() {
|
|
- var arr = [], n = 0;
|
|
|
|
- for(var key in this.set){
|
|
|
|
- if(this.set.hasOwnProperty(key)) arr[n++] = this.set[key];
|
|
|
|
- }
|
|
|
|
- return arr;
|
|
|
|
|
|
+ return this.set.values();
|
|
};
|
|
};
|
|
|
|
|
|
return klass;
|
|
return klass;
|