src/entity.js
/*
 * Register entity types.
 *
 * category: The category name, or null.
 * types: Mapping from type names to types
 */
Register entity types.
category: The category name, or null.
types: Mapping from type names to types
Register entity types . category : The category name or null . types : Mapping from type names to types
function registerTypes(types, category) {
	var prefix = category ? category + '.' : '';
	_.forOwn(types, function(value, key) {
		var inh = value.inherit, i;
		if (inh) {
			for (i = 0; i < inh.length; i++) {
				_.defaults(value, inh[i]);
			}
			delete value.inherit;
		}
		var tname = prefix + key;
		if (Types.hasOwnProperty(tname)) {
			console.error('Duplicate type registered: ' + tname);
			return;
		}
		Types[tname] = value;
	});
}
function registerTypes ( types , category ) { var prefix = category ? category + '.' : '' ; _ . forOwn ( types , function ( value , key ) { var inh = value . inherit , i ; if ( inh ) { for ( i = 0 ; i < inh . length ; i ++ ) { _ . defaults ( value , inh [ i ] ) ; } delete value . inherit ; } var tname = prefix + key ; if ( Types . hasOwnProperty ( tname ) ) { console . error ( 'Duplicate type registered: ' + tname ) ; return ; } Types [ tname ] = value ; } ) ; }
Register entity types.
Register entity types .