var nsq = require("nsqjs"),
    Readable = require("stream").Readable,
    util = require("util");

function ReaderStream(topic, channel, options) {

    if (!(this instanceof ReaderStream)) {
        return new ReaderStream(topic, channel, options);
    }

    Readable.call(this, { objectMode: true });

    var self = this;

    self.buffer = [];
    self.reader = new nsq.Reader(topic, channel, options);

    self.reader.on("discard", function (message) {
        self.emit("discard", message);
    });

    self.reader.on("error", function (error) {
        self.emit("error", error);
    });

    self.reader.on("message", function (message) {
        if (!self.push(message.body)) {
            self.buffer.push(message.body);
        }
        message.finish();
        self.read(0);
    });

    self.reader.on("nsqd_connected", function (host, port) {
        self.emit("nsqd_connected", host, port);
    });

    self.reader.on("nsqd_closed", function (host, port) {
        self.emit("nsqd_closed", host, port);
    });

    self.reader.connect();
}

util.inherits(ReaderStream, Readable);

/*jslint unparam:true*/
ReaderStream.prototype._read = function (size) {
    var buffer = this.buffer,
        index = 0;

    while (index < buffer.length && this.push(buffer[index])) {
        index += 1;
    }

    if (index < buffer.length) {
        this.buffer = this.buffer.slice(index);
    }
};
/*jslint unparam:false*/

ReaderStream.prototype.close = function () {
    this.reader.close();
}

module.exports = ReaderStream;


@@ -141,16 +141,34 @@
 tions) %7B
+%0A    %22use strict%22;
 %0A%0A    if
@@ -1119,32 +1119,8 @@
 );%0A%0A
-/*jslint unparam:true*/%0A
 Read
@@ -1160,24 +1160,43 @@
 on (size) %7B%0A
+    %22use strict%22;%0A%0A
     var buff
@@ -1417,33 +1417,8 @@
 %7D%0A%7D;
-%0A/*jslint unparam:false*/
 %0A%0ARe
@@ -1456,24 +1456,43 @@
 nction () %7B%0A
+    %22use strict%22;%0A%0A
     this.rea
@@ -1507,16 +1507,16 @@
 e();%0A%7D%0A%0A
+
 module.e
@@ -1538,9 +1538,8 @@
 Stream;%0A
-%0A

Remove jslint directives, use strict for functions