beanstalkd-protocol
Advanced tools
Comparing version 0.2.3 to 1.0.0
@@ -20,3 +20,7 @@ 'use strict'; | ||
constructor() { | ||
this.types = _default.types; | ||
this.reset(); | ||
} | ||
reset() { | ||
this.types = Object.assign({}, _default.types); | ||
this.commandMap = {}; | ||
@@ -129,3 +133,3 @@ this.replyMap = {}; | ||
[key]: identifier, | ||
args: convertArgs(spec, args) | ||
args: convertArgs(spec, args, this.types) | ||
}]; | ||
@@ -220,8 +224,8 @@ } | ||
exports.default = BeanstalkdProtocol; | ||
function convertArgs(spec, args) { | ||
function convertArgs(spec, args, types) { | ||
return (0, _misc.reduce)(args, function (args, arg, i) { | ||
let key = spec.args[i]; | ||
args[key] = _default.types[key](arg); | ||
args[key] = types[key](arg); | ||
return args; | ||
}, {}); | ||
} |
{ | ||
"name": "beanstalkd-protocol", | ||
"version": "0.2.3", | ||
"version": "1.0.0", | ||
"description": "Beanstalkd protocol parser for Node.js/Javascript", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -24,4 +24,2 @@ # Beanstalkd protocol parser for Node.js/Javascript | ||
Will discard command data from put, etc commands. | ||
* **buffer** `Buffer` to parse. Can be a partial chunk of a stream. | ||
@@ -31,1 +29,16 @@ * Returns: `[null, {command, args}]` returned if command was the only thing in the chunk | ||
* Returns: `[Buffer, {command, args}]` returns remaining part of chunk + found command if chunk is larger than command | ||
### protocol.parseReply(buffer) | ||
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. | ||
* Returns: `[null, {reply, args}]` returned if reply was the only thing in the chunk | ||
* Returns: `[Buffer, null]` returns passed chunk if no reply was found or not enough data was available to fully parse reply | ||
* Returns: `[Buffer, {reply, args}]` returns remaining part of chunk + found reply if chunk is larger than reply | ||
#### protocol.reset() | ||
Removes all custom types, commands & replies |
@@ -69,3 +69,3 @@ import BeanstalkdProtocol, {convertArgs} from '../../src/index'; | ||
command, | ||
args: convertArgs(protocol.commandMap[command], args) | ||
args: convertArgs(protocol.commandMap[command], args, protocol.types) | ||
} | ||
@@ -122,3 +122,3 @@ ]); | ||
reply, | ||
args: convertArgs(protocol.replyMap[reply], args) | ||
args: convertArgs(protocol.replyMap[reply], args, protocol.types) | ||
} | ||
@@ -125,0 +125,0 @@ ]); |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
36715
16
730
0
43