Feature-detect "use regular streams as an underlying socket for tls.connect()" #981
Closed
Description
Hi, I'm looking for a good solution to be able to detect if this feature exists in the runtime my module is running on so I can throw if it's not supported. It was suggested on IRC to make an issue here.
I originally thought perhaps if I just construct a duplex stream and pass it into tls.connect
, but it doesn't seem to throw an error on pre-1.4.1 versions. Suggestions?
// This doesn't seem to work
var supportswrappedjsstreams = (function(){
var s = require("stream").Duplex();s._read=s._write=function(){};
try { require("tls").connect({ stream: s }); return true; } catch { return false; }
});
// This does work, but not sure if this is going to suddenly break in the future
var supportswrappedjsstreams = (function(){
try { require("_stream_wrap"); return true; } catch { return false; }
});