SingleValueAccumulator.js 969 B

123456789101112131415161718192021222324252627282930313233
  1. var SingleValueAccumulator = module.exports = (function(){
  2. // Constructor
  3. /**
  4. * This isn't a finished accumulator, but rather a convenient base class
  5. * for others such as $first, $last, $max, $min, and similar. It just
  6. * provides a holder for a single Value, and the getter for that. The
  7. * holder is protected so derived classes can manipulate it.
  8. *
  9. * @class SingleValueAccumulator
  10. * @namespace munge.pipeline.accumulators
  11. * @module munge
  12. * @constructor
  13. **/
  14. var klass = module.exports = function AccumulatorSingleValue(value){
  15. if(arguments.length > 1 ) throw new Error("expects a single value");
  16. this.value = value;
  17. base.call(this);
  18. }, Accumulator = require("./Accumulator"), base = Accumulator, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  19. // DEPENDENCIES
  20. var Value = require("../Value");
  21. proto.getValue = function getValue(){
  22. return this.value;
  23. };
  24. return klass;
  25. })();