I would like to prototype an object but the problem is, I don’t know how to address the object before I use it.
??????.prototype.writeObj = function( obj ) {
this.write( JSON.stringify(obj) );
}
tls.createServer(options, function (s) {
s.writeObj( {command:'addjob', options:{} } );
}
The important thing for me here is to find out how to go about finding this out, if that makes sense. I’ve tried reading the node documentation, but it does….oh hang on a sec.
I will continue anyway, turns out ????? is stream.Stream. Without reading the manual sic, is there an easy way to find this out in code?
Object.getPrototypeOfThe ES5 method lets you find the prototype.
Object.getPrototypeOf(s) === stream.StreamThere is a similar utility method called
.isPrototypeOfstream.Stream.isPrototypeOf(s)