Skip to content

Commit

Permalink
Replace concat-stream with get-stream (#1123)
Browse files Browse the repository at this point in the history
* Replace concat-stream with get-stream

Ref https://packagephobia.com/result?p=concat-stream https://packagephobia.com/result?p=get-stream

Concat-stream is a big package with not relevant in node 10 dependencies.
In this diff I replaced it with dependency-free get-stream with promise
based api.

* Add node 10, 12 and 14 to travis config

* Fix lint
  • Loading branch information
TrySound authored Sep 29, 2020
1 parent 8884a96 commit 471073b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 61 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ language: node_js
notifications:
email: false
node_js:
- "9"
- "8"
- "7"
- "6"
- "10"
- "12"
- "14"
- "lts/*"
env:
- CXX=g++-4.8
Expand Down
82 changes: 30 additions & 52 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"author": "Vinay Pulim <[email protected]>",
"dependencies": {
"bluebird": "^3.5.0",
"concat-stream": "^2.0.0",
"debug": "^4.1.1",
"get-stream": "^6.0.0",
"httpntlm": "^1.5.2",
"lodash": "^4.17.19",
"request": ">=2.9.0",
Expand Down
7 changes: 3 additions & 4 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import * as assert from 'assert';
import * as BluebirdPromise from 'bluebird';
import * as concatStream from 'concat-stream';
import * as debugBuilder from 'debug';
import { EventEmitter } from 'events';
import getStream = require('get-stream');
import { IncomingHttpHeaders } from 'http';
import * as _ from 'lodash';
import * as request from 'request';
Expand Down Expand Up @@ -476,15 +476,14 @@ export class Client extends EventEmitter {
// When the output element cannot be looked up in the wsdl, play it safe and
// don't stream
if (response.statusCode !== 200 || !output || !output.$lookupTypes) {
response.pipe(concatStream({encoding: 'string'}, (body) => {
getStream(response).then((body) => {
this.lastResponse = body;
this.lastResponseHeaders = response && response.headers;
this.lastElapsedTime = Date.now() - startTime;
this.emit('response', body, response, eid);

return parseSync(body, response);

}));
});
return;
}

Expand Down

0 comments on commit 471073b

Please sign in to comment.