// Copyright Node.js contributors. All rights reserved. MIT License.importtypeDuplexfrom"./duplex.ts";importtypeReadablefrom"./readable.ts";importtypeStreamfrom"./stream.ts";importtypeWritablefrom"./writable.ts"; //This whole module acts as a 'normalizer'//Idea behind it is you can pass any kind of streams and functions will execute anyways //TODO(Soremwar)//Should be any implementation of stream//This is a guard to check executed methods exist inside the implementationtypeStreamImplementations=Duplex|Readable|Writable; // TODO(Soremwar)// Bring back once requests are implemented// function isRequest(stream: any) {// return stream && stream.setHeader && typeof stream.abort === "function";// } exportfunctiondestroyer(stream:Stream, err?:Error|null){// TODO(Soremwar)// Bring back once requests are implemented// if (isRequest(stream)) return stream.abort();// if (isRequest(stream.req)) return stream.req.abort();if(typeof(stream asStreamImplementations).destroy==="function"){return(stream asStreamImplementations).destroy(err);}// A test of async iterator mocks an upcoming implementation of stream// his is casted to any in the meanwhile// deno-lint-ignore no-explicit-anyif(typeof(stream asany).close==="function"){// deno-lint-ignore no-explicit-anyreturn(stream asany).close();}}