You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-17 19:41:06 +03:00
clean code
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const cronometro = require('cronometro'),
|
||||
newRedis = require('redis-new'),
|
||||
oldRedis = require('redis-old');
|
||||
|
@@ -6,12 +6,12 @@ import { RedisReply } from './commands';
|
||||
export interface QueueCommandOptions {
|
||||
asap?: boolean;
|
||||
signal?: AbortSignal;
|
||||
chainId?: Symbol;
|
||||
chainId?: symbol;
|
||||
}
|
||||
|
||||
interface CommandWaitingToBeSent extends CommandWaitingForReply {
|
||||
encodedCommand: string;
|
||||
chainId?: Symbol;
|
||||
chainId?: symbol;
|
||||
abort?: {
|
||||
signal: AbortSignal;
|
||||
listener(): void;
|
||||
@@ -119,7 +119,7 @@ export default class RedisCommandsQueue {
|
||||
returnError: (err: Error) => this.#shiftWaitingForReply().reject(err)
|
||||
});
|
||||
|
||||
#chainInExecution: Symbol | undefined;
|
||||
#chainInExecution: symbol | undefined;
|
||||
|
||||
constructor(maxLength: number | null | undefined, executor: CommandsQueueExecutor) {
|
||||
this.#maxLength = maxLength;
|
||||
@@ -293,7 +293,7 @@ export default class RedisCommandsQueue {
|
||||
|
||||
const encoded: Array<string> = [];
|
||||
let size = 0,
|
||||
lastCommandChainId: Symbol | undefined;
|
||||
lastCommandChainId: symbol | undefined;
|
||||
for (const command of this.#waitingToBeSent) {
|
||||
encoded.push(command.encodedCommand);
|
||||
size += command.encodedCommand.length;
|
||||
|
@@ -31,7 +31,7 @@ interface AclLog {
|
||||
context: string;
|
||||
object: string;
|
||||
username: string;
|
||||
ageSeconds: Number;
|
||||
ageSeconds: number;
|
||||
clientInfo: string;
|
||||
}
|
||||
|
||||
|
@@ -95,8 +95,6 @@ describe('CLUSTER NODES', () => {
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.clusterNodes', async cluster => {
|
||||
const nodes = await cluster.clusterNodes();
|
||||
|
||||
for (const node of (await cluster.clusterNodes())) {
|
||||
assert.equal(typeof node.id, 'string');
|
||||
assert.equal(typeof node.url, 'string');
|
||||
|
@@ -81,7 +81,7 @@ describe('SET', () => {
|
||||
it('with GET', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'value', {
|
||||
GET: 1
|
||||
GET: true
|
||||
}),
|
||||
['SET', 'key', 'value', 'GET']
|
||||
);
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { triggerAsyncId } from 'async_hooks';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments, transformReply } from './XINFO_STREAM';
|
||||
|
||||
|
@@ -32,11 +32,4 @@ export function transformArguments(
|
||||
return args;
|
||||
}
|
||||
|
||||
interface XPendingReply {
|
||||
messageId: string;
|
||||
owner: string;
|
||||
msSinceLastDelivery: number;
|
||||
deliveriesCounter: number;
|
||||
}
|
||||
|
||||
export const transformReply = transformReplyStreamMessages;
|
||||
|
@@ -25,7 +25,7 @@ export interface MultiQueuedCommand {
|
||||
transformReply?: RedisCommand['transformReply'];
|
||||
}
|
||||
|
||||
export type RedisMultiExecutor = (queue: Array<MultiQueuedCommand>, chainId?: Symbol) => Promise<Array<RedisReply>>;
|
||||
export type RedisMultiExecutor = (queue: Array<MultiQueuedCommand>, chainId?: symbol) => Promise<Array<RedisReply>>;
|
||||
|
||||
export default class RedisMultiCommand<M extends RedisModules = RedisModules, S extends RedisLuaScripts = RedisLuaScripts> {
|
||||
static defineCommand(on: any, name: string, command: RedisCommand): void {
|
||||
|
@@ -217,11 +217,9 @@ export async function spawnRedisCluster(type: TestRedisClusters | null, numberOf
|
||||
export async function spawnGlobalRedisCluster(type: TestRedisClusters | null, numberOfNodes: number, args?: Array<string>): Promise<Array<number>> {
|
||||
const results = await spawnRedisCluster(type, numberOfNodes, args);
|
||||
|
||||
after(() => {
|
||||
for (const { cleanup } of results) {
|
||||
cleanup();
|
||||
}
|
||||
});
|
||||
after(() => Promise.all(
|
||||
results.map(({ cleanup }) => cleanup())
|
||||
));
|
||||
|
||||
return results.map(({ port }) => port);
|
||||
}
|
||||
|
Reference in New Issue
Block a user