import * as generic from './GenericTagTypes' ; import { ITag } from '../type' ; import { INativeMetadataCollector , IWarningCollector } from './MetadataCollector' ; export interface IGenericTagMapper { /**
     * Which tagType it able to map to the generic mapping format
     */ tagTypes : generic . TagType [ ] ; /**
     * Basic tag map
     */ tagMap : generic . INativeTagMap ; param tag param warnings return mapGenericTag ( tag , warnings ) : generic . IGenericTag ; } export class CommonTagMapper implements IGenericTagMapper { public static maxRatingScore = 1 ; public static toIntOrNull ( str ) { const cleaned = parseInt ( str , 10 ) ; return isNaN ( cleaned ) ? null : cleaned ; } public static normalizeTrack ( origVal ) { const split = origVal . toString ( ) . split ( '/' ) ; return { no : parseInt ( split [ 0 ] , 10 ) || null , of : parseInt ( split [ 1 ] , 10 ) || null } ; } public constructor ( public tagTypes , public tagMap ) { } param tag param warnings return public mapGenericTag ( tag , warnings ) { tag = { id : tag . id , value : tag . value } ; this . postMap ( tag , warnings ) ; const id = this . getCommonName ( tag . id ) ; return id ? { id , value : tag . value } : null ; } tag return protected getCommonName ( tag ) { return this . tagMap [ tag ] ; } param { string } tag param { warnings } Used protected postMap ( tag , warnings ) { return ; } }