diff --git a/.gitignore b/.gitignore index 3c3629e..ec7a3a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ node_modules +.idea +*.swp +*.log + diff --git a/lib/memcached.js b/lib/memcached.js index d699f2b..be2882f 100644 --- a/lib/memcached.js +++ b/lib/memcached.js @@ -31,8 +31,7 @@ var curry = Utils.curry; function Client (args, options) { var servers = [] , weights = {} - , regular = 'localhost:11211' - , key; + , regular = 'localhost:11211'; // Parse down the connection arguments switch (Object.prototype.toString.call(args)) { @@ -112,8 +111,7 @@ Client.config = { nMemcached.prototype.__proto__ = require('events').EventEmitter.prototype; var memcached = nMemcached.prototype - , privates = {} - , undefined; + , privates = {}; // Creates or generates a new connection for the give server, the callback // will receive the connection if the operation was successful @@ -319,7 +317,7 @@ Client.config = { var S = { serverAddress: server, tokens: server.split(':').reverse() - } + }; var message = error || 'Unable to connect to server'; memcached.connectionIssue(message, S); return query.callback && memcached.makeCallback(query.callback,new Error(message)); @@ -706,8 +704,7 @@ Client.config = { , dataSet , resultSet , metaData - , err = [] - , tmp; + , err = []; while(S.bufferArray.length && privates.allCommands.test(S.bufferArray[0])) { token = S.bufferArray.shift(); diff --git a/lib/utils.js b/lib/utils.js index a450d9c..0757ffd 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -31,9 +31,13 @@ exports.validateArg = function validateArg (args, config) { } if (!err && key === 'key') { for (var vKey in value) { + if (!value.hasOwnProperty(vKey)) continue; var vValue = value[vKey]; var result = validateKeySize(config, vKey, vValue); if (result.err) { + if (result.err === 'function') { + continue; + } err = result.err; } else { args.command = args.command.replace(vValue, result['value']); @@ -87,6 +91,10 @@ exports.validateArg = function validateArg (args, config) { }; var validateKeySize = function validateKeySize(config, key, value) { + if (typeof value === 'function') { + return { err: 'function' }; + } + if (value.length > config.maxKeySize) { if (config.keyCompression){ return { err: false, value: createHash('md5').update(value).digest('hex') }; @@ -111,6 +119,7 @@ exports.fuse = function fuse (target, handlers) { // merges a object's proppertys / values with a other object exports.merge = function merge (target, obj) { for (var i in obj) { + if (!obj.hasOwnProperty(i)) continue; target[i] = obj[i]; }