You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
chore - remove standard and use individual config
Standard is not as up to date and still uses a old eslint version. Instead, use the airbnb default with a couple of modifications. All required changes are included.
This commit is contained in:
@ -21,10 +21,11 @@ var errors = null
|
||||
/**
|
||||
* @description Pipeline and write all commands to the stream
|
||||
*
|
||||
* If the pipelined string exceeds X mb, write it directly to the stream and pipeline the rest again.
|
||||
* If the pipelined string exceeds X mb, write it directly to the stream and
|
||||
* pipeline the rest again.
|
||||
* @param {RedisClient} client
|
||||
*/
|
||||
function writeToStream (client) {
|
||||
function writeToStream(client) {
|
||||
const stream = client._stream
|
||||
const queue = client._pipelineQueue
|
||||
const cache = client._strCache
|
||||
@ -41,7 +42,7 @@ function writeToStream (client) {
|
||||
client._pipeline = false
|
||||
}
|
||||
|
||||
function write (client) {
|
||||
function write(client) {
|
||||
if (client._pipeline === false) {
|
||||
client._stream.cork()
|
||||
client._pipeline = true
|
||||
@ -49,11 +50,11 @@ function write (client) {
|
||||
}
|
||||
}
|
||||
|
||||
function pipelineBuffers (client, commandStr) {
|
||||
function pipelineBuffers(client, commandStr) {
|
||||
const queue = client._pipelineQueue
|
||||
client._strCache += commandStr
|
||||
while (copy.length) {
|
||||
var arg = copy.shift()
|
||||
const arg = copy.shift()
|
||||
if (typeof arg === 'string') {
|
||||
client._strCache += `$${Buffer.byteLength(arg)}\r\n${arg}\r\n`
|
||||
} else {
|
||||
@ -69,20 +70,20 @@ function pipelineBuffers (client, commandStr) {
|
||||
client._strCache = ''
|
||||
}
|
||||
|
||||
function toString (arg) {
|
||||
function toString(arg) {
|
||||
if (typeof arg === 'string') {
|
||||
copy.push(arg)
|
||||
} else if (typeof arg === 'number') {
|
||||
copy.push('' + arg)
|
||||
copy.push(`${arg}`)
|
||||
} else if (arg instanceof Array) {
|
||||
for (var i = 0; i < arg.length; i += 1) {
|
||||
for (let i = 0; i < arg.length; i += 1) {
|
||||
toString(arg[i])
|
||||
}
|
||||
} else if (arg && arg.constructor.name === 'Buffer') { // TODO: check performance
|
||||
copy.push(arg)
|
||||
bufferCount++
|
||||
} else if (typeof arg === 'boolean') { // TODO: Remove this support and use hooks instead
|
||||
copy.push('' + arg)
|
||||
copy.push(`${arg}`)
|
||||
} else if (arg && arg.constructor.name === 'Object') { // Check if this is actually a good check or not
|
||||
// TODO: As soon as we add support for JSON
|
||||
// We could simple stringify this right here.
|
||||
@ -99,7 +100,7 @@ function toString (arg) {
|
||||
toString(val)
|
||||
})
|
||||
} else if (arg instanceof Set) {
|
||||
arg.forEach((val) => toString(val))
|
||||
arg.forEach(val => toString(val))
|
||||
} else if (arg && arg.constructor.name === 'Date') { // Check if this is actually a good check or not
|
||||
copy.push(arg.toString())
|
||||
} else {
|
||||
@ -110,7 +111,7 @@ function toString (arg) {
|
||||
}
|
||||
}
|
||||
|
||||
function returnErr (client, command) {
|
||||
function returnErr(client, command) {
|
||||
const err = new TypeError('NodeRedis can not handle the provided arguments (see "error.issues" property).\n\nFurther information https://github.com/asd')
|
||||
err.command = command.command.toUpperCase()
|
||||
err.args = command.args
|
||||
@ -119,13 +120,14 @@ function returnErr (client, command) {
|
||||
utils.replyInOrder(client, command.callback, err, undefined, client.commandQueue)
|
||||
}
|
||||
|
||||
// Always use 'Multi bulk commands', but if passed any Buffer args, then do multiple writes, one for each arg.
|
||||
// This means that using Buffers in commands is going to be slower, so use Strings if you don't already have a Buffer.
|
||||
// Always use 'Multi bulk commands', but if passed any Buffer args, then do
|
||||
// multiple writes, one for each arg. This means that using Buffers in commands
|
||||
// is going to be slower, so use Strings if you don't already have a Buffer.
|
||||
|
||||
// TODO: It is faster to move this part somewhere else
|
||||
// We could move this to the function creation as well
|
||||
// if we use hooks for our individual commands!
|
||||
function normalizeAndWrite (client, command) {
|
||||
function normalizeAndWrite(client, command) {
|
||||
const args = command.args
|
||||
const origName = command.command
|
||||
const renameCommands = client._options.renameCommands
|
||||
@ -134,7 +136,7 @@ function normalizeAndWrite (client, command) {
|
||||
: origName
|
||||
|
||||
bufferCount = 0
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
toString(args[i])
|
||||
}
|
||||
|
||||
@ -153,7 +155,7 @@ function normalizeAndWrite (client, command) {
|
||||
|
||||
const bufferArgs = bufferCount !== 0
|
||||
const len = copy.length
|
||||
var commandStr = `*${len + 1}\r\n$${name.length}\r\n${name}\r\n`
|
||||
let commandStr = `*${len + 1}\r\n$${name.length}\r\n${name}\r\n`
|
||||
|
||||
command.bufferArgs = bufferArgs
|
||||
command.argsLength = len
|
||||
|
Reference in New Issue
Block a user