@@ -8,20 +8,17 @@ import {
88 convertMapToArray ,
99 convertObjectToArray ,
1010} from "./utils" ;
11- import { CallbackFunction , ICommand , CommandParameter } from "./types" ;
11+ import { CallbackFunction , Respondable , CommandParameter } from "./types" ;
1212
1313export type ArgumentType =
1414 | string
1515 | Buffer
1616 | number
1717 | ( string | Buffer | number | any [ ] ) [ ] ;
1818
19- interface ICommandOptions {
19+ interface CommandOptions {
2020 /**
2121 * Set the encoding of the reply, by default buffer will be returned.
22- *
23- * @type {(string | null) }
24- * @memberof ICommandOptions
2522 */
2623 replyEncoding ?: BufferEncoding | null ;
2724 errorStack ?: Error ;
@@ -34,11 +31,11 @@ interface ICommandOptions {
3431
3532type ArgumentTransformer = ( args : any [ ] ) => any [ ] ;
3633type ReplyTransformer = ( reply : any ) => any ;
37- interface IFlagMap {
34+ interface FlagMap {
3835 [ flag : string ] : { [ command : string ] : true } ;
3936}
4037
41- export interface ICommandNameFlags {
38+ export interface CommandNameFlags {
4239 // Commands that can be processed when client is in the subscriber mode
4340 VALID_IN_SUBSCRIBER_MODE : [
4441 "subscribe" ,
@@ -83,9 +80,9 @@ export interface ICommandNameFlags {
8380 * ```
8481 * @see {@link Redis#sendCommand } which can send a Command instance to Redis
8582 */
86- export default class Command implements ICommand {
83+ export default class Command implements Respondable {
8784 public static FLAGS : {
88- [ key in keyof ICommandNameFlags ] : ICommandNameFlags [ key ] ;
85+ [ key in keyof CommandNameFlags ] : CommandNameFlags [ key ] ;
8986 } = {
9087 VALID_IN_SUBSCRIBER_MODE : [
9188 "subscribe" ,
@@ -101,12 +98,12 @@ export default class Command implements ICommand {
10198 WILL_DISCONNECT : [ "quit" ] ,
10299 } ;
103100
104- private static flagMap ?: IFlagMap ;
101+ private static flagMap ?: FlagMap ;
105102
106- private static getFlagMap ( ) : IFlagMap {
103+ private static getFlagMap ( ) : FlagMap {
107104 if ( ! this . flagMap ) {
108105 this . flagMap = Object . keys ( Command . FLAGS ) . reduce (
109- ( map : IFlagMap , flagName : string ) => {
106+ ( map : FlagMap , flagName : string ) => {
110107 map [ flagName ] = { } ;
111108 Command . FLAGS [ flagName ] . forEach ( ( commandName : string ) => {
112109 map [ flagName ] [ commandName ] = true ;
@@ -126,10 +123,10 @@ export default class Command implements ICommand {
126123 * @param {string } commandName
127124 * @return {boolean }
128125 */
129- public static checkFlag < T extends keyof ICommandNameFlags > (
126+ public static checkFlag < T extends keyof CommandNameFlags > (
130127 flagName : T ,
131128 commandName : string
132- ) : commandName is ICommandNameFlags [ T ] [ number ] {
129+ ) : commandName is CommandNameFlags [ T ] [ number ] {
133130 return ! ! this . getFlagMap ( ) [ flagName ] [ commandName ] ;
134131 }
135132
@@ -177,15 +174,15 @@ export default class Command implements ICommand {
177174 * Creates an instance of Command.
178175 * @param {string } name Command name
179176 * @param {(Array<string | Buffer | number>) } [args=[]] An array of command arguments
180- * @param {ICommandOptions } [options={}]
177+ * @param {CommandOptions } [options={}]
181178 * @param {CallbackFunction } [callback] The callback that handles the response.
182179 * If omit, the response will be handled via Promise
183180 * @memberof Command
184181 */
185182 constructor (
186183 public name : string ,
187184 args : Array < ArgumentType > = [ ] ,
188- options : ICommandOptions = { } ,
185+ options : CommandOptions = { } ,
189186 callback ?: CallbackFunction
190187 ) {
191188 this . replyEncoding = options . replyEncoding ;
0 commit comments