MCPcopy
hub / github.com/redis/node-redis / reset

Method reset

packages/client/lib/client/commands-queue.ts:515–546  ·  view source on GitHub ↗
(chainId: symbol, typeMapping?: T)

Source from the content-addressed store, hash-verified

513 #resetFallbackOnReply?: Decoder["onReply"];
514
515 async reset<T extends TypeMapping>(chainId: symbol, typeMapping?: T) {
516 return new Promise((resolve, reject) => {
517 // overriding onReply to handle `RESET` while in `MONITOR` or PubSub mode
518 this.#resetFallbackOnReply = this.decoder.onReply;
519 this.decoder.onReply = ((reply) => {
520 if (
521 (typeof reply === "string" && reply === "RESET") ||
522 (reply instanceof Buffer && RESET.equals(reply))
523 ) {
524 this.#resetDecoderCallbacks();
525 this.#resetFallbackOnReply = undefined;
526 this.#pubSub.reset();
527
528 this.#waitingForReply.shift()!.resolve(reply);
529 return;
530 }
531
532 this.#resetFallbackOnReply!(reply);
533 }) as Decoder["onReply"];
534
535 this.#toWrite.push({
536 args: ["RESET"],
537 chainId,
538 abort: undefined,
539 timeout: undefined,
540 resolve,
541 reject,
542 channelsCounter: undefined,
543 typeMapping,
544 });
545 });
546 }
547
548 isWaitingToWrite() {
549 return this.#toWrite.length > 0;

Callers 4

resetDecoderMethod · 0.45
#flushWaitingForReplyMethod · 0.45
flushWaitingForReplyMethod · 0.45
flushAllMethod · 0.45

Calls 4

resolveMethod · 0.65
shiftMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected