LastAccumulator.js 590 B

12345678910111213141516171819202122
  1. var LastAccumulator = module.exports = (function(){
  2. // Constructor
  3. var klass = module.exports = function LastAccumulator(){
  4. base.call(this);
  5. }, SingleValueAccumulator = require("./SingleValueAccumulator"), base = SingleValueAccumulator, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  6. proto.evaluate = function evaluate(doc){
  7. if(this.operands.length != 1) throw new Error("this should never happen");
  8. this.value = this.operands[0].evaluate(doc);
  9. };
  10. proto.getOpName = function getOpName(){
  11. return "$last";
  12. };
  13. return klass;
  14. })();