Skip to content

Commit e57ed63

Browse files
fix(deps): drop dependency on through2 (#457)
1 parent 6b9ce77 commit e57ed63

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@
5757
"google-gax": "^1.0.0",
5858
"is": "^3.3.0",
5959
"split-array-stream": "^2.0.0",
60-
"stream-events": "^1.0.5",
61-
"through2": "^3.0.1"
60+
"stream-events": "^1.0.5"
6261
},
6362
"devDependencies": {
6463
"@types/extend": "^3.0.1",
@@ -68,7 +67,6 @@
6867
"@types/ncp": "^2.0.1",
6968
"@types/proxyquire": "^1.3.28",
7069
"@types/sinon": "^7.0.11",
71-
"@types/through2": "^2.0.34",
7270
"@types/tmp": "0.1.0",
7371
"assert-rejects": "^1.0.0",
7472
"codecov": "^3.5.0",

samples/.eslintrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
---
22
rules:
33
no-console: off
4+
require-atomic-updates: off

src/request.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const concat = require('concat-stream');
2222
import * as extend from 'extend';
2323
import {split} from 'split-array-stream';
2424
import * as streamEvents from 'stream-events';
25-
import * as through from 'through2';
2625
import {google} from '../proto/datastore';
2726
import {CallOptions} from 'google-gax';
2827
import {Transform} from 'stream';
@@ -302,7 +301,7 @@ class DatastoreRequest {
302301
);
303302
};
304303

305-
const stream = streamEvents(through.obj());
304+
const stream = streamEvents(new Transform({objectMode: true}));
306305
stream.once('reading', () => {
307306
makeRequest(keys);
308307
});
@@ -778,7 +777,7 @@ class DatastoreRequest {
778777
});
779778
}
780779

781-
const stream = streamEvents(through.obj());
780+
const stream = streamEvents(new Transform({objectMode: true}));
782781
stream.once('reading', () => {
783782
makeRequest(query);
784783
});

test/request.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ import * as pjy from '@google-cloud/projectify';
1818
import * as pfy from '@google-cloud/promisify';
1919
import * as assert from 'assert';
2020
import * as extend from 'extend';
21-
import {CallOptions} from '@grpc/grpc-js';
2221
import * as is from 'is';
2322
import * as proxyquire from 'proxyquire';
2423
import * as sinon from 'sinon';
25-
import * as through from 'through2';
24+
import {Transform} from 'stream';
2625

2726
import {google} from '../proto/datastore';
2827
import * as ds from '../src';
@@ -367,12 +366,11 @@ describe('Request', () => {
367366

368367
it('should end stream', done => {
369368
const stream = request.createReadStream(key);
370-
371369
stream
372370
.on('data', () => {})
373371
.on('error', () => {
374372
setImmediate(() => {
375-
assert.strictEqual((stream as Any)._destroyed, true);
373+
assert.strictEqual(stream.destroyed, true);
376374
done();
377375
});
378376
});
@@ -604,7 +602,7 @@ describe('Request', () => {
604602

605603
beforeEach(() => {
606604
request.createReadStream = sandbox.spy(() => {
607-
const stream = through.obj();
605+
const stream = new Transform({objectMode: true});
608606
setImmediate(() => {
609607
fakeEntities.forEach(entity => stream.push(entity));
610608
stream.push(null);
@@ -656,7 +654,7 @@ describe('Request', () => {
656654

657655
beforeEach(() => {
658656
request.createReadStream = sandbox.spy(() => {
659-
const stream = through.obj();
657+
const stream = new Transform({objectMode: true});
660658
setImmediate(() => {
661659
stream.emit('error', error);
662660
});
@@ -1081,7 +1079,7 @@ describe('Request', () => {
10811079

10821080
beforeEach(() => {
10831081
request.runQueryStream = sandbox.spy(() => {
1084-
const stream = through.obj();
1082+
const stream = new Transform({objectMode: true});
10851083

10861084
setImmediate(() => {
10871085
stream.emit('info', fakeInfo);
@@ -1139,7 +1137,7 @@ describe('Request', () => {
11391137

11401138
beforeEach(() => {
11411139
request.runQueryStream = sandbox.spy(() => {
1142-
const stream = through.obj();
1140+
const stream = new Transform({objectMode: true});
11431141

11441142
setImmediate(() => {
11451143
stream.emit('error', error);

0 commit comments

Comments
 (0)