The Enumerable base class
@class Enumerable
@param {Array|Enumerable|crafity.Enumerable|Enumerator} object The enumerable source to wrap
335667
function Enumerable(object) {
  var self = this,
    enumeratorFactory = Enumerator.enumeratorFactories[crafity.getType(object)];

  if (enumeratorFactory === undefined) {
    throw ("There is no Enumerator for an object of type '" + crafity.getType(object) + "'");
  }

  /**
   * An enumerable object
   */
  this.getObject = function internalGetObject() {
    return object;
  };

  this.overrideEnumerator = function overrideEnumeratorInternal(getEnumerator) {
    self.getEnumerator = function getEnumeratorInternal() {
      return function () {
        return getEnumerator(self.getEnumerator());
      };
    };
    return self;
  };

  /**
   * Returns a function that gets an enumerator
   * @returns {Function} A function to get an enumerator
   */
  this.getEnumerator = function getEnumeratorInternal() {
    return enumeratorFactory.getEnumerator(self, object);
  };

  /**
   * Define a for each loop for an enumerable
   * @param {Function} consumer A yield function
   * @returns {Enumerable} A new enumerable containing the each logic
   */
  this.forEach = function forEachInternal(consumer) {
    return crafity.Enumerable.from(consumer);
  };
  /**
   * Selects or transforms an enumerable into a new enumerable
   * @param {Function} func A function that selects a value from an item
   * @returns {Enumerable} A new enumerable containing the select logic
   */
  this.select = function selectInternal(func) {
    //	return self.forEach(
    //		function forEachItem(value, yieldReturn) {
    //			yieldReturn(func(value));
    //		}
    //		);

    //	return new Enumerable(this).overrideEnumerator(function(enumerator) {
    //		return enumerator.overrideGetCurrent(function (current) {
    //			return func(current);
    //		});
    //	});
    var innerEnumerator = self.getEnumerator();
    return new Enumerable(
      new Enumerator(
        function getCurrentInternal() {
          return func(innerEnumerator.getCurrent());
        },
        function moveNextInternal() {
          return innerEnumerator.moveNext();
        },
        function resetInternal() {
          return innerEnumerator.reset();
        }
      )
    );
  };
  this.union = function unionInternal(enumerable) {
    var innerEnumerator = self.getEnumerator(),
      otherEnumerable,
      otherEnumerator,
      switched = false;
    return new crafity.Enumerable(
      new crafity.Enumerator(
        function getCurrentInternal() {
          return switched === false ? innerEnumerator.getCurrent() : otherEnumerator.getCurrent();
        },
        function moveNextInternal() {
          var result = false;
          if (switched === false) {
            result = innerEnumerator.moveNext();
            if (result === false) {
              if (otherEnumerable === undefined) {
                otherEnumerable = new crafity.Enumerable(enumerable);
              }
              otherEnumerator = otherEnumerable.getEnumerator();
              result = otherEnumerator.moveNext();
              switched = true;
            }
          } else {
            result = otherEnumerator.moveNext();
          }

          return result;
        },
        function resetInternal() {
          switched = false;
          return innerEnumerator.reset();
        }
      )
    );
  };
  this.selectMany = function selectManyInternal(func) {
    var innerEnumerator = self.getEnumerator()
      , childEnumerable, childEnumerator;

    return new crafity.Enumerable(
      new crafity.Enumerator(
        function getCurrentInternal() {
          return childEnumerator.getCurrent();
        },
        function moveNextInternal() {
          var movedNext = false, finished = false, childValue;

          if (childEnumerator !== undefined) {
            movedNext = childEnumerator.moveNext();
          }

          while (movedNext === false && finished === false) {
            childEnumerator = undefined;
            childEnumerable = undefined;
            finished = innerEnumerator.moveNext() === false;
            if (finished === false) {
              childValue = func(innerEnumerator.getCurrent());
              childEnumerable = new crafity.Enumerable(childValue);
              childEnumerator = childEnumerable.getEnumerator();
            }
            if (childEnumerator !== undefined) {
              movedNext = childEnumerator.moveNext();
            }
          }

          return movedNext;
        },
        function resetInternal() {
          childEnumerator = undefined;
          childEnumerable = undefined;
          return innerEnumerator.reset();
        }
      )
    );
  };
  this.recursive = function recursiveInternal(func) {
    var innerEnumerator = self.getEnumerator()
      , childEnumerable, childEnumerator;
    return new crafity.Enumerable(
      new crafity.Enumerator(
        function getCurrentInternal() {
          if (crafity.hasValue(childEnumerator)) {
            return childEnumerator.getCurrent();
          }
          return innerEnumerator.getCurrent();
        },
        function moveNextInternal() {
          var movedNext = false, finished = false;

          if (crafity.hasValue(childEnumerable) && crafity.hasNoValue(childEnumerator)) {
            childEnumerator = childEnumerable.getEnumerator();
          }

          if (crafity.hasValue(childEnumerator)) {
            movedNext = childEnumerator.moveNext();
          }

          if (movedNext === false && finished === false) {
            childEnumerator = undefined;
            childEnumerable = undefined;
            movedNext = innerEnumerator.moveNext();
            finished = !movedNext;
            if (finished === false) {
              var childValue = func(innerEnumerator.getCurrent());
              childEnumerable = new crafity.Enumerable(childValue).recursive(func);
            }
          }

          return movedNext;
        },
        function resetInternal() {
          childEnumerator = undefined;
          childEnumerable = undefined;
          return innerEnumerator.reset();
        }
      )
    );
  };
  /**
   * Where filters an enumerable by creating a new filtered enumerable
   * @param {Function} func A function that decides if a value is included
   * @returns {Enumerable} A new filtered enumerable
   */
  this.where = function whereInternal(func) {
    var innerEnumerator = self.getEnumerator();
    return new crafity.Enumerable(
      new crafity.Enumerator(
        function getCurrentInternal() {
          return innerEnumerator.getCurrent();
        },
        function moveNextInternal() {
          var moveNext = innerEnumerator.moveNext();
          while (moveNext && !func(innerEnumerator.getCurrent())) {
            moveNext = innerEnumerator.moveNext();
          }
          return moveNext;
        },
        function resetInternal() {
          return innerEnumerator.reset();
        }
      )
    );
  };
  /**
   * Take X number of items from the enumerable
   * @param {Number} number Number of items to take
   * @returns {Enumerable} A new enumerable containing the take logic
   */
  this.take = function takeInternal(number) {
    var innerEnumerator = self.getEnumerator();
    return new crafity.Enumerable(
      new crafity.Enumerator(
        function getCurrentInternal() {
          return innerEnumerator.getCurrent();
        },
        function moveNextInternal() {
          return innerEnumerator.getIndex() < number && innerEnumerator.moveNext();
        },
        function resetInternal() {
          return innerEnumerator.reset();
        }
      )
    );
  };
  /**
   * Skip X number of items in the enumerable
   * @param number Number of items to skip
   * @returns {Enumerable} A new enumerable containing the skip logic
   */
  this.skip = function skipInternal(number) {
    var innerEnumerator = self.getEnumerator();
    return new Enumerable(
      new Enumerator(
        function getCurrentInternal() {
          return innerEnumerator.getCurrent();
        },
        function moveNextInternal() {
          while (innerEnumerator.getIndex() < number && innerEnumerator.moveNext()) {
            innerEnumerator.__ = 1;
          }
          return innerEnumerator.moveNext();
        },
        function resetInternal() {
          return innerEnumerator.reset();
        }
      )
    );
  };
  /**
   * Loop thru all the items in an enumerable.
   * @param {Function} func This function will be called for every item
   */
  this.loop = function loopInternal(func) {
    var enumerator = self.getEnumerator();
    enumerator.reset();
    while (enumerator.moveNext()) {
      func(enumerator.getCurrent());
    }
  };
  /**
   * Aggregate an enumerable with a custom function
   * @param {Function} func A function containing the aggregagtion logic
   * @param {Object} seed The initial value to start the aggregation with
   * @returns {Object} The aggregated result
   */
  this.aggregate = function aggregateInternal(func, seed) {
    var result = seed;
    self.loop(function (value) {
      result = func(result, value);
    });
    return result;
  };
  /**
   * Collect all the values from an enumerable into an Array
   * @returns {Array} An array containing all the enumerable values
   */
  this.toArray = function toArrayInternal() {
    return self.aggregate(function (seed, value) {
      seed.push(value);
      return seed;
    }, []);
  };
  /**
   * Sum all the values in an enumerable
   * @returns {Number} The sum of the values
   */
  this.sum = function sumInternal() {
    return self.aggregate(function (seed, value) {
      return seed + value;
    }, 0);
  };
  /**
   * Count all the values in an enumerable
   * @returns {Number} The number of the values in the enumerable
   */
  this.count = function countInternal() {
    return self.aggregate(function (seed, value) {
      return seed + 1;
    }, 0);
  };

}
782880
function parseObject(object) {
  const children = Object.keys(object).map(key => ({
    keyTemplate: parseString(key),
    valueTemplate: parse(object[key])
  }));
  const templateParameters = children.reduce(
    (parameters, child) =>
      parameters.concat(child.valueTemplate.parameters, child.keyTemplate.parameters),
    []
  );
  const templateFn = context => {
    return children.reduce((newObject, child) => {
      newObject[child.keyTemplate(context)] = child.valueTemplate(context);
      return newObject;
    }, {});
  };

  return Template(templateFn, templateParameters);
}
634026
function encodePlainObject( encoder, object ) {

	// Extract plain object signature
	var o_keys =Object.keys(object);
		// signature = o_keys.join("+"),
	var sid = encoder.getSignatureID( o_keys );

	// Collect values of all properties
	var values = [];
	for (var i=0, len=o_keys.length; i<len; ++i)
		values.push( object[o_keys[i]] );

	encoder.log(LOG.PLO, "plain["+sid+"], signature="+o_keys.toString()+", sid="+sid);

	// Split entity ID in a 11-bit number
	var sid_hi = (sid & 0x700) >> 8,
		sid_lo =  sid & 0xFF;

	// We have a known entity ID, re-use it
	encoder.stream8.write( pack1b( PRIM_OP.OBJECT | OBJ_OP.PLAIN_LOOKUP | sid_hi ) );
	encoder.stream8.write( pack1b( sid_lo ) );
	encoder.counters.op_prm+=2;

	// Keep iref and encode
	encodeArray( encoder, values );

}
1233728
function Object_values(source) { // @arg Object|Function|Array
                                 // @ret ValueAnyArray [key, ... ]
    var keys = Object.keys(source);
    var i = 0, iz = keys.length;
    var result = new Array(iz);

    for (; i < iz; ++i) {
        result[i] = source[keys[i]];
    }
    return result;
}
460438
function mixinConstructor(source)
{
  var keys = Object.keys(source)
    , i    = keys.length
    ;

  while (i-- > 0) {
    this[keys[i]] = source[keys[i]];
  }
}
800633
public static <T extends Enum<T>> void enuum(String value, Object object, PropertyInterface property) {
		@SuppressWarnings("unchecked")
		Class<T> enumClass = (Class<T>) property.getClazz();
		List<Enum> values = (List<Enum>) EnumUtils.valueList(enumClass);
		for (Enum enumValue : values) {
			if (enumValue.name().equalsIgnoreCase(value)) {
				property.setValue(object, enumValue);
				return;
			}
		}
		Object createdEnum = InvalidValues.createInvalidEnum(enumClass, value);
		property.setValue(object, createdEnum);
	}
