import * as streams from '../node-wrappers' ; import { Reader } from '../reader' ; require ( '../reader' ) . decorate ( streams . ReadableStream . prototype ) ; require ( '../writer' ) . decorate ( streams . WritableStream . prototype ) ; export interface NodeReaderOptions { encoding ? : string ; } export function fixOptions ( options ) { var opts ; if ( typeof options === "string" ) { opts = { encoding : options , } ; } else { opts = options || { } ; } return opts ; } export function reader ( emitter , options ? ) { var opts = fixOptions ( options ) ; const reader = new streams . ReadableStream ( emitter , opts ) ; if ( opts . encoding ) reader . setEncoding ( opts . encoding ) ; return reader . reader ; } export interface NodeWriterOptions { } ; export function writer ( emitter , options ? ) { const writer = new streams . WritableStream ( emitter , fixOptions ( options ) ) ; return writer . writer ; }