license import { Analysis , Document , ParsedHtmlDocument , ParsedJavaScriptDocument } from 'polymer-analyzer' ; export function getAnalysisDocument ( analysis , url ) { const result = analysis . getDocument ( url ) ; if ( result . successful ) { return result . value ; } if ( result . error ) { const message = `Unable to get document ${ url }: ${ result . error . message }` ; throw new Error ( message ) ; } throw new Error ( `Unable to get document ${ url }` ) ; } export function assertIsHtmlDocument ( doc ) { if ( doc . kinds . has ( 'html-document' ) ) { return doc as Document < ParsedHtmlDocument > ; } else { throw new Error ( `Document wasn't an HTML document, it's a: ${ [ ... doc . kinds ] }` ) ; } } export function assertIsJsDocument ( doc ) { if ( doc . kinds . has ( 'js-document' ) ) { return doc as Document < ParsedJavaScriptDocument > ; } else { throw new Error ( `Document wasn't an JS document, it's a: ${ [ ... doc . kinds ] }` ) ; } }