You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-10 11:43:01 +03:00
Remove snack_case and always use camelCase
This commit is contained in:
committed by
Ruben Bridgewater
parent
a86c998a64
commit
28afc33c9a
@@ -3,27 +3,28 @@
|
||||
var utils = require('./utils');
|
||||
var URL = require('url');
|
||||
|
||||
module.exports = function createClient (port_arg, host_arg, options) {
|
||||
module.exports = function createClient (portArg, hostArg, options) {
|
||||
|
||||
if (typeof port_arg === 'number' || typeof port_arg === 'string' && /^\d+$/.test(port_arg)) {
|
||||
if (typeof portArg === 'number' || typeof portArg === 'string' && /^\d+$/.test(portArg)) {
|
||||
|
||||
var host;
|
||||
if (typeof host_arg === 'string') {
|
||||
host = host_arg;
|
||||
if (typeof hostArg === 'string') {
|
||||
host = hostArg;
|
||||
} else {
|
||||
if (options && host_arg) {
|
||||
if (options && hostArg) {
|
||||
throw new TypeError('Unknown type of connection in createClient()');
|
||||
}
|
||||
options = options || host_arg;
|
||||
options = options || hostArg;
|
||||
}
|
||||
options = utils.clone(options);
|
||||
options.host = host || options.host;
|
||||
options.port = port_arg;
|
||||
options.port = portArg;
|
||||
|
||||
} else if (typeof port_arg === 'string' || port_arg && port_arg.url) {
|
||||
} else if (typeof portArg === 'string' || portArg && portArg.url) {
|
||||
|
||||
options = utils.clone(port_arg.url ? port_arg : host_arg || options);
|
||||
var parsed = URL.parse(port_arg.url || port_arg, true, true);
|
||||
options = utils.clone(portArg.url ? portArg : hostArg || options);
|
||||
|
||||
var parsed = URL.parse(portArg.url || portArg, true, true);
|
||||
|
||||
// [redis:]//[[user][:password]@][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]
|
||||
if (parsed.slashes) { // We require slashes
|
||||
@@ -31,7 +32,7 @@ module.exports = function createClient (port_arg, host_arg, options) {
|
||||
options.password = parsed.auth.split(':')[1];
|
||||
}
|
||||
if (parsed.protocol && parsed.protocol !== 'redis:') {
|
||||
console.warn('node_redis: WARNING: You passed "' + parsed.protocol.substring(0, parsed.protocol.length - 1) + '" as protocol instead of the "redis" protocol!');
|
||||
console.warn('nodeRedis: WARNING: You passed "' + parsed.protocol.substring(0, parsed.protocol.length - 1) + '" as protocol instead of the "redis" protocol!');
|
||||
}
|
||||
if (parsed.pathname && parsed.pathname !== '/') {
|
||||
options.db = parsed.pathname.substr(1);
|
||||
@@ -48,7 +49,7 @@ module.exports = function createClient (port_arg, host_arg, options) {
|
||||
// If options are passed twice, only the parsed options will be used
|
||||
if (elem in options) {
|
||||
if (options[elem] === parsed.query[elem]) {
|
||||
console.warn('node_redis: WARNING: You passed the ' + elem + ' option twice!');
|
||||
console.warn('nodeRedis: WARNING: You passed the ' + elem + ' option twice!');
|
||||
} else {
|
||||
throw new RangeError('The ' + elem + ' option is added twice and does not match');
|
||||
}
|
||||
@@ -59,14 +60,14 @@ module.exports = function createClient (port_arg, host_arg, options) {
|
||||
} else if (parsed.hostname) {
|
||||
throw new RangeError('The redis url must begin with slashes "//" or contain slashes after the redis protocol');
|
||||
} else {
|
||||
options.path = port_arg;
|
||||
options.path = portArg;
|
||||
}
|
||||
|
||||
} else if (typeof port_arg === 'object' || port_arg === undefined) {
|
||||
options = utils.clone(port_arg || options);
|
||||
options.host = options.host || host_arg;
|
||||
} else if (typeof portArg === 'object' || portArg === undefined) {
|
||||
options = utils.clone(portArg || options);
|
||||
options.host = options.host || hostArg;
|
||||
|
||||
if (port_arg && arguments.length !== 1) {
|
||||
if (portArg && arguments.length !== 1) {
|
||||
throw new TypeError('To many arguments passed to createClient. Please only pass the options object');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user