I'm trying implement a stream which returns one symbol from file on each 'data' event. I finished with code bellow:
var util = require('util'),
    fs = require('fs'),
    Readable = require('stream').Readable;
var util = require('util');
var Readable = require('stream').Readable;
var SymbolReadStream = function(filename, options) {
  Readable.call(this);
  this._readable = fs.createReadStream(filename, options).pause();
  self = this;
  this._readable.on('readable', function() {
    var chunk;
    chunk = self._readable.read(1);
    // I believe the problem is here
    self._readable.pause();
  });
};
util.inherits(SymbolReadStream, Readable); // inherit the prototype methods
SymbolReadStream.prototype._read = function() {
  this._readable.resume();
};
var r = new SymbolReadStream("test.txt", {
  encoding: 'utf8',
});
r.on('data', function(el) {
  console.log(el);
});
but this code doesn't work. Please help. Is there an easier way to achieve the behavior?
 
     
     
    