dist/entt.js
function getClassProperties(classes) {
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
      extensionsManager = _ref.extensionsManager;

  // Define checks for shorthand casting configurations
  var isPropertyShorthandCastAsSingleEntity = function isPropertyShorthandCastAsSingleEntity(propertyConfiguration) {
    if (propertyConfiguration
    // Check if class extending EnTT
    && propertyConfiguration.prototype instanceof EnTT) {
      return propertyConfiguration;
    }
  };
  var isPropertyShorthandCastAsEntityArray = function isPropertyShorthandCastAsEntityArray(propertyConfiguration) {
    if (propertyConfiguration
    // Check if array
    && _lodash2.default.isArray(propertyConfiguration)
    // Check if array has a single member
    && propertyConfiguration.length === 1
    // Check if single array memeber is a class extending EnTT
    && propertyConfiguration[0].prototype instanceof EnTT) {
      return propertyConfiguration[0];
    }
  };
  var isPropertyShorthandCastAsEntityHashmap = function isPropertyShorthandCastAsEntityHashmap(propertyConfiguration) {
    if (propertyConfiguration
    // Check if object
    && _lodash2.default.isObject(propertyConfiguration)
    // Check if object has a single member
    && _lodash2.default.values(propertyConfiguration).length
    // Check if single object member is a class extending EnTT
    && _lodash2.default.values(propertyConfiguration)[0].prototype instanceof EnTT
    // Check if single object member's property key equals class name
    && _lodash2.default.keys(propertyConfiguration)[0] === _lodash2.default.values(propertyConfiguration)[0].name) {
      return _lodash2.default.values(propertyConfiguration)[0];
    }
  };

  // Extract property definitions from all inherited classes' static ".props" property
  var properties = _lodash2.default.reduceRight(classes, function (properties, current) {

    // Extract currentProperties
    var currentProperties = current.props,
        CastClass = void 0;

    // Edit short-hand configuration syntax where possible
    _lodash2.default.forEach(currentProperties, function (propertyConfiguration, propertyName) {

      // Replace "casting properties" short-hand configuration syntax for single entity
      CastClass = isPropertyShorthandCastAsSingleEntity(propertyConfiguration);
      if (CastClass) {
        // Replace shorthand cast-as-single-entity syntax
        currentProperties[propertyName] = { cast: propertyConfiguration };
        return;
      }
      // Replace "casting properties" short-hand configuration syntax for entity array
      CastClass = isPropertyShorthandCastAsEntityArray(propertyConfiguration);
      if (CastClass) {
        // Replace shorthand cast-as-entity-array syntax
        currentProperties[propertyName] = { cast: [CastClass] };
        return;
      }
      // Replace "casting properties" short-hand configuration syntax for entity array
      CastClass = isPropertyShorthandCastAsEntityHashmap(propertyConfiguration);
      if (CastClass) {
        // Replace shorthand cast-as-entity-hashmap syntax
        currentProperties[propertyName] = { cast: _defineProperty({}, new CastClass().constructor.name, CastClass) };
        return;
      }

      // EXTENSIONS HOOK: .processShorthandPropertyConfiguration(...)
      // Lets extensions process short-hand property configuration
      currentProperties[propertyName] = extensionsManager.processShorthandPropertyConfiguration(propertyConfiguration);
    });

    // Merge with existing properties
    return _lodash2.default.merge(properties, currentProperties || {});
  }, {});

  // Update property configuration with default configuration values
  _lodash2.default.forEach(properties, function (propertyConfiguration, key) {
    properties[key] = _lodash2.default.merge({}, EnTT.default, propertyConfiguration);
  });

  // Return extracted properties
  return properties;
}
function getClassProperties(classes) {
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
      extensionsManager = _ref.extensionsManager;

  // Define checks for shorthand casting configurations
  var isPropertyShorthandCastAsSingleEntity = function isPropertyShorthandCastAsSingleEntity(propertyConfiguration) {
    if (propertyConfiguration
    // Check if class extending EnTT
    && propertyConfiguration.prototype instanceof EnTT) {
      return propertyConfiguration;
    }
  };
  var isPropertyShorthandCastAsEntityArray = function isPropertyShorthandCastAsEntityArray(propertyConfiguration) {
    if (propertyConfiguration
    // Check if array
    && _lodash2.default.isArray(propertyConfiguration)
    // Check if array has a single member
    && propertyConfiguration.length === 1
    // Check if single array memeber is a class extending EnTT
    && propertyConfiguration[0].prototype instanceof EnTT) {
      return propertyConfiguration[0];
    }
  };
  var isPropertyShorthandCastAsEntityHashmap = function isPropertyShorthandCastAsEntityHashmap(propertyConfiguration) {
    if (propertyConfiguration
    // Check if object
    && _lodash2.default.isObject(propertyConfiguration)
    // Check if object has a single member
    && _lodash2.default.values(propertyConfiguration).length
    // Check if single object member is a class extending EnTT
    && _lodash2.default.values(propertyConfiguration)[0].prototype instanceof EnTT
    // Check if single object member's property key equals class name
    && _lodash2.default.keys(propertyConfiguration)[0] === _lodash2.default.values(propertyConfiguration)[0].name) {
      return _lodash2.default.values(propertyConfiguration)[0];
    }
  };

  // Extract property definitions from all inherited classes' static ".props" property
  var properties = _lodash2.default.reduceRight(classes, function (properties, current) {

    // Extract currentProperties
    var currentProperties = current.props,
        CastClass = void 0;

    // Edit short-hand configuration syntax where possible
    _lodash2.default.forEach(currentProperties, function (propertyConfiguration, propertyName) {

      // Replace "casting properties" short-hand configuration syntax for single entity
      CastClass = isPropertyShorthandCastAsSingleEntity(propertyConfiguration);
      if (CastClass) {
        // Replace shorthand cast-as-single-entity syntax
        currentProperties[propertyName] = { cast: propertyConfiguration };
        return;
      }
      // Replace "casting properties" short-hand configuration syntax for entity array
      CastClass = isPropertyShorthandCastAsEntityArray(propertyConfiguration);
      if (CastClass) {
        // Replace shorthand cast-as-entity-array syntax
        currentProperties[propertyName] = { cast: [CastClass] };
        return;
      }
      // Replace "casting properties" short-hand configuration syntax for entity array
      CastClass = isPropertyShorthandCastAsEntityHashmap(propertyConfiguration);
      if (CastClass) {
        // Replace shorthand cast-as-entity-hashmap syntax
        currentProperties[propertyName] = { cast: _defineProperty({}, new CastClass().constructor.name, CastClass) };
        return;
      }

      // EXTENSIONS HOOK: .processShorthandPropertyConfiguration(...)
      // Lets extensions process short-hand property configuration
      currentProperties[propertyName] = extensionsManager.processShorthandPropertyConfiguration(propertyConfiguration);
    });

    // Merge with existing properties
    return _lodash2.default.merge(properties, currentProperties || {});
  }, {});

  // Update property configuration with default configuration values
  _lodash2.default.forEach(properties, function (propertyConfiguration, key) {
    properties[key] = _lodash2.default.merge({}, EnTT.default, propertyConfiguration);
  });

  // Return extracted properties
  return properties;
}
function getClassProperties ( classes ) { var _ref = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } , extensionsManager = _ref . extensionsManager ; // Define checks for shorthand casting configurations var isPropertyShorthandCastAsSingleEntity = function isPropertyShorthandCastAsSingleEntity ( propertyConfiguration ) { if ( propertyConfiguration // Check if class extending EnTT && propertyConfiguration . prototype instanceof EnTT ) { return propertyConfiguration ; } } ; var isPropertyShorthandCastAsEntityArray = function isPropertyShorthandCastAsEntityArray ( propertyConfiguration ) { if ( propertyConfiguration // Check if array && _lodash2 . default . isArray ( propertyConfiguration ) // Check if array has a single member && propertyConfiguration . length === 1 // Check if single array memeber is a class extending EnTT && propertyConfiguration [ 0 ] . prototype instanceof EnTT ) { return propertyConfiguration [ 0 ] ; } } ; var isPropertyShorthandCastAsEntityHashmap = function isPropertyShorthandCastAsEntityHashmap ( propertyConfiguration ) { if ( propertyConfiguration // Check if object && _lodash2 . default . isObject ( propertyConfiguration ) // Check if object has a single member && _lodash2 . default . values ( propertyConfiguration ) . length // Check if single object member is a class extending EnTT && _lodash2 . default . values ( propertyConfiguration ) [ 0 ] . prototype instanceof EnTT // Check if single object member's property key equals class name && _lodash2 . default . keys ( propertyConfiguration ) [ 0 ] === _lodash2 . default . values ( propertyConfiguration ) [ 0 ] . name ) { return _lodash2 . default . values ( propertyConfiguration ) [ 0 ] ; } } ; // Extract property definitions from all inherited classes' static ".props" property var properties = _lodash2 . default . reduceRight ( classes , function ( properties , current ) { // Extract currentProperties var currentProperties = current . props , CastClass = void 0 ; // Edit short-hand configuration syntax where possible _lodash2 . default . forEach ( currentProperties , function ( propertyConfiguration , propertyName ) { // Replace "casting properties" short-hand configuration syntax for single entity CastClass = isPropertyShorthandCastAsSingleEntity ( propertyConfiguration ) ; if ( CastClass ) { // Replace shorthand cast-as-single-entity syntax currentProperties [ propertyName ] = { cast : propertyConfiguration } ; return ; } // Replace "casting properties" short-hand configuration syntax for entity array CastClass = isPropertyShorthandCastAsEntityArray ( propertyConfiguration ) ; if ( CastClass ) { // Replace shorthand cast-as-entity-array syntax currentProperties [ propertyName ] = { cast : [ CastClass ] } ; return ; } // Replace "casting properties" short-hand configuration syntax for entity array CastClass = isPropertyShorthandCastAsEntityHashmap ( propertyConfiguration ) ; if ( CastClass ) { // Replace shorthand cast-as-entity-hashmap syntax currentProperties [ propertyName ] = { cast : _defineProperty ( { } , new CastClass ( ) . constructor . name , CastClass ) } ; return ; } // EXTENSIONS HOOK: .processShorthandPropertyConfiguration(...) // Lets extensions process short-hand property configuration currentProperties [ propertyName ] = extensionsManager . processShorthandPropertyConfiguration ( propertyConfiguration ) ; } ) ; // Merge with existing properties return _lodash2 . default . merge ( properties , currentProperties || { } ) ; } , { } ) ; // Update property configuration with default configuration values _lodash2 . default . forEach ( properties , function ( propertyConfiguration , key ) { properties [ key ] = _lodash2 . default . merge ( { } , EnTT . default , propertyConfiguration ) ; } ) ; // Return extracted properties return properties ; }
Gets class properties configuration by traversing and merging static ".props" property of the instance's class and all it's inherited classes
@param {any} classes Array of inherited from classes
@param {any} extensionsManager Extensions manager
@returns {any} Property configuration for all class' properties
Gets class properties configuration by traversing and merging static . props property of the instance s class and all it s inherited classes