( functionName: string, commandName: string, script: Script, encoding: BufferEncoding | null )
| 168 | } |
| 169 | |
| 170 | function 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 | |
| 207 | export default Commander; |
no test coverage detected
searching dependent graphs…