899938
function Enum(keys) {
  if (!(keys instanceof Array)) {
    throw new Error('Expected keys to be an array!');
  }

  const map = {};
  keys.forEach(key => {
    map[key] = key;
  });

  // ------------------------------------------------
  // Install an iterator that iterates over the
  // enum keys

  map[Symbol.iterator] = function() {
    let nextIndex = 0;

    const members = Object.values(map);

    return {
      next: function() {
        return nextIndex < keys.length ? {value: members[nextIndex++], done: false} : {done: true};
      },
    };
  };

  function testProperty(map, property) {
    if (!map[property]) {
      throw new Error(`Member '${property}' not found on the Enum.`);
    }
    return map[property];
  }

  const functions = {
    // ------------------------------------------------
    // Return an array of enums
    toArray: function() {
      return Object.values(map);
    },

    // ------------------------------------------------
    // Check if an enum key is valid
    isValid: function(key) {
      return map.hasOwnProperty(key);
    },

    // ------------------------------------------------
    // Enum to string
    toString: function() {
      return 'Enum{' + functions.toArray().join(', ') + '}';
    },
  };

  // ------------------------------------------------
  // Restrict reads and writes of properties to this
  // Enum object
  return new Proxy(map, {
    get: (target, property) => {
      if (functions[property]) {
        return functions[property];
      }
      return testProperty(map, property);
    },
    set: (target, property, value) => {
      throw new Error('Enum members may not be added.');
    },
  });
}
170248
function (object) {
		if (!object || object._bsontype)
			return object;

		if (_.isString(object))
			return object.replace(/\./g, "U+FF0E").replace(/\$/g, "U+FF04");

		var newObject = _.isArray(object) ? [ ] : { };

		Object.keys(object).forEach(function (key) {
			var sKey = key;
			
			if (/[.|$]/.test(key)) {
				sKey = mongojs.util.sanitise(key);
				newObject[sKey] = object[key];
			} else {
				newObject[key] = object[key];
			}
			
			// Recurse
			if (isObject(newObject[sKey]))
				newObject[sKey] = this.sanitise(newObject[sKey]);
		}.bind(this));
		
		return newObject;
	}
