import { Readable } from 'stream' ; import * as messages from '@cucumber/messages' ; import { GherkinStreams } from '@cucumber/gherkin-streams' ; export function gherkinMessages ( gherkinSource , uri ) { const source = { source : { uri , data : gherkinSource , mediaType : messages . SourceMediaType . TEXT_X_CUCUMBER_GHERKIN_PLAIN , } , } ; return GherkinStreams . fromSources ( [ source ] , { newId : messages . IdGenerator . uuid ( ) , } ) ; } export async function streamToArray ( readableStream ) { return new Promise < messages . Envelope [ ] > ( ( resolve , reject ) => { const items = [ ] ; readableStream . on ( 'data' , items . push . bind ( items ) ) ; readableStream . on ( 'error' , reject ) ; readableStream . on ( 'end' , ( ) => resolve ( items ) ) ; } ) ; }