import { _ } from 'streamline-runtime' ; import { Reader } from '../reader' ; import { Writer } from '../writer' ; import * as generic from './generic' ; export interface Duplex < T > { reader : Reader < T > ; writer : Writer < T > ; } export function create < T > ( max ? ) { const queue = _ . queue ( max ) ; queue . reader = generic . reader ( queue . read . bind ( queue ) , function ( _ ) { queue . end . call ( queue ) ; } ) ; queue . writer = generic . writer ( queue . write . bind ( queue ) ) ; return queue ; }