File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ export interface Redis extends RedisCommands {
112112 ) : Promise < RedisReply > ;
113113 connect ( ) : Promise < void > ;
114114 close ( ) : void ;
115+ [ Symbol . dispose ] ( ) : void ;
115116}
116117
117118class RedisImpl implements Redis {
@@ -142,7 +143,11 @@ class RedisImpl implements Redis {
142143 }
143144
144145 close ( ) : void {
145- this . executor . close ( ) ;
146+ return this . executor . close ( ) ;
147+ }
148+
149+ [ Symbol . dispose ] ( ) : void {
150+ return this . close ( ) ;
146151 }
147152
148153 async execReply < T extends Raw = Raw > (
Original file line number Diff line number Diff line change @@ -143,6 +143,14 @@ export function connectionTests(
143143 client . close ( ) ;
144144 } ) ;
145145 } ) ;
146+
147+ describe ( "using" , ( ) => {
148+ it ( "implements `Symbol.dispose`" , async ( ) => {
149+ using client = await connect ( getOpts ( ) ) ;
150+ assert ( client . isConnected ) ;
151+ assert ( ! client . isClosed ) ;
152+ } ) ;
153+ } ) ;
146154}
147155
148156function parseCommandStats (
You can’t perform that action at this time.
0 commit comments