@@ -172,21 +172,21 @@ export class GridFSBucketWriteStream extends Writable implements NodeJS.Writable
172
172
* @param encoding - Optional encoding for the buffer
173
173
* @param callback - Function to call when all files and chunks have been persisted to MongoDB
174
174
*/
175
- end ( ) : void ;
176
- end ( chunk : Buffer ) : void ;
177
- end ( callback : Callback < GridFSFile | void > ) : void ;
178
- end ( chunk : Buffer , callback : Callback < GridFSFile | void > ) : void ;
179
- end ( chunk : Buffer , encoding : BufferEncoding ) : void ;
175
+ end ( ) : this ;
176
+ end ( chunk : Buffer ) : this ;
177
+ end ( callback : Callback < GridFSFile | void > ) : this ;
178
+ end ( chunk : Buffer , callback : Callback < GridFSFile | void > ) : this ;
179
+ end ( chunk : Buffer , encoding : BufferEncoding ) : this ;
180
180
end (
181
181
chunk : Buffer ,
182
182
encoding : BufferEncoding | undefined ,
183
183
callback : Callback < GridFSFile | void >
184
- ) : void ;
184
+ ) : this ;
185
185
end (
186
186
chunkOrCallback ?: Buffer | Callback < GridFSFile | void > ,
187
187
encodingOrCallback ?: BufferEncoding | Callback < GridFSFile | void > ,
188
188
callback ?: Callback < GridFSFile | void >
189
- ) : void {
189
+ ) : this {
190
190
const chunk = typeof chunkOrCallback === 'function' ? undefined : chunkOrCallback ;
191
191
const encoding = typeof encodingOrCallback === 'function' ? undefined : encodingOrCallback ;
192
192
callback =
@@ -196,7 +196,7 @@ export class GridFSBucketWriteStream extends Writable implements NodeJS.Writable
196
196
? encodingOrCallback
197
197
: callback ;
198
198
199
- if ( checkAborted ( this , callback ) ) return ;
199
+ if ( checkAborted ( this , callback ) ) return this ;
200
200
201
201
this . state . streamEnd = true ;
202
202
@@ -208,12 +208,14 @@ export class GridFSBucketWriteStream extends Writable implements NodeJS.Writable
208
208
209
209
if ( ! chunk ) {
210
210
waitForIndexes ( this , ( ) => ! ! writeRemnant ( this ) ) ;
211
- return ;
211
+ return this ;
212
212
}
213
213
214
214
this . write ( chunk , encoding , ( ) => {
215
215
writeRemnant ( this ) ;
216
216
} ) ;
217
+
218
+ return this ;
217
219
}
218
220
}
219
221
0 commit comments