beanstalkd-protocol
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -112,3 +112,3 @@ 'use strict'; | ||
let previous = i && spec.parts[i - 1] || null; | ||
let bytes = previous[previous.length - 1] === 'bytes' && args[args.length - 1] || null; | ||
let bytes = previous[previous.length - 1] === 'bytes' && parseInt(args[args.length - 1], 10) || null; | ||
@@ -121,3 +121,3 @@ if (bytes > remainder.length) return [buffer, null]; | ||
let part = remainder.slice(0, boundary); | ||
remainder = remainder.length > boundary + _misc.CRLF.length ? buffer.slice(remainder + _misc.CRLF.length) : null; | ||
remainder = remainder.length > boundary + _misc.CRLF.length ? remainder.slice(remainder + _misc.CRLF.length) : null; | ||
@@ -124,0 +124,0 @@ args.push(part); |
{ | ||
"name": "beanstalkd-protocol", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Beanstalkd protocol parser for Node.js/Javascript", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -98,13 +98,17 @@ import BeanstalkdProtocol from '../../src/index'; | ||
let buffers = [ | ||
full.slice(0, 200000), | ||
full.slice(200000) | ||
]; | ||
let buffer = new Buffer(0); | ||
for (let i = 0; i < full.length; i += 65536) { | ||
let piece = full.slice(i, i + 65536); | ||
let [remainder, result] = protocol.parseReply(buffers[0]); | ||
expect(result, 'to equal', null); | ||
expect(remainder.length, 'to equal', buffers[0].length); | ||
if (piece.length === 65536) { | ||
let [remainder, result] = protocol.parseReply(Buffer.concat([buffer, piece])); | ||
expect(result, 'to equal', null); | ||
buffer = remainder; | ||
} else { | ||
buffer = Buffer.concat([buffer, piece]); | ||
} | ||
} | ||
expect( | ||
protocol.parseReply(Buffer.concat([remainder, buffers[1]])), | ||
protocol.parseReply(buffer), | ||
'to equal', | ||
@@ -172,3 +176,19 @@ [null, { | ||
}); | ||
it('parses two stats replies in a single buffer', function () { | ||
let buffer = new Buffer( | ||
'OK 927' + | ||
'\r\n' + | ||
'---\ncurrent-jobs-urgent: 202\ncurrent-jobs-ready: 202\ncurrent-jobs-reserved: 0\ncurrent-jobs-delayed: 0\ncurrent-jobs-buried: 0\ncmd-put: 216\ncmd-peek: 15\ncmd-peek-ready: 0\ncmd-peek-delayed: 0\ncmd-peek-buried: 0\ncmd-reserve: 0\ncmd-reserve-with-timeout: 201\ncmd-delete: 14\ncmd-release: 0\ncmd-use: 181\ncmd-watch: 180\ncmd-ignore: 178\ncmd-bury: 0\ncmd-kick: 0\ncmd-touch: 0\ncmd-stats: 85\ncmd-stats-job: 0\ncmd-stats-tube: 0\ncmd-list-tubes: 0\ncmd-list-tube-used: 18\ncmd-list-tubes-watched: 18\ncmd-pause-tube: 0\njob-timeouts: 0\ntotal-jobs: 216\nmax-job-size: 5000000\ncurrent-tubes: 128\ncurrent-connections: 1\ncurrent-producers: 0\ncurrent-workers: 0\ncurrent-waiting: 0\ntotal-connections: 519\npid: 1\nversion: 1.10\nrusage-utime: 0.064000\nrusage-stime: 0.412000\nuptime: 4766\nbinlog-oldest-index: 0\nbinlog-current-index: 0\nbinlog-records-migrated: 0\nbinlog-records-written: 0\nbinlog-max-size: 10485760\nid: eb22a9da2b666fa1hostname: 2656fb9c580b' + | ||
'\r\n' + | ||
'OK 927' + | ||
'\r\n' + | ||
'---\ncurrent-jobs-urgent: 202\ncurrent-jobs-ready: 202\ncurrent-jobs-reserved: 0\ncurrent-jobs-delayed: 0\ncurrent-jobs-buried: 0\ncmd-put: 216\ncmd-peek: 15\ncmd-peek-ready: 0\ncmd-peek-delayed: 0\ncmd-peek-buried: 0\ncmd-reserve: 0\ncmd-reserve-with-timeout: 201\ncmd-delete: 14\ncmd-release: 0\ncmd-use: 181\ncmd-watch: 180\ncmd-ignore: 178\ncmd-bury: 0\ncmd-kick: 0\ncmd-touch: 0\ncmd-stats: 85\ncmd-stats-job: 0\ncmd-stats-tube: 0\ncmd-list-tubes: 0\ncmd-list-tube-used: 18\ncmd-list-tubes-watched: 18\ncmd-pause-tube: 0\njob-timeouts: 0\ntotal-jobs: 216\nmax-job-size: 5000000\ncurrent-tubes: 128\ncurrent-connections: 1\ncurrent-producers: 0\ncurrent-workers: 0\ncurrent-waiting: 0\ntotal-connections: 519\npid: 1\nversion: 1.10\nrusage-utime: 0.064000\nrusage-stime: 0.412000\nuptime: 4766\nbinlog-oldest-index: 0\nbinlog-current-index: 0\nbinlog-records-migrated: 0\nbinlog-records-written: 0\nbinlog-max-size: 10485760\nid: eb22a9da2b666fa1hostname: 2656fb9c580b' + | ||
'\r\n' | ||
); | ||
let [remainder, result] = protocol.parseReply(buffer); | ||
expect(remainder, 'not to equal', null); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35164
708