Fix comparison operators

This commit is contained in:
Valery De Smedt 2015-03-26 18:30:47 +01:00
parent 772492aa3d
commit d01e9a2ea1
2 changed files with 8 additions and 8 deletions

View file

@ -51,9 +51,9 @@ module.exports = {
return function (emitter, buffer) {
for (var i = 0; i < buffer.length; i++) {
buf[buf.length] = buffer[i];
if(buf[buf.length-1] == delimiter[nextDelimIndex])
if(buf[buf.length-1] === delimiter[nextDelimIndex])
nextDelimIndex++;
if(nextDelimIndex == delimiter.length) {
if(nextDelimIndex === delimiter.length) {
emitter.emit('data', buf);
buf = [];
nextDelimIndex = 0;

View file

@ -52,11 +52,11 @@ describe('parsers', function () {
parser({ emit: spy }, data);
expect(spy.callCount).to.equal(3);
expect(spy.getCall(0).args[1]).to.have.length(15);
expect(spy.getCall(0).args[1]).to.satisfy(function(d) { return d[d.length-1] == 0; });
expect(spy.getCall(0).args[1]).to.satisfy(function(d) { return d[d.length-1] === 0; });
expect(spy.getCall(1).args[1]).to.have.length(13);
expect(spy.getCall(1).args[1]).to.satisfy(function(d) { return d[d.length-1] == 0; });
expect(spy.getCall(1).args[1]).to.satisfy(function(d) { return d[d.length-1] === 0; });
expect(spy.getCall(2).args[1]).to.have.length(21);
expect(spy.getCall(2).args[1]).to.satisfy(function(d) { return d[d.length-1] == 0; });
expect(spy.getCall(2).args[1]).to.satisfy(function(d) { return d[d.length-1] === 0; });
});
it('accepts single byte delimiter', function() {
var data = new Buffer('This could be\0binary data\0sent from a Moteino\0');
@ -81,11 +81,11 @@ describe('parsers', function () {
parser({ emit: spy }, data2);
expect(spy.callCount).to.equal(3);
expect(spy.getCall(0).args[1]).to.have.length(15);
expect(spy.getCall(0).args[1]).to.satisfy(function(d) { return d[d.length-1] == 0; });
expect(spy.getCall(0).args[1]).to.satisfy(function(d) { return d[d.length-1] === 0; });
expect(spy.getCall(1).args[1]).to.have.length(13);
expect(spy.getCall(1).args[1]).to.satisfy(function(d) { return d[d.length-1] == 0; });
expect(spy.getCall(1).args[1]).to.satisfy(function(d) { return d[d.length-1] === 0; });
expect(spy.getCall(2).args[1]).to.have.length(21);
expect(spy.getCall(2).args[1]).to.satisfy(function(d) { return d[d.length-1] == 0; });
expect(spy.getCall(2).args[1]).to.satisfy(function(d) { return d[d.length-1] === 0; });
});
});
});