Beanstalkd protocol parser for Node.js/Javascript
npm install beanstalkd-protocol``sh`
npm install --save beanstalkd-protocol
See unit tests
`js
import Protocol from 'beanstalkd-protocol';
`
Parses a Buffer for a consumer/worker command.
Buffer can be a partial chunk of a stream, the method will return values based on whether or not it has enough information to parse the full command yet.
* buffer Buffer to parse. Can be a partial chunk of a stream.[null, {command, args}]
* Returns: returned if command was the only thing in the chunk[Buffer, null]
* Returns: returns passed chunk if no command was found or not enough data was available to fully parse command[Buffer, {command, args}]
* Returns: returns remaining part of chunk + found command if chunk is larger than command
Parses a Buffer for a beanstalkd server reply.
Buffer can be a partial chunk of a stream, the method will return values based on whether or not it has enough information to parse the full command yet.
* buffer Buffer to parse. Can be a partial chunk of a stream.[null, {reply, args}]
* Returns: returned if reply was the only thing in the chunk[Buffer, null]
* Returns: returns passed chunk if no reply was found or not enough data was available to fully parse reply[Buffer, {reply, args}]` returns remaining part of chunk + found reply if chunk is larger than reply
* Returns:
#### protocol.reset()
Removes all custom types, commands & replies