import { validateFullCitation , validateCitationID } from './validator' ; import { citationExtractionRE } from './regex' ; export param { string } file param { boolean } strict returns { string [ ] } export function extractCitations ( file , strict = false ) { let allCitations = [ ] ; let citation ; while ( ( citation = citationExtractionRE . exec ( file ) ) !== null ) { if ( citation [ 3 ] ) { if ( ! validateCitationID ( citation [ 3 ] , strict ) ) continue ; allCitations . push ( citation [ 3 ] ) ; } else if ( citation [ 1 ] ) { if ( ! validateFullCitation ( citation [ 1 ] ) ) continue ; allCitations . push ( citation [ 1 ] ) ; } } return allCitations ; }