Skip to content

move some usage of RedisArgument arrays to ReadonlyArray #2724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/client/lib/RESP/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { RedisArgument } from './types';

const CRLF = '\r\n';

export default function encodeCommand(args: Array<RedisArgument>): Array<RedisArgument> {
export default function encodeCommand(args: ReadonlyArray<RedisArgument>): ReadonlyArray<RedisArgument> {
const toWrite: Array<RedisArgument> = [];

let strings = '*' + args.length + CRLF;
Expand Down
8 changes: 4 additions & 4 deletions packages/client/lib/client/commands-queue.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SinglyLinkedList, DoublyLinkedNode, DoublyLinkedList } from './linked-list';
import encodeCommand from '../RESP/encoder';
import { Decoder, PUSH_TYPE_MAPPING, RESP_TYPES } from '../RESP/decoder';
import { CommandArguments, TypeMapping, ReplyUnion, RespVersions } from '../RESP/types';
import { TypeMapping, ReplyUnion, RespVersions, RedisArgument } from '../RESP/types';
import { ChannelListeners, PubSub, PubSubCommand, PubSubListener, PubSubType, PubSubTypeListeners } from './pub-sub';
import { AbortError, ErrorReply } from '../errors';
import { MonitorCallback } from '.';
Expand All @@ -17,7 +17,7 @@ export interface CommandOptions<T = TypeMapping> {
}

export interface CommandToWrite extends CommandWaitingForReply {
args: CommandArguments;
args: ReadonlyArray<RedisArgument>;
chainId: symbol | undefined;
abort: {
signal: AbortSignal;
Expand Down Expand Up @@ -117,7 +117,7 @@ export default class RedisCommandsQueue {
}

addCommand<T>(
args: CommandArguments,
args: ReadonlyArray<RedisArgument>,
options?: CommandOptions
): Promise<T> {
if (this.#maxLength && this.#toWrite.length + this.#waitingForReply.length >= this.#maxLength) {
Expand Down Expand Up @@ -346,7 +346,7 @@ export default class RedisCommandsQueue {
*commandsToWrite() {
let toSend = this.#toWrite.shift();
while (toSend) {
let encoded: CommandArguments;
let encoded: ReadonlyArray<RedisArgument>
try {
encoded = encodeCommand(toSend.args);
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ export default class RedisClient<
}

sendCommand<T = ReplyUnion>(
args: Array<RedisArgument>,
args: ReadonlyArray<RedisArgument>,
options?: CommandOptions
): Promise<T> {
if (!this._self.#socket.isOpen) {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/client/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export default class RedisSocket extends EventEmitter {
});
}

write(iterable: Iterable<Array<RedisArgument>>) {
write(iterable: Iterable<ReadonlyArray<RedisArgument>>) {
if (!this.#socket) return;

this.#socket.cork();
Expand Down