MCPcopy
hub / github.com/redis/ioredis / generateScriptingFunction

Function generateScriptingFunction

lib/utils/Commander.ts:170–205  ·  view source on GitHub ↗
(
  functionName: string,
  commandName: string,
  script: Script,
  encoding: BufferEncoding | null
)

Source from the content-addressed store, hash-verified

168}
169
170function generateScriptingFunction(
171 functionName: string,
172 commandName: string,
173 script: Script,
174 encoding: BufferEncoding | null
175) {
176 return function (...args: any[]) {
177 const callback =
178 typeof args[args.length - 1] === "function" ? args.pop() : undefined;
179
180 const options: {
181 replyEncoding: BufferEncoding | null;
182 errorStack?: Error;
183 } = {
184 replyEncoding: encoding,
185 };
186
187 if (this.options.showFriendlyErrorStack) {
188 options.errorStack = new Error();
189 }
190
191 // No auto pipeline, use regular command sending
192 if (!shouldUseAutoPipelining(this, functionName, commandName)) {
193 return script.execute(this, args, options, callback);
194 }
195
196 // Create a new pipeline and make sure it's scheduled
197 return executeWithAutoPipelining(
198 this,
199 functionName,
200 commandName,
201 args,
202 callback
203 );
204 };
205}
206
207export default Commander;

Callers 1

defineCommandMethod · 0.85

Calls 3

shouldUseAutoPipeliningFunction · 0.90
executeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…