@dasch-swiss/dsp-js
Version:
TypeScript client library for DSP-API
31 lines • 1.05 kB
JavaScript
import { TypeGuard } from '../resources/type-guard';
/**
* @category Internal
*/
export class ClassAndPropertyDefinitions {
/**
* Given a map of entity Iris to entity definitions,
* returns an array of entity definitions.
*
* @param entityDefs Entity definitions to be returned as an array.
*/
getAllEntityDefinitionsAsArray(entityDefs) {
const entityIndexes = Object.keys(entityDefs);
return entityIndexes.map((entityIndex) => {
return entityDefs[entityIndex];
});
}
/**
* Given an array of entity definitions,
* returns only the entity definitions matching the given type.
*
* @param entityDefs The entity definitions to be filtered.
* @param type The type of entity definitions to be returned.
*/
getEntityDefinitionsByTypeAsArray(entityDefs, type) {
return entityDefs.filter((entityDef) => {
return TypeGuard.typeGuard(entityDef, type);
});
}
}
//# sourceMappingURL=ClassAndPropertyDefinitions.js.map