source: node_modules/nodemailer/lib/mime-node/last-newline.js

main
Last change on this file was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 670 bytes
Line 
1'use strict';
2
3const Transform = require('stream').Transform;
4
5class LastNewline extends Transform {
6 constructor() {
7 super();
8 this.lastByte = false;
9 }
10
11 _transform(chunk, encoding, done) {
12 if (chunk.length) {
13 this.lastByte = chunk[chunk.length - 1];
14 }
15
16 this.push(chunk);
17 done();
18 }
19
20 _flush(done) {
21 if (this.lastByte === 0x0a) {
22 return done();
23 }
24 if (this.lastByte === 0x0d) {
25 this.push(Buffer.from('\n'));
26 return done();
27 }
28 this.push(Buffer.from('\r\n'));
29 return done();
30 }
31}
32
33module.exports = LastNewline;
Note: See TracBrowser for help on using the repository browser.