import { DefinitionExtraFieldParser } from '@ulangi/ulangi-common/core' ; import { WordClass } from '@ulangi/ulangi-common/enums' ; import { config } from '../../constants/config' ; export class DefinitionDelegate { private definitionExtraFieldParser = new DefinitionExtraFieldParser ( ) ; public hasCustomWordClasses ( meaning ) { return ( this . definitionExtraFieldParser . parse ( meaning ) . extraFields . wordClass . length > 0 ) ; } public prependBuiltInWordClassesToMeaning ( meaning , wordClasses ) { if ( ! this . hasCustomWordClasses ( meaning ) && wordClasses . length > 0 ) { const wordClassesInString = wordClasses . map ( ( wordClass ) : string => { return '[' + config . builtInWordClass . map [ wordClass ] . abbr + ']' ; } ) . join ( ' ' ) ; return wordClassesInString + ' ' + meaning ; } else { return meaning ; } } }