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?
The ES5 method lets you find the prototype.
Object.getPrototypeOf(s) === stream.Stream
There is a similar utility method called .isPrototypeOf
stream.Stream.isPrototypeOf(s)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.