Hey I made a module in nodejs that is supposed to get an integer array( okay var array) as input. The module will perform an algorithm on the array and it is supposed to stream the output data as output. I did not want to implement a transform stream since the data must be fully recieved in order for the processing to begin.
The problem is that while the modules are loaded. i am not getting a ready event.
The module code is shown below
var Readable = require('stream').Readable;
var EventEmitter = require('events').EventEmitter;
var util = require('util');
util.inherits(interpolation, Readable);
module.exports = new EventEmitter();
function interpolation (opt){
if (!(this instanceof interpolation))
return new interpolation;
Readable.call(this,opt);
};
interpolation.prototype._read = function(chuck){
//The byte array and the vareger arrays are initialised here
console.log("Printing the data\n");
var copy = chunk;
var test = [];
...
...
...
...
...
...
console.log('Hey.. about to start exporing\n');
module.exports.emit('ready');
this.push(address_array);
this.end();
};
module.exports.process = interpolation;
The part where I call the module is shown below
result = conv.process();
result.on('ready',function(res){
broadcast(res,sock);
wstream.pipe(res);
buffer=[];
});