import { Port } from "../ports/port" ; import * as Types from "../types" ; import { ReadyValue } from "./ready" ; import { CompleteStream } from "./streamComplete" ; import { StreamElement } from "./streamElement" ; import { StreamEnd } from "./streamEnd" ; export function fetchComplete ( port , type ) { const value = port . getData ( type ) ; if ( value instanceof StreamElement ) { const values = [ ] ; let lastValue = value ; let index = 0 ; while ( lastValue instanceof StreamElement ) { index += 1 ; values . push ( lastValue . value ) ; lastValue = port . getData ( type , index ) ; } return new CompleteStream ( values ) ; } return value ; }