Initial commit
[yaffs-website] / node_modules / fstream / lib / socket-reader.js
1 // Just get the stats, and then don't do anything.
2 // You can't really "read" from a socket.  You "connect" to it.
3 // Mostly, this is here so that reading a dir with a socket in it
4 // doesn't blow up.
5
6 module.exports = SocketReader
7
8 var inherits = require('inherits')
9 var Reader = require('./reader.js')
10
11 inherits(SocketReader, Reader)
12
13 function SocketReader (props) {
14   var self = this
15   if (!(self instanceof SocketReader)) {
16     throw new Error('SocketReader must be called as constructor.')
17   }
18
19   if (!(props.type === 'Socket' && props.Socket)) {
20     throw new Error('Non-socket type ' + props.type)
21   }
22
23   Reader.call(self, props)
24 }
25
26 SocketReader.prototype._read = function () {
27   var self = this
28   if (self._paused) return
29   // basically just a no-op, since we got all the info we have
30   // from the _stat method
31   if (!self._ended) {
32     self.emit('end')
33     self.emit('close')
34     self._ended = true
35   }
36 }