Skip to content

Commit

Permalink
Replace pump with pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed Aug 19, 2020
1 parent f14182b commit f2c5f06
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 34 deletions.
5 changes: 2 additions & 3 deletions lib/commands/hdr.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
'use strict';


const pump = require('pump');
const status = require('../status');
const { Readable, Transform } = require('stream');
const { Readable, Transform, pipeline } = require('stream');


const CMD_RE = /^X?HDR ([^\s]+)(?: (?:(\d{1,15})(-(\d{1,15})?)?|(<[^\s<>]+>))?)?$/i;
Expand Down Expand Up @@ -85,7 +84,7 @@ module.exports = {
}
});

pump(article_stream, stream);
pipeline(article_stream, stream, () => {});

return stream;
}
Expand Down
5 changes: 2 additions & 3 deletions lib/commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
'use strict';


const pump = require('pump');
const status = require('../status');
const { Readable, Transform } = require('stream');
const { Readable, Transform, pipeline } = require('stream');

const CMD_RE = /^LIST( (.+))?$/i;

Expand All @@ -32,7 +31,7 @@ module.exports = {
}
});

pump(groups, stream);
pipeline(groups, stream, () => {});

return [
status._215_INFO_FOLLOWS,
Expand Down
5 changes: 2 additions & 3 deletions lib/commands/list_active.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
'use strict';


const pump = require('pump');
const status = require('../status');
const wildmat_re = require('../wildmat');
const { Readable, Transform } = require('stream');
const { Readable, Transform, pipeline } = require('stream');


const CMD_RE = /^LIST ACTIVE( ([^\s]+))?$/i;
Expand Down Expand Up @@ -40,7 +39,7 @@ module.exports = {
}
});

pump(groups, stream);
pipeline(groups, stream, () => {});

return [
status._215_INFO_FOLLOWS,
Expand Down
5 changes: 2 additions & 3 deletions lib/commands/list_newsgroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
'use strict';


const pump = require('pump');
const status = require('../status');
const wildmat_re = require('../wildmat');
const { Readable, Transform } = require('stream');
const { Readable, Transform, pipeline } = require('stream');


const CMD_RE = /^LIST NEWSGROUPS( ([^\s]+))?$/i;
Expand Down Expand Up @@ -40,7 +39,7 @@ module.exports = {
}
});

pump(groups, stream);
pipeline(groups, stream, () => {});

return [
status._215_INFO_FOLLOWS,
Expand Down
5 changes: 2 additions & 3 deletions lib/commands/listgroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
'use strict';


const pump = require('pump');
const status = require('../status');
const { Readable, Transform } = require('stream');
const { Readable, Transform, pipeline } = require('stream');


const CMD_RE = /^LISTGROUP( ([^\s]+)( (\d{1,15})((-)(\d{1,15})?)?)?)?$/i;
Expand Down Expand Up @@ -65,7 +64,7 @@ module.exports = {
}
});

pump(articles, stream);
pipeline(articles, stream, () => {});

return [
`${status._211_GRP_SELECTED} ${g.total} ${g.min_index} ${g.max_index} ${name} list follows`,
Expand Down
5 changes: 2 additions & 3 deletions lib/commands/newgroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
'use strict';


const pump = require('pump');
const status = require('../status');
const { Readable, Transform } = require('stream');
const { Readable, Transform, pipeline } = require('stream');


const CMD_RE = /^NEWGROUPS (\d{6,8})\s(\d{6})(?:\sGMT)?$/i;
Expand Down Expand Up @@ -49,7 +48,7 @@ module.exports = {
}
});

pump(groups, stream);
pipeline(groups, stream, () => {});

return [
status._215_INFO_FOLLOWS,
Expand Down
5 changes: 2 additions & 3 deletions lib/commands/newnews.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
'use strict';


const pump = require('pump');
const status = require('../status');
const wildmat_re = require('../wildmat');
const { Readable, Transform } = require('stream');
const { Readable, Transform, pipeline } = require('stream');


const CMD_RE = /^NEWNEWS ([^\s]+)\s(\d{6,8})\s(\d{6})(?:\sGMT)?$/i;
Expand Down Expand Up @@ -60,7 +59,7 @@ module.exports = {
}
});

pump(newnews, stream);
pipeline(newnews, stream, () => {});

return [
status._230_NEWNEWS_FOLLOW,
Expand Down
5 changes: 2 additions & 3 deletions lib/commands/over.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
'use strict';


const pump = require('pump');
const status = require('../status');
const { Readable, Transform } = require('stream');
const { Readable, Transform, pipeline } = require('stream');


const CMD_RE = /^X?OVER(?: (?:(\d{1,15})(-(\d{1,15})?)?|(<[^\s<>]+>))?)?$/i;
Expand Down Expand Up @@ -93,7 +92,7 @@ module.exports = {
}
});

pump(article_stream, stream);
pipeline(article_stream, stream, () => {});

return stream;
}
Expand Down
3 changes: 1 addition & 2 deletions lib/flatten-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

const Denque = require('denque');
const destroy = require('destroy');
const eos = require('end-of-stream');
const stream = require('stream');
const util = require('util');

Expand Down Expand Up @@ -133,7 +132,7 @@ FlattenStream.prototype._read = function () {
data.on('readable', this.top_chunk_read_fn);
this.top_chunk_read_fn();

eos(data, err => {
stream.finished(data, err => {
data.removeListener('readable', this.top_chunk_read_fn);

if (err) {
Expand Down
8 changes: 4 additions & 4 deletions lib/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const debug_net = require('debug')('nntp-server.network');
const destroy = require('destroy');
const serializeError = require('serialize-error').serializeError;
const split2 = require('split2');
const pump = require('pump');
const pipeline = require('stream').pipeline;
const flattenStream = require('./flatten-stream');
const status = require('./status');

Expand Down Expand Up @@ -84,14 +84,14 @@ function Session(server, stream) {

this.write(status._201_SRV_READY_RO);

pump(stream, this.lines);
pipeline(stream, this.lines, () => {});

pump(this.out_stream, stream);
pipeline(this.out_stream, stream, () => {});

if (debug_net.enabled) {
let debug_logger = split2();

pump(this.out_stream, debug_logger);
pipeline(this.out_stream, debug_logger, () => {});

debug_logger.on('data', line => {
debug_net('<-- [%s] %s', this.debug_mark, line);
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"debug": "^4.0.0",
"denque": "^1.1.1",
"destroy": "^1.0.4",
"end-of-stream": "^1.4.0",
"pump": "^3.0.0",
"serialize-error": "^7.0.1",
"split2": "^3.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/asline.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


const assert = require('assert');
const pump = require('pump');
const pipeline = require('stream').pipeline;
const split2 = require('split2');
const util = require('util');

Expand All @@ -18,7 +18,7 @@ function AsLine(stream, options = {}) {
this._timeout = options.timeout;
this._linebreak = options.linebreak || '\r\n';

pump(stream, this._input);
pipeline(stream, this._input, () => {});
}


Expand Down

0 comments on commit f2c5f06

Please sign in to comment.