const getEntities = async (blockHash: Hash): Promise> => { let nrEntities: number = await getNextEntity(this.api, blockHash); let entities = new Map(); for (let i = 0; i < nrEntities; ++i) { const entity: Entity = await getEntity(this.api, blockHash, i); entities.set(i, entity); } return entities; }; export const computeUsedSpaceInMbs = async ( contentIds: Vec ): Promise => { let space = 0; for (let contentId of contentIds) { const dataObject: Option = await getDataObject( this.api, contentId ); space += dataObject.unwrap().size_in_bytes.toNumber(); } return space / 1024 / 1024; }; export const parseVideos = async ( entities: Map ): Promise => { let videos: Media[] = []; for (let [key, entity] of entities) { if (entity.class_id.toNumber() != VIDEO_CLASS_iD || entity.values.isEmpty) continue; let values = Array.from(entity.getField("values").entries()); if (values.length < 2 || values[2].length < 1) continue; let title = values[2][1].getValue().toString(); videos.push(new Media(key, title)); } return videos; }; const parseChannels = async ( entities: Map ): Promise => { let channels: Channel[] = []; for (let [key, entity] of entities) { if ( entity.class_id.toNumber() != CHANNEL_CLASS_iD || entity.values.isEmpty ) { continue; } let values = Array.from(entity.getField("values").entries()); let title = values[0][1].getValue().toString(); channels.push(new Channel(key, title)); } return channels; };