Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

beanstalkd-protocol

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beanstalkd-protocol - npm Package Compare versions

Comparing version 0.2.3 to 1.0.0

test/unit/reset.test.js

12

lib/index.js

@@ -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 @@ ]);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc