1
0
mirror of https://github.com/eleith/emailjs.git synced 2024-07-02 11:08:51 +00:00

smtp/message: remove eslint-disable comments

This commit is contained in:
Zack Schuster 2020-07-27 02:19:10 -07:00
parent 10cfc1a2b9
commit ce7094ec08

View File

@ -236,7 +236,6 @@ export class Message {
* @returns {*} a stream of the current message * @returns {*} a stream of the current message
*/ */
public stream() { public stream() {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
return new MessageStream(this); return new MessageStream(this);
} }
@ -441,22 +440,20 @@ class MessageStream extends Stream {
attachment: MessageAttachment, attachment: MessageAttachment,
callback: () => void callback: () => void
) => { ) => {
if (attachment.stream != null && attachment.stream.readable) { const { stream } = attachment;
if (stream?.readable) {
let previous = Buffer.alloc(0); let previous = Buffer.alloc(0);
attachment.stream.resume(); stream.resume();
attachment.stream.on('end', () => { stream.on('end', () => {
output_base64(previous.toString('base64'), callback); output_base64(previous.toString('base64'), callback);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.removeListener('pause', stream.pause);
this.removeListener('pause', attachment.stream!.pause); this.removeListener('resume', stream.resume);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.removeListener('error', stream.resume);
this.removeListener('resume', attachment.stream!.resume);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.removeListener('error', attachment.stream!.resume);
}); });
attachment.stream.on('data', (buff) => { stream.on('data', (buff) => {
// do we have bytes from a previous stream data event? // do we have bytes from a previous stream data event?
let buffer = Buffer.isBuffer(buff) ? buff : Buffer.from(buff); let buffer = Buffer.isBuffer(buff) ? buff : Buffer.from(buff);
@ -475,9 +472,9 @@ class MessageStream extends Stream {
output_base64(buffer.toString('base64', 0, buffer.length - padded)); output_base64(buffer.toString('base64', 0, buffer.length - padded));
}); });
this.on('pause', attachment.stream.pause); this.on('pause', stream.pause);
this.on('resume', attachment.stream.resume); this.on('resume', stream.resume);
this.on('error', attachment.stream.resume); this.on('error', stream.resume);
} else { } else {
this.emit('error', { message: 'stream not readable' }); this.emit('error', { message: 'stream not readable' });
} }