706093
function baseKeysIn(object) {
  if (!isObject_1(object)) {
    return _nativeKeysIn(object);
  }
  var isProto = _isPrototype(object),
      result = [];

  for (var key in object) {
    if (!(key == 'constructor' && (isProto || !hasOwnProperty$11.call(object, key)))) {
      result.push(key);
    }
  }
  return result;
}
961185
function isObjectObject(object) {
  return _.isObject(object) && !_.isArray(object) && !_.isFunction(object);
}
147603
function _enumKeys(it) {
	  var result = _objectKeys(it);
	  var getSymbols = _objectGops.f;
	  if (getSymbols) {
	    var symbols = getSymbols(it);
	    var isEnum = _objectPie.f;
	    var i = 0;
	    var key;
	    while (symbols.length > i) {
	      if (isEnum.call(it, key = symbols[i++])) result.push(key);
	    }
	  }return result;
	}
1090892
function (object) {
		var result = { };
	
		for (var i in object) {
			if (!object.hasOwnProperty(i)) continue;
			
			if (isObject(object[i])) {
				var flatObject = this.flatten(object[i]);
				for (var x in flatObject) {
					if (!flatObject.hasOwnProperty(x)) continue;
					
					result[i + '.' + x] = flatObject[x];
				}
			} else {
				result[i] = object[i];
			}
		}

		return result;
	}
