lib/modules/crafity.query.js
function Enumerator(getCurrent, moveNext, reset) {
  var index = 0,
    self = this;

  /**
   * Get the current index of the enumerator
   */
  this.getIndex = function getIndexEnumeratorInternal() {
    return index;
  };
  /**
   * Function that retrieves the current value
   * @function
   * @returns {Object} The current item
   */
  this.getCurrent = function getCurrentInternal() {
    return getCurrent(self);
  };

  this.overrideGetCurrent = function overrideGetCurrentInternal(getCurrent) {
    self.getCurrent = function () {
      return getCurrent(self.getCurrent());
    };
    return self;
  };
  /**
   * Function that moves to the next item and returns true if there was a next item, otherwise false
   * @function
   * @returns {Boolean} True if moved to the next item, otherwise false
   */
  this.moveNext = function moveNextInternal() {
    index = index + 1;
    return moveNext(self);
  };
  /**
   * Function that moves to the next item and returns true if there was a next item, otherwise false
   * @function
   * @returns {Boolean} True if moved to the next item, otherwise false
   */
  this.reset = function resetInternal() {
    index = 0;
    return reset(self);
  };
}
function Enumerator(getCurrent, moveNext, reset) {
  var index = 0,
    self = this;

  /**
   * Get the current index of the enumerator
   */
  this.getIndex = function getIndexEnumeratorInternal() {
    return index;
  };
  /**
   * Function that retrieves the current value
   * @function
   * @returns {Object} The current item
   */
  this.getCurrent = function getCurrentInternal() {
    return getCurrent(self);
  };

  this.overrideGetCurrent = function overrideGetCurrentInternal(getCurrent) {
    self.getCurrent = function () {
      return getCurrent(self.getCurrent());
    };
    return self;
  };
  /**
   * Function that moves to the next item and returns true if there was a next item, otherwise false
   * @function
   * @returns {Boolean} True if moved to the next item, otherwise false
   */
  this.moveNext = function moveNextInternal() {
    index = index + 1;
    return moveNext(self);
  };
  /**
   * Function that moves to the next item and returns true if there was a next item, otherwise false
   * @function
   * @returns {Boolean} True if moved to the next item, otherwise false
   */
  this.reset = function resetInternal() {
    index = 0;
    return reset(self);
  };
}
function Enumerator ( getCurrent , moveNext , reset ) { var index = 0 , self = this ; /**
   * Get the current index of the enumerator
   */ this . getIndex = function getIndexEnumeratorInternal ( ) { return index ; } ; /**
   * Function that retrieves the current value
   * @function
   * @returns {Object} The current item
   */ this . getCurrent = function getCurrentInternal ( ) { return getCurrent ( self ) ; } ; this . overrideGetCurrent = function overrideGetCurrentInternal ( getCurrent ) { self . getCurrent = function ( ) { return getCurrent ( self . getCurrent ( ) ) ; } ; return self ; } ; /**
   * Function that moves to the next item and returns true if there was a next item, otherwise false
   * @function
   * @returns {Boolean} True if moved to the next item, otherwise false
   */ this . moveNext = function moveNextInternal ( ) { index = index + 1 ; return moveNext ( self ) ; } ; /**
   * Function that moves to the next item and returns true if there was a next item, otherwise false
   * @function
   * @returns {Boolean} True if moved to the next item, otherwise false
   */ this . reset = function resetInternal ( ) { index = 0 ; return reset ( self ) ; } ; }
The Enumerator base class
@class Enumerator
@param {Function} getCurrent Function that retrieves the current value
@param {Function} moveNext Function that moves to the next item and returns true if there was a next item, otherwise false
@param {Function} reset Function that resets the enumerator to the beginning of the enumerable
The Enumerator base class