dist/axis3d.js
/**
 * Flatten and filter compoments into a single array.
 *
 * flattenComponents(components: [...Function|[Function]) -> [...Function]
 */
Flatten and filter compoments into a single array.
Flatten and filter compoments into a single array .
function flattenComponents() {
  for (var _len3 = arguments.length, components = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
    components[_key3 - 1] = arguments[_key3];
  }
  var initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  components = Array.isArray(components[0]) ? components[0] : components;
  return {
    initialState: initialState,
    components: components.filter(filter).map(map).reduce(reduce, [])
  };
  function filter(component) {
    return 'function' == typeof component;
  }
  function map(component) {
    if ('entityId' in component && Array.isArray(component.components)) {
      if (component.initialState && 'object' == _typeof(component.initialState)) {
        (0, _extend2.default)(true, initialState, component.initialState);
      }
      return flattenComponents(initialState, component.components).components;
    } else {
      return component;
    }
  }
  function reduce(components, component) {
    return components.concat(component);
  }
}
function flattenComponents ( ) { for ( var _len3 = arguments . length , components = Array ( _len3 > 1 ? _len3 - 1 : 0 ) , _key3 = 1 ; _key3 < _len3 ; _key3 ++ ) { components [ _key3 - 1 ] = arguments [ _key3 ] ; } var initialState = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ; components = Array . isArray ( components [ 0 ] ) ? components [ 0 ] : components ; return { initialState : initialState , components : components . filter ( filter ) . map ( map ) . reduce ( reduce , [ ] ) } ; function filter ( component ) { return 'function' == typeof component ; } function map ( component ) { if ( 'entityId' in component && Array . isArray ( component . components ) ) { if ( component . initialState && 'object' == _typeof ( component . initialState ) ) { ( 0 , _extend2 . default ) ( true , initialState , component . initialState ) ; } return flattenComponents ( initialState , component . components ) . components ; } else { return component ; } } function reduce ( components , component ) { return components . concat ( component ) ; } }
Flatten and filter compoments into a single array.
Flatten and filter compoments into a single array .