Skip to content

Commit 9d65e1c

Browse files
committed
tests: fix buffer test (failed due to new parser) & remove unused node feature checks (< 4)
1 parent 13ec6af commit 9d65e1c

File tree

3 files changed

+8
-34
lines changed

3 files changed

+8
-34
lines changed

index.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ var SUBSCRIBE_COMMANDS = {
2020
punsubscribe: true
2121
};
2222

23-
// Newer Node.js versions > 0.10 return the EventEmitter right away and using .EventEmitter was deprecated
24-
if (typeof EventEmitter !== 'function') {
25-
EventEmitter = EventEmitter.EventEmitter;
26-
}
27-
2823
function noop () {}
2924

3025
function handle_detect_buffers_reply (reply, command, buffer_args) {
@@ -153,7 +148,6 @@ function RedisClient (options, stream) {
153148
this.server_info = {};
154149
this.auth_pass = options.auth_pass || options.password;
155150
this.selected_db = options.db; // Save the selected db here, used when reconnecting
156-
this.old_state = null;
157151
this.fire_strings = true; // Determine if strings or buffers should be written to the stream
158152
this.pipeline = false;
159153
this.sub_commands_left = 0;
@@ -175,12 +169,6 @@ function RedisClient (options, stream) {
175169
'If you want to keep on listening to this event please listen to the stream drain event directly.'
176170
);
177171
} else if ((event === 'message_buffer' || event === 'pmessage_buffer' || event === 'messageBuffer' || event === 'pmessageBuffer') && !this.buffers && !this.message_buffers) {
178-
if (this.reply_parser.name !== 'javascript') {
179-
return this.warn(
180-
'You attached the "' + event + '" listener without the returnBuffers option set to true.\n' +
181-
'Please use the JavaScript parser or set the returnBuffers option to true to return buffers.'
182-
);
183-
}
184172
this.reply_parser.optionReturnBuffers = true;
185173
this.message_buffers = true;
186174
this.handle_reply = handle_detect_buffers_reply;

lib/commands.js

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@ var commands = require('redis-commands');
44
var Multi = require('./multi');
55
var RedisClient = require('../').RedisClient;
66
var Command = require('./command');
7-
// Feature detect if a function may change it's name
8-
var changeFunctionName = (function () {
9-
var fn = function abc () {};
10-
try {
11-
Object.defineProperty(fn, 'name', {
12-
value: 'foobar'
13-
});
14-
return true;
15-
} catch (e) {
16-
return false;
17-
}
18-
}());
197

208
var addCommand = function (command) {
219
// Some rare Redis commands use special characters in their command name
@@ -61,11 +49,9 @@ var addCommand = function (command) {
6149
if (commandName !== command) {
6250
RedisClient.prototype[commandName.toUpperCase()] = RedisClient.prototype[commandName] = RedisClient.prototype[command];
6351
}
64-
if (changeFunctionName) {
65-
Object.defineProperty(RedisClient.prototype[command], 'name', {
66-
value: commandName
67-
});
68-
}
52+
Object.defineProperty(RedisClient.prototype[command], 'name', {
53+
value: commandName
54+
});
6955
}
7056

7157
// Do not override existing functions
@@ -108,11 +94,9 @@ var addCommand = function (command) {
10894
if (commandName !== command) {
10995
Multi.prototype[commandName.toUpperCase()] = Multi.prototype[commandName] = Multi.prototype[command];
11096
}
111-
if (changeFunctionName) {
112-
Object.defineProperty(Multi.prototype[command], 'name', {
113-
value: commandName
114-
});
115-
}
97+
Object.defineProperty(Multi.prototype[command], 'name', {
98+
value: commandName
99+
});
116100
}
117101
};
118102

test/pubsub.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ describe('publish/subscribe', function () {
524524
assert.strictEqual(channel.inspect(), new Buffer('/foo').inspect());
525525
sub.quit(end);
526526
});
527+
// Either message_buffers or buffers has to be true, but not both at the same time
528+
assert.notStrictEqual(sub.message_buffers, sub.buffers);
527529
});
528530
var batch = sub.batch();
529531
batch.psubscribe('*');

0 commit comments

Comments
 (0)