Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed May 2, 2024
1 parent d893bce commit 3394fac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
36 changes: 18 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,23 +365,23 @@ exports.get_public_ip_async = require('./lib/get_public_ip').get_public_ip_async
exports.HarakaMx = require('./lib/HarakaMx')

exports.add_line_processor = (socket) => {
const line_regexp = /^([^\n]*\n)/; // utils.line_regexp
let current_data = '';

socket.on('data', (data) => {
current_data += data;
let results;
while ((results = line_regexp.exec(current_data))) {
const this_line = results[1];
current_data = current_data.slice(this_line.length);
socket.emit('line', this_line);
}
})
const line_regexp = /^([^\n]*\n)/ // utils.line_regexp
let current_data = ''

socket.on('data', (data) => {
current_data += data
let results
while ((results = line_regexp.exec(current_data))) {
const this_line = results[1]
current_data = current_data.slice(this_line.length)
socket.emit('line', this_line)
}
})

socket.on('end', () => {
if (current_data.length) {
socket.emit('line', current_data);
}
current_data = '';
})
socket.on('end', () => {
if (current_data.length) {
socket.emit('line', current_data)
}
current_data = ''
})
}
4 changes: 2 additions & 2 deletions test/net_utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('node:assert')
const EventEmitter = require('node:events');
const EventEmitter = require('node:events')
const os = require('node:os')
const path = require('node:path')

Expand Down Expand Up @@ -551,7 +551,7 @@ describe('add_line_processor', function () {
socket.on('line', () => {
lines++
})
socket.on('end', (e) => {
socket.on('end', () => {
assert.equal(lines, 3)
done()
})
Expand Down

0 comments on commit 3394fac

Please sign in to comment.