export class ContentManager { private imports : string [ ] = [ ] ; private importsMap : { [ key ] : boolean ; } = { } ; private content : string [ ] = [ ] ; private contentMap : { [ key ] : boolean ; } = { } ; public addImport ( importString , customKey ? ) { const hash = customKey || this . makeHash ( importString ) ; if ( ! this . importsMap [ hash ] ) { this . importsMap [ hash ] = true ; this . imports . push ( importString ) ; } } public addContent ( contentString , customKey ? ) { const hash = customKey || this . makeHash ( contentString ) ; if ( ! this . contentMap [ hash ] ) { this . contentMap [ hash ] = true ; this . content . push ( contentString ) ; } } public generateImportArray ( ) { return this . imports ; } public createContentString ( ) { return this . content . join ( "\n" ) ; } private makeHash ( input ) { var hash = 0 , i , chr ; if ( input . length === 0 ) return hash ; for ( i = 0 ; i < input . length ; i ++ ) { chr = input . charCodeAt ( i ) ; hash = ( hash << 5 ) - hash + chr ; hash |= 0 ; } return hash ; } }