LastAccumulator.js 829 B

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. var LastAccumulator = module.exports = (function(){
  3. // Constructor
  4. /**
  5. * Constructor for LastAccumulator, wraps SingleValueAccumulator's constructor and
  6. * finds the last document
  7. *
  8. * @class LastAccumulator
  9. * @namespace munge.pipeline.accumulators
  10. * @module munge
  11. * @constructor
  12. **/
  13. var klass = module.exports = function LastAccumulator(){
  14. base.call(this);
  15. }, SingleValueAccumulator = require("./SingleValueAccumulator"), base = SingleValueAccumulator, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  16. proto.evaluate = function evaluate(doc){
  17. if(this.operands.length != 1) throw new Error("this should never happen");
  18. this.value = this.operands[0].evaluate(doc);
  19. };
  20. proto.getOpName = function getOpName(){
  21. return "$last";
  22. };
  23. return klass;
  24. })();