import ParseHelper = require ( './parse-helper' ) ; import Parser = require ( './parser' ) ; param source const withoutBOMmark = ( source ) => { return source . charCodeAt ( 0 ) === 0xFEFF ? '\n' + source . slice ( 1 ) : source ; } ; param parser param source param helper const parseChunks = function _parseChunks ( parser , source , helper ) { const re = parser . getRegex ( ) ; let match = re . exec ( withoutBOMmark ( source ) ) ; const changes = ! ! match ; while ( match ) { helper . flushPrev ( match . index ) ; re . lastIndex = helper . flushLine ( match . index , re . lastIndex , parser . parse ( match ) ) ; match = re . exec ( source ) ; } parser . close ( ) ; return helper . flush ( ) || changes ; } ; export = parseChunks ;