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

beanstalkd

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beanstalkd - npm Package Compare versions

Comparing version 1.0.5 to 1.1.0

.babelrc

250

lib/client.js
'use strict';
var _createClass = require('babel-runtime/helpers/create-class')['default'];
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
var _bluebird = require('bluebird');
var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default'];
var _bluebird2 = _interopRequireDefault(_bluebird);
Object.defineProperty(exports, '__esModule', {
value: true
});
var _net = require('net');

@@ -19,4 +15,6 @@

var _bluebird2 = _interopRequireDefault(_bluebird);
var _beanstalkdProtocol = require('beanstalkd-protocol');
var _beanstalkdProtocol2 = _interopRequireDefault(_beanstalkdProtocol);
var _readQueue = require('./read-queue');

@@ -32,42 +30,43 @@

var debug = require('debug')('beanstalkd');
var debugError = require('debug')('beanstalkd:error');
var DEFAULT_HOST = '127.0.0.1';
var DEFAULT_PORT = 11300;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var BeanstalkdClient = (function () {
function BeanstalkdClient(host, port, options) {
_classCallCheck(this, BeanstalkdClient);
const debug = require('debug')('beanstalkd');
const debugError = require('debug')('beanstalkd:error');
const DEFAULT_HOST = '127.0.0.1';
const DEFAULT_PORT = 11300;
class BeanstalkdClient {
constructor(host, port, options) {
this.host = host || DEFAULT_HOST;
this.port = port || DEFAULT_PORT;
this.options = options || {};
this.protocol = new _beanstalkdProtocol2.default();
this.readQueue = null;
this.writeQueue = _bluebird2['default'].resolve();
this.writeQueue = _bluebird2.default.resolve();
this.closed = false;
this.use = makeCommand(new _writer.BasicWriter('use', new _types.TubeType()), new _reader.BasicReader('USING', new _types.TubeType()));
this.use = makeCommand(new _writer.BasicWriter('use'), new _reader.BasicReader('USING', new _types.TubeType()));
this.listTubeUsed = makeCommand(new _writer.BasicWriter('list-tube-used'), new _reader.BasicReader('USING', new _types.TubeType()));
this.pauseTube = makeCommand(new _writer.BasicWriter('pause-tube', new _types.TubeType(), new _types.DelayType()), new _reader.BasicReader('PAUSED'));
this.pauseTube = makeCommand(new _writer.BasicWriter('pause-tube'), new _reader.BasicReader('PAUSED'));
this.put = makeCommand(new _writer.BodyWriter('put', new _types.PriorityType(), new _types.DelayType(), new _types.Type('ttr', Number), new _types.BodyType()), new _reader.BasicReader('INSERTED', new _types.IdType()));
this.put = makeCommand(new _writer.BodyWriter('put'), new _reader.BasicReader('INSERTED', new _types.IdType()));
this.watch = makeCommand(new _writer.BasicWriter('watch', new _types.TubeType()), new _reader.BasicReader('WATCHING', new _types.TubeType()));
this.ignore = makeCommand(new _writer.BasicWriter('ignore', new _types.TubeType()), new _reader.BasicReader('WATCHING', new _types.TubeType()));
this.watch = makeCommand(new _writer.BasicWriter('watch'), new _reader.BasicReader('WATCHING', new _types.TubeType()));
this.ignore = makeCommand(new _writer.BasicWriter('ignore'), new _reader.BasicReader('WATCHING', new _types.TubeType()));
/* Reserve commands */
this.reserve = makeCommand(new _writer.BasicWriter('reserve'), new _reader.BodyReader('RESERVED', new _types.IdType(), new _types.BodyType()));
this.reserveWithTimeout = makeCommand(new _writer.BasicWriter('reserve-with-timeout', new _types.Type('timeout', Number)), new _reader.BodyReader('RESERVED', new _types.IdType(), new _types.BodyType()));
this.reserveWithTimeout = makeCommand(new _writer.BasicWriter('reserve-with-timeout'), new _reader.BodyReader('RESERVED', new _types.IdType(), new _types.BodyType()));
/* Job commands */
this.destroy = makeCommand(new _writer.BasicWriter('delete', new _types.IdType()), new _reader.BasicReader('DELETED'));
this.bury = makeCommand(new _writer.BasicWriter('bury', new _types.IdType(), new _types.PriorityType()), new _reader.BasicReader('BURIED'));
this.release = makeCommand(new _writer.BasicWriter('release', new _types.IdType(), new _types.PriorityType(), new _types.DelayType()), new _reader.BasicReader('RELEASED'));
this.touch = makeCommand(new _writer.BasicWriter('touch', new _types.IdType()), new _reader.BasicReader('TOUCHED'));
this.kickJob = makeCommand(new _writer.BasicWriter('kick-job', new _types.IdType()), new _reader.BasicReader('KICKED'));
this.destroy = makeCommand(new _writer.BasicWriter('delete'), new _reader.BasicReader('DELETED'));
this.bury = makeCommand(new _writer.BasicWriter('bury'), new _reader.BasicReader('BURIED'));
this.release = makeCommand(new _writer.BasicWriter('release'), new _reader.BasicReader('RELEASED'));
this.touch = makeCommand(new _writer.BasicWriter('touch'), new _reader.BasicReader('TOUCHED'));
this.kickJob = makeCommand(new _writer.BasicWriter('kick-job'), new _reader.BasicReader('KICKED'));
/* Peek commands */
this.peek = makeCommand(new _writer.BasicWriter('peek', new _types.IdType()), new _reader.BodyReader('FOUND', new _types.IgnoreType(), new _types.BodyType()));
this.peek = makeCommand(new _writer.BasicWriter('peek'), new _reader.BodyReader('FOUND', new _types.IgnoreType(), new _types.BodyType()));

@@ -83,130 +82,126 @@ this.peekReady = makeCommand(new _writer.BasicWriter('peek-ready'), new _reader.BodyReader('FOUND', new _types.IdType(), new _types.BodyType()));

this.listTubes = makeCommand(new _writer.BasicWriter('list-tubes'), new _reader.YamlReader('OK', new _types.YamlBodyType()));
this.statsJob = makeCommand(new _writer.BasicWriter('stats-job', new _types.IdType()), new _reader.YamlReader('OK', new _types.YamlBodyType()));
this.statsTube = makeCommand(new _writer.BasicWriter('stats-tube', new _types.TubeType()), new _reader.YamlReader('OK', new _types.YamlBodyType()));
this.statsJob = makeCommand(new _writer.BasicWriter('stats-job'), new _reader.YamlReader('OK', new _types.YamlBodyType()));
this.statsTube = makeCommand(new _writer.BasicWriter('stats-tube'), new _reader.YamlReader('OK', new _types.YamlBodyType()));
this.stats = makeCommand(new _writer.BasicWriter('stats'), new _reader.YamlReader('OK', new _types.YamlBodyType()));
}
_createClass(BeanstalkdClient, [{
key: 'connect',
value: function connect() {
var _this = this;
connect() {
return new _bluebird2.default((resolve, reject) => {
debug('connecting to %s:%s', this.host, this.port);
let connection = _net2.default.createConnection(this.port, this.host);
return new _bluebird2['default'](function (resolve, reject) {
debug('connecting to %s:%s', _this.host, _this.port);
var connection = _net2['default'].createConnection(_this.port, _this.host);
connection.on('error', err => {
this.closed = true;
this.error = err;
reject(err);
});
connection.on('error', function (err) {
_this.closed = true;
_this.error = err;
reject(err);
});
connection.on('connect', () => {
debug('connected to %s:%s', this.host, this.port);
this.connection = connection;
this.readQueue = new _readQueue2.default(this.connection);
resolve(this);
});
connection.on('connect', function () {
debug('connected to %s:%s', _this.host, _this.port);
_this.connection = connection;
_this.readQueue = new _readQueue2['default'](_this.connection);
resolve(_this);
});
connection.on('end', () => {
debug('connection finished');
this.closed = true;
});
connection.on('end', function () {
debug('connection finished');
_this.closed = true;
});
connection.on('close', function () {
debug('connection closed');
_this.closed = true;
_this.connection = null;
});
connection.on('close', () => {
debug('connection closed');
this.closed = true;
this.connection = null;
});
}
}, {
key: 'unref',
value: function unref() {
this.connection.unref();
}
}, {
key: 'on',
value: function on(event) {
var _connection;
});
}
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
unref() {
this.connection.unref();
}
(_connection = this.connection).on.apply(_connection, [event].concat(args));
on(event) {
var _connection;
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
}, {
key: 'quit',
value: function quit() {
this.closed = true;
if (this.connection) {
this.connection.end();
}
return _bluebird2['default'].resolve();
}
}]);
return BeanstalkdClient;
})();
(_connection = this.connection).on.apply(_connection, [event].concat(args));
}
exports['default'] = BeanstalkdClient;
quit() {
this.closed = true;
if (this.connection) {
this.connection.end();
}
return _bluebird2.default.resolve();
}
}
exports.default = BeanstalkdClient;
function makeCommand(writer, reader) {
var command = _bluebird.coroutine(function* () {
var _this2 = this;
let command = (() => {
var _ref = (0, _bluebird.coroutine)(function* () {
var _this = this;
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
var onConnectionEnded = undefined,
connection = this.connection,
result = undefined;
let onConnectionEnded,
connection = this.connection,
protocol = this.protocol,
result;
if (this.closed) throw new Error('Connection is closed');
if (this.closed) throw new Error('Connection is closed');
yield this.writeQueue;
yield this.writeQueue;
try {
result = new _bluebird2['default'](function (resolve, reject) {
onConnectionEnded = function (error) {
reject(error || 'CLOSED');
};
try {
result = new _bluebird2.default(function (resolve, reject) {
onConnectionEnded = function onConnectionEnded(error) {
reject(error || 'CLOSED');
};
connection.once('close', onConnectionEnded);
connection.once('error', onConnectionEnded);
connection.once('close', onConnectionEnded);
connection.once('error', onConnectionEnded);
_this2.readQueue.push(function (data) {
return reader.handle(data, function (result) {
connection.removeListener('close', onConnectionEnded);
connection.removeListener('error', onConnectionEnded);
_this.readQueue.push(function (data) {
return reader.handle(data, function (result) {
connection.removeListener('close', onConnectionEnded);
connection.removeListener('error', onConnectionEnded);
resolve(result);
}, function (err) {
connection.removeListener('close', onConnectionEnded);
connection.removeListener('error', onConnectionEnded);
resolve(result);
}, function (err) {
connection.removeListener('close', onConnectionEnded);
connection.removeListener('error', onConnectionEnded);
reject(err);
reject(err);
});
});
writer.handle.apply(writer, [protocol, connection].concat(args));
});
writer.handle.apply(writer, [connection].concat(args));
});
this.writeQueue = result.reflect();
this.writeQueue = result.reflect();
yield result;
yield result;
debug('Sent command "' + writer.command + ' ' + args.join(' ') + '"');
} catch (err) {
debugError('Command "' + writer.command + ' ' + args.join(' ') + '" ' + err.toString());
throw err;
} finally {
connection.removeListener('close', onConnectionEnded);
connection.removeListener('error', onConnectionEnded);
}
debug(`Sent command "${ writer.command } ${ args.join(' ') }"`);
} catch (err) {
debugError(`Command "${ writer.command } ${ args.join(' ') }" ${ err.toString() }`);
throw err;
} finally {
connection.removeListener('close', onConnectionEnded);
connection.removeListener('error', onConnectionEnded);
}
return result;
});
return result;
});
return function command() {
return _ref.apply(this, arguments);
};
})();
command.writer = writer;

@@ -216,3 +211,2 @@ command.reader = reader;

return command;
}
module.exports = exports['default'];
}

@@ -6,3 +6,2 @@ "use strict";

});
var CRLF = new Buffer([0x0d, 0x0a]);
exports.CRLF = CRLF;
const CRLF = exports.CRLF = new Buffer([0x0d, 0x0a]);
'use strict';
var _createClass = require('babel-runtime/helpers/create-class')['default'];
var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
var ReadQueue = (function () {
function ReadQueue(connection) {
var _this = this;
_classCallCheck(this, ReadQueue);
class ReadQueue {
constructor(connection) {
this.connection = connection;

@@ -21,48 +12,39 @@ this.queue = [];

this.connection.on('data', function (data) {
_this.read(data);
this.connection.on('data', data => {
this.read(data);
});
}
_createClass(ReadQueue, [{
key: 'push',
value: function push(callback) {
this.queue.push(callback);
}
}, {
key: 'read',
value: function read(data) {
var result;
get length() {
return this.queue.length;
}
if (this.current === null) {
this.current = this.queue.shift();
push(callback) {
this.queue.push(callback);
}
if (!this.current) {
this.connection.emit('error', new Error('No read queue item for item, length: ' + data.length));
console.log(data.toString());
this.connection.destroy();
return;
}
}
read(data) {
var result;
result = this.current(data);
if (this.current === null) {
this.current = this.queue.shift();
if (result) {
this.current = null;
if (Buffer.isBuffer(result) && result.length) {
this.read(result);
}
if (!this.current) {
this.connection.emit('error', new Error(`No read queue item for item, length: ${ data.length }`));
console.log(data.toString());
this.connection.destroy();
return;
}
}
}, {
key: 'length',
get: function get() {
return this.queue.length;
}
}]);
return ReadQueue;
})();
result = this.current(data);
exports['default'] = ReadQueue;
module.exports = exports['default'];
if (result) {
this.current = null;
if (Buffer.isBuffer(result) && result.length) {
this.read(result);
}
}
}
}
exports.default = ReadQueue;
'use strict';
var _createClass = require('babel-runtime/helpers/create-class')['default'];
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.YamlReader = exports.BodyReader = exports.BasicReader = undefined;
var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _get = require('babel-runtime/helpers/get')['default'];
var _inherits = require('babel-runtime/helpers/inherits')['default'];
var _slicedToArray = require('babel-runtime/helpers/sliced-to-array')['default'];
var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default'];
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.parseResult = parseResult;

@@ -28,4 +20,6 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function extractHeader(data) {
var length = data.indexOf(_misc.CRLF),
let length = data.indexOf(_misc.CRLF),
header = data.toString('utf8', 0, length),

@@ -38,3 +32,3 @@ remainder = data.slice(length + _misc.CRLF.length, data.length);

function parseResult(result, types) {
var offset = 0;
let offset = 0;

@@ -52,6 +46,4 @@ result = result.slice(0);

var BasicReader = (function () {
function BasicReader(expectation) {
_classCallCheck(this, BasicReader);
class BasicReader {
constructor(expectation) {
this.expectation = expectation;

@@ -66,41 +58,29 @@

_createClass(BasicReader, [{
key: 'handle',
value: function handle(data, resolve, reject) {
var _extractHeader = extractHeader(data);
handle(data, resolve, reject) {
var _extractHeader = extractHeader(data),
_extractHeader2 = _slicedToArray(_extractHeader, 2);
var _extractHeader2 = _slicedToArray(_extractHeader, 2);
let header = _extractHeader2[0],
remainder = _extractHeader2[1],
args = header.split(' '),
response = args.shift(),
result = null;
var header = _extractHeader2[0];
var remainder = _extractHeader2[1];
var args = header.split(' ');
var response = args.shift();
var result = null;
if (response === this.expectation) {
result = args;
if (response === this.expectation) {
result = args;
result = parseResult(result, this.types);
resolve(result.length > 1 ? result : result[0]);
return remainder;
} else {
reject(new Error(response));
return remainder;
}
result = parseResult(result, this.types);
resolve(result.length > 1 ? result : result[0]);
return remainder;
} else {
reject(new Error(response));
return remainder;
}
}]);
}
}
return BasicReader;
})();
exports.BasicReader = BasicReader;
var BodyReader = (function (_BasicReader) {
_inherits(BodyReader, _BasicReader);
function BodyReader(expectation) {
var _get2;
_classCallCheck(this, BodyReader);
class BodyReader extends BasicReader {
constructor(expectation) {
for (var _len2 = arguments.length, types = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {

@@ -110,104 +90,84 @@ types[_key2 - 1] = arguments[_key2];

(_get2 = _get(Object.getPrototypeOf(BodyReader.prototype), 'constructor', this)).call.apply(_get2, [this, expectation].concat(types));
super(expectation, ...types);
this['continue'] = null;
this.continue = null;
}
_createClass(BodyReader, [{
key: 'parseBody',
value: function parseBody(body) {
return body;
}
}, {
key: 'handle',
value: function handle(data, resolve, reject) {
if (this['continue']) {
var _continue = this['continue'];
var _length = _continue.length;
var _result = _continue.result;
var _body = _continue.body;
parseBody(body) {
return body;
}
_body = Buffer.concat([_body, data]);
handle(data, resolve, reject) {
if (this.continue) {
var _continue = this.continue;
let length = _continue.length,
result = _continue.result,
body = _continue.body;
if (_body.length - _misc.CRLF.length < _length) {
this['continue'].body = _body;
return false;
}
this['continue'] = null;
body = Buffer.concat([body, data]);
_body = _body.slice(0, _length);
remainder = _body.slice(_length + _misc.CRLF.length);
_body = this.parseBody(_body);
_result.push(_body);
_result = parseResult(_result, this.types);
resolve(_result.length > 1 ? _result : _result[0]);
return remainder;
if (body.length - _misc.CRLF.length < length) {
this.continue.body = body;
return false;
}
var _extractHeader3 = extractHeader(data);
this.continue = null;
var _extractHeader32 = _slicedToArray(_extractHeader3, 2);
body = body.slice(0, length);
let remainder = body.slice(length + _misc.CRLF.length);
var header = _extractHeader32[0];
var remainder = _extractHeader32[1];
var args = header.split(' ');
var response = args.shift();
var length = parseInt(args.pop(), 10);
var result = null;
var body = undefined;
body = this.parseBody(body);
result.push(body);
result = parseResult(result, this.types);
resolve(result.length > 1 ? result : result[0]);
return remainder;
}
if (response === this.expectation) {
result = args;
var _extractHeader3 = extractHeader(data),
_extractHeader4 = _slicedToArray(_extractHeader3, 2);
if (remainder.length < length) {
this['continue'] = {
result: result,
body: remainder,
length: length
};
return false;
} else {
body = remainder.slice(0, length);
remainder = remainder.slice(length + _misc.CRLF.length);
}
let header = _extractHeader4[0],
remainder = _extractHeader4[1],
args = header.split(' '),
response = args.shift(),
length = parseInt(args.pop(), 10),
result = null,
body;
body = this.parseBody(body);
result.push(body);
result = parseResult(result, this.types);
resolve(result.length > 1 ? result : result[0]);
return remainder;
if (response === this.expectation) {
result = args;
if (remainder.length < length) {
this.continue = {
result: result,
body: remainder,
length: length
};
return false;
} else {
reject(new Error(response));
return remainder;
body = remainder.slice(0, length);
remainder = remainder.slice(length + _misc.CRLF.length);
}
body = this.parseBody(body);
result.push(body);
result = parseResult(result, this.types);
resolve(result.length > 1 ? result : result[0]);
return remainder;
} else {
reject(new Error(response));
return remainder;
}
}]);
}
}
return BodyReader;
})(BasicReader);
exports.BodyReader = BodyReader;
var YamlReader = (function (_BodyReader) {
_inherits(YamlReader, _BodyReader);
function YamlReader() {
_classCallCheck(this, YamlReader);
_get(Object.getPrototypeOf(YamlReader.prototype), 'constructor', this).apply(this, arguments);
class YamlReader extends BodyReader {
parseBody(body) {
return _jsYaml2.default.load(body.toString());
}
_createClass(YamlReader, [{
key: 'parseBody',
value: function parseBody(body) {
return _jsYaml2['default'].load(body.toString());
}
}]);
return YamlReader;
})(BodyReader);
}
exports.YamlReader = YamlReader;
'use strict';
var _createClass = require('babel-runtime/helpers/create-class')['default'];
var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
var _get = require('babel-runtime/helpers/get')['default'];
var _inherits = require('babel-runtime/helpers/inherits')['default'];
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
var Type = (function () {
function Type(name, type) {
_classCallCheck(this, Type);
class Type {
constructor(name, type) {
this.name = name;

@@ -23,116 +12,64 @@ this.type = type;

_createClass(Type, [{
key: 'validateInput',
value: function validateInput(value) {
if (this.type === Buffer) {
return Buffer.isBuffer(value) || typeof value === 'string';
}
if (this.type === Number) {
return typeof value === 'number' || !isNaN(parseInt(value, 10));
}
if (this.type === String) {
return typeof value === 'string';
}
return true;
validateInput(value) {
if (this.type === Buffer) {
return Buffer.isBuffer(value) || typeof value === 'string';
}
}, {
key: 'toString',
value: function toString() {
return this.name + '<' + this.type.name + '>';
if (this.type === Number) {
return typeof value === 'number' || !isNaN(parseInt(value, 10));
}
}]);
if (this.type === String) {
return typeof value === 'string';
}
return true;
}
return Type;
})();
toString() {
return `${ this.name }<${ this.type.name }>`;
}
}
exports.Type = Type;
var IdType = (function (_Type) {
_inherits(IdType, _Type);
function IdType() {
_classCallCheck(this, IdType);
_get(Object.getPrototypeOf(IdType.prototype), 'constructor', this).call(this, 'id', Number);
class IdType extends Type {
constructor() {
super('id', Number);
}
}
return IdType;
})(Type);
exports.IdType = IdType;
var PriorityType = (function (_Type2) {
_inherits(PriorityType, _Type2);
function PriorityType() {
_classCallCheck(this, PriorityType);
_get(Object.getPrototypeOf(PriorityType.prototype), 'constructor', this).call(this, 'priority', Number);
class PriorityType extends Type {
constructor() {
super('priority', Number);
}
}
return PriorityType;
})(Type);
exports.PriorityType = PriorityType;
var DelayType = (function (_Type3) {
_inherits(DelayType, _Type3);
function DelayType() {
_classCallCheck(this, DelayType);
_get(Object.getPrototypeOf(DelayType.prototype), 'constructor', this).call(this, 'delay', Number);
class DelayType extends Type {
constructor() {
super('delay', Number);
}
}
return DelayType;
})(Type);
exports.DelayType = DelayType;
var TubeType = (function (_Type4) {
_inherits(TubeType, _Type4);
function TubeType() {
_classCallCheck(this, TubeType);
_get(Object.getPrototypeOf(TubeType.prototype), 'constructor', this).call(this, 'tube', String);
class TubeType extends Type {
constructor() {
super('tube', String);
}
}
return TubeType;
})(Type);
exports.TubeType = TubeType;
var BodyType = (function (_Type5) {
_inherits(BodyType, _Type5);
function BodyType() {
_classCallCheck(this, BodyType);
_get(Object.getPrototypeOf(BodyType.prototype), 'constructor', this).call(this, 'body', Buffer);
class BodyType extends Type {
constructor() {
super('body', Buffer);
}
}
return BodyType;
})(Type);
exports.BodyType = BodyType;
var YamlBodyType = (function (_Type6) {
_inherits(YamlBodyType, _Type6);
function YamlBodyType() {
_classCallCheck(this, YamlBodyType);
_get(Object.getPrototypeOf(YamlBodyType.prototype), 'constructor', this).call(this, 'body', Object);
class YamlBodyType extends Type {
constructor() {
super('body', Object);
}
}
return YamlBodyType;
})(Type);
exports.YamlBodyType = YamlBodyType;
var IgnoreType = function IgnoreType() {
_classCallCheck(this, IgnoreType);
};
class IgnoreType {}
exports.IgnoreType = IgnoreType;

@@ -1,103 +0,45 @@

'use strict';
"use strict";
var _createClass = require('babel-runtime/helpers/create-class')['default'];
var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
var _get = require('babel-runtime/helpers/get')['default'];
var _inherits = require('babel-runtime/helpers/inherits')['default'];
var _bluebird = require('bluebird');
var _Promise = require('babel-runtime/core-js/promise')['default'];
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BodyWriter = exports.BasicWriter = exports.Writer = undefined;
var _misc = require('./misc');
var _bluebird = require("bluebird");
var Writer = (function () {
function Writer(command) {
_classCallCheck(this, Writer);
class Writer {
constructor(command) {
this.command = command;
for (var _len = arguments.length, types = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
types[_key - 1] = arguments[_key];
}
this.types = types;
}
}
_createClass(Writer, [{
key: 'validateArgs',
value: function validateArgs(args) {
if (args.length !== this.types.length) {
var typesString = this.types.map(function (type) {
return type.toString();
}).join(', ');
throw new Error('Argument length mismatch for ' + this.command + ', expected ' + typesString);
}
exports.Writer = Writer;
class BasicWriter extends Writer {
handle(protocol, connection) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
}]);
return Writer;
})();
var _this = this;
exports.Writer = Writer;
var BasicWriter = (function (_Writer) {
_inherits(BasicWriter, _Writer);
function BasicWriter() {
_classCallCheck(this, BasicWriter);
_get(Object.getPrototypeOf(BasicWriter.prototype), 'constructor', this).apply(this, arguments);
return (0, _bluebird.coroutine)(function* () {
yield new Promise(function (resolve) {
connection.write(protocol.buildCommand(_this.command, args), resolve);
});
})();
}
}
_createClass(BasicWriter, [{
key: 'handle',
value: _bluebird.coroutine(function* (connection) {
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
this.validateArgs(args);
args.unshift(this.command);
yield new _Promise(function (resolve) {
connection.write(Buffer.concat([new Buffer(args.join(' ')), _misc.CRLF]), resolve);
});
})
}]);
return BasicWriter;
})(Writer);
exports.BasicWriter = BasicWriter;
class BodyWriter extends BasicWriter {
handle(protocol, connection) {
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
args[_key2 - 2] = arguments[_key2];
}
var BodyWriter = (function (_BasicWriter) {
_inherits(BodyWriter, _BasicWriter);
var _this2 = this;
function BodyWriter() {
_classCallCheck(this, BodyWriter);
return (0, _bluebird.coroutine)(function* () {
let body = args.pop();
_get(Object.getPrototypeOf(BodyWriter.prototype), 'constructor', this).apply(this, arguments);
}
_createClass(BodyWriter, [{
key: 'handle',
value: _bluebird.coroutine(function* (connection) {
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];
}
this.validateArgs(args);
var body = args.pop();
if (!Buffer.isBuffer(body)) {

@@ -107,14 +49,11 @@ body = new Buffer(body);

args.unshift(this.command);
args.push(body.length);
args.push(body);
yield new _Promise(function (resolve) {
connection.write(Buffer.concat([new Buffer(args.join(' ')), _misc.CRLF, body, _misc.CRLF]), resolve);
yield new Promise(function (resolve) {
connection.write(protocol.buildCommand(_this2.command, args), resolve);
});
})
}]);
return BodyWriter;
})(BasicWriter);
})();
}
}
exports.BodyWriter = BodyWriter;
{
"name": "beanstalkd",
"version": "1.0.5",
"version": "1.1.0",
"description": "A beanstalkd client for Node.js with promises",

@@ -8,3 +8,4 @@ "main": "lib/client.js",

"babel-runtime": "^5.8.25",
"bluebird": "~2.5.3",
"beanstalkd-protocol": "^0.1.1",
"bluebird": "^3.4.7",
"debug": "^2.2.0",

@@ -14,9 +15,11 @@ "js-yaml": "^3.4.2"

"devDependencies": {
"babel": "^5.8.23",
"babel-core": "^5.8.25",
"babel-eslint": "^4.1.3",
"babel-cli": "^6.18.0",
"babel-eslint": "^7.1.1",
"babel-preset-async-to-bluebird": "^1.1.0",
"babel-preset-es2015-node4": "^2.1.1",
"babel-register": "^6.18.0",
"chai": "^2.3.0",
"chai-as-promised": "^5.0.0",
"chai-datetime": "^1.4.0",
"eslint": "^1.5.1",
"eslint": "^3.12.2",
"istanbul": "^0.3.18",

@@ -33,11 +36,10 @@ "mocha": "^2.2.1",

"prepublish": "npm run check && npm run build",
"check": "npm run lint && npm run test-unit",
"check": "npm run lint && npm run test:unit",
"lint": "eslint src",
"build": "rm -rf lib/* && babel src --ignore test --optional runtime,bluebirdCoroutines --out-dir lib",
"build-docker": "docker-compose build",
"build": "rm -rf lib/* && babel src -d lib",
"cover": "NODE_PATH=src NODE_ENV=test istanbul cover _mocha -- $npm_package_options_mocha test/unit/*.test.js test/unit/**/*.test.js",
"test": "npm run test-unit && npm run test-integration",
"test-unit": "NODE_PATH=src NODE_ENV=test mocha $npm_package_options_mocha test/unit/*.test.js test/unit/**/*.test.js",
"test-integration": "docker-compose run client /bin/sh -c \"npm run test-integration-raw\"",
"test-integration-raw": "NODE_ENV=test mocha $npm_package_options_mocha test/integration/*.test.js test/integration/**/*.test.js"
"test": "npm run test:unit && npm run test:integration",
"test:unit": "NODE_PATH=src NODE_ENV=test mocha $npm_package_options_mocha test/unit/*.test.js test/unit/**/*.test.js",
"test:integration": "docker-compose run client /bin/sh -c \"npm run test:integration:raw\"",
"test:integration:raw": "NODE_ENV=test mocha $npm_package_options_mocha test/integration/*.test.js test/integration/**/*.test.js"
},

@@ -44,0 +46,0 @@ "repository": {

@@ -8,2 +8,4 @@ # node-beanstalkd-client

For a high level beanstalkd worker client, see [node-beanstalkd-worker](https://github.com/burstable/node-beanstalkd-worker)
## Install

@@ -38,3 +40,3 @@

All beanstalkd commands are implemented per the protocol.
Method names are the same as beanstalk command names camelCased, list-tubes-watched becomes listTubesWatched.
Method names are the same as beanstalk command names camelCased, list-tubes-watched becomes listTubesWatched.

@@ -41,0 +43,0 @@ ## Debugging

@@ -1,2 +0,2 @@

import Client from 'client';
import Client from '../../src/client';
import {expect} from 'chai';

@@ -317,2 +317,2 @@ import Promise from 'bluebird';

});
});
});

@@ -133,3 +133,3 @@ import BeanstalkdClient from 'client';

it('should close connection if read queue errors', function () {
let client = client = new BeanstalkdClient(Math.random().toString(), Math.floor(Math.random() * 9999));
let client = new BeanstalkdClient(Math.random().toString(), Math.floor(Math.random() * 9999));
client.connect();

@@ -146,2 +146,2 @@ this.connectionStub.emit('connect');

});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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