505922
function Closure (parent, listOfKeys, accessor) {
  "use strict";

  var closure = {};

  listOfKeys = listOfKeys || [];
  accessor   = accessor || function () {};
  
  parent && parent.__mixin__ && parent.__mixin__(closure);

  listOfKeys.forEach(function (key) {
    closure[key] = accessor.bind(null, key);
  });

  this.getValues = function () {
    var values = {};
    Object.keys(closure).forEach(function (key) {
      values[key] = closure[key]();
      if (values[key] === undefined) {
        values[key] = null;
      }
      if (typeof values[key] === 'function') {
        throw new Error('a closure variable must be serializable, so you cannot use a function');
      }
    });
    return values;
  }

  this.setValues = function (values) {
    Object.keys(values).forEach(function (key) {
      closure[key](values[key]);
    });
  }

  this.__mixin__ = function (object) {
    Object.keys(closure).forEach(function (key) {
      object[key] = closure[key];
    });
  }

}
241206
function iterateOverObject(obj) {
  const props = keys(obj);
  const output = {};
  props.forEach(function iterateOverProps(prop) {
    const val = obj[prop];
    const type = typeof val;
    if (type === 'string' && BLACK_LIST_PROPS.indexOf(prop) === -1) {
      output[prop] = escape(val);
    } else if (type === 'object') {
      if (prop !== '#multi') {
        output[prop] = iterateOverObject(val);
      } else {
        output[prop] = val;
        val.match = escape(val.match);
      }
    } else {
      output[prop] = val;
    }
  });

  return output;
}
1030863
function baseAssignValue(object, key, value) {
  if (key == '__proto__') {
    Object.defineProperty(object, key, {
      'configurable': true,
      'enumerable': true,
      'value': value,
      'writable': true
    })
  } else {
    object[key] = value
  }
}
1012238
function (source, keyS, target, keyT) {
      var desc = Object.getOwnPropertyDescriptor(source, keyS);
      if (desc) {
        desc.enumerable = false;
        target[keyT] = desc;
      }
    }
1163215
function defineProp(obj, key, get) {
  Object.defineProperty(obj, key, { get, enumerable: true });
}