electron-johnny-five-examples icon indicating copy to clipboard operation
electron-johnny-five-examples copied to clipboard

Hook in our stream

Open eMarek opened this issue 7 years ago • 0 comments

May I ask what does this part of code do: https://github.com/sofroniewn/electron-johnny-five-examples/blob/master/2-switch/app/index.js#L5-L15

var Readable = require('stream').Readable  
var util = require('util')  

util.inherits(MyStream, Readable)  
function MyStream(opt) {  
  Readable.call(this, opt)
}
MyStream.prototype._read = function() {};  
// hook in our stream
process.__defineGetter__('stdin', function() {  
  if (process.__stdin) return process.__stdin
  process.__stdin = new MyStream()
  return process.__stdin
})

eMarek avatar Feb 17 '19 22:02 eMarek