|
|
@@ -6,19 +6,19 @@
|
|
|
* @namespace mungedb-aggregate.pipeline.accumulators
|
|
|
* @module mungedb-aggregate
|
|
|
* @constructor
|
|
|
-**/
|
|
|
-var AddToSetAccumulator = module.exports = function AddToSetAccumulator(){
|
|
|
+ */
|
|
|
+var AddToSetAccumulator = module.exports = function AddToSetAccumulator() {
|
|
|
if (arguments.length !== 0) throw new Error("zero args expected");
|
|
|
this.reset();
|
|
|
base.call(this);
|
|
|
}, klass = AddToSetAccumulator, Accumulator = require("./Accumulator"), base = Accumulator, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
-var Value = require("../Value");
|
|
|
+var ValueSet = require("../ValueSet");
|
|
|
|
|
|
proto.processInternal = function processInternal(input, merging) {
|
|
|
if (!merging) {
|
|
|
if (input !== undefined) {
|
|
|
- this.set[JSON.stringify(input)] = input;
|
|
|
+ this.set.insert(input);
|
|
|
}
|
|
|
} else {
|
|
|
// If we're merging, we need to take apart the arrays we
|
|
|
@@ -28,22 +28,17 @@ proto.processInternal = function processInternal(input, merging) {
|
|
|
if (!Array.isArray(input)) throw new Error("Assertion failure");
|
|
|
|
|
|
for (var i = 0, l = input.length; i < l; i++) {
|
|
|
- this.set[JSON.stringify(input[i])] = input[i];
|
|
|
+ this.set.insert(input[i]);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-proto.getValue = function getValue(toBeMerged) {
|
|
|
- var results = [];
|
|
|
- for(var key in this.set){
|
|
|
- // if(!Object.hasOwnProperty(this.set))
|
|
|
- results.push(this.set[key]);
|
|
|
- }
|
|
|
- return results;
|
|
|
+proto.getValue = function getValue(toBeMerged) { //jshint ignore:line
|
|
|
+ return this.set.values();
|
|
|
};
|
|
|
|
|
|
proto.reset = function reset() {
|
|
|
- this.set = {};
|
|
|
+ this.set = new ValueSet();
|
|
|
};
|
|
|
|
|
|
klass.create = function create() {
|