From 8550382a783d0f7d75b11b3859facb734f06836e Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Fri, 19 Jul 2019 08:18:06 -0700 Subject: [PATCH 1/2] fix(deps): drop dependency on through2 --- package.json | 4 +--- src/request.ts | 5 ++--- test/request.ts | 14 ++++++-------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index c028184db..100a5ed4c 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,7 @@ "google-gax": "^1.0.0", "is": "^3.3.0", "split-array-stream": "^2.0.0", - "stream-events": "^1.0.5", - "through2": "^3.0.1" + "stream-events": "^1.0.5" }, "devDependencies": { "@types/extend": "^3.0.1", @@ -68,7 +67,6 @@ "@types/ncp": "^2.0.1", "@types/proxyquire": "^1.3.28", "@types/sinon": "^7.0.11", - "@types/through2": "^2.0.34", "@types/tmp": "0.1.0", "assert-rejects": "^1.0.0", "codecov": "^3.5.0", diff --git a/src/request.ts b/src/request.ts index a6c7533a1..7bec27397 100644 --- a/src/request.ts +++ b/src/request.ts @@ -22,7 +22,6 @@ const concat = require('concat-stream'); import * as extend from 'extend'; import {split} from 'split-array-stream'; import * as streamEvents from 'stream-events'; -import * as through from 'through2'; import {google} from '../proto/datastore'; import {CallOptions} from 'google-gax'; import {Transform} from 'stream'; @@ -302,7 +301,7 @@ class DatastoreRequest { ); }; - const stream = streamEvents(through.obj()); + const stream = streamEvents(new Transform({objectMode: true})); stream.once('reading', () => { makeRequest(keys); }); @@ -778,7 +777,7 @@ class DatastoreRequest { }); } - const stream = streamEvents(through.obj()); + const stream = streamEvents(new Transform({objectMode: true})); stream.once('reading', () => { makeRequest(query); }); diff --git a/test/request.ts b/test/request.ts index 246c40921..8e704be96 100644 --- a/test/request.ts +++ b/test/request.ts @@ -18,11 +18,10 @@ import * as pjy from '@google-cloud/projectify'; import * as pfy from '@google-cloud/promisify'; import * as assert from 'assert'; import * as extend from 'extend'; -import {CallOptions} from '@grpc/grpc-js'; import * as is from 'is'; import * as proxyquire from 'proxyquire'; import * as sinon from 'sinon'; -import * as through from 'through2'; +import { Transform } from 'stream'; import {google} from '../proto/datastore'; import * as ds from '../src'; @@ -367,12 +366,11 @@ describe('Request', () => { it('should end stream', done => { const stream = request.createReadStream(key); - stream .on('data', () => {}) .on('error', () => { setImmediate(() => { - assert.strictEqual((stream as Any)._destroyed, true); + assert.strictEqual(stream.destroyed, true); done(); }); }); @@ -604,7 +602,7 @@ describe('Request', () => { beforeEach(() => { request.createReadStream = sandbox.spy(() => { - const stream = through.obj(); + const stream = new Transform({objectMode: true}); setImmediate(() => { fakeEntities.forEach(entity => stream.push(entity)); stream.push(null); @@ -656,7 +654,7 @@ describe('Request', () => { beforeEach(() => { request.createReadStream = sandbox.spy(() => { - const stream = through.obj(); + const stream = new Transform({objectMode: true}); setImmediate(() => { stream.emit('error', error); }); @@ -1081,7 +1079,7 @@ describe('Request', () => { beforeEach(() => { request.runQueryStream = sandbox.spy(() => { - const stream = through.obj(); + const stream = new Transform({objectMode: true}); setImmediate(() => { stream.emit('info', fakeInfo); @@ -1139,7 +1137,7 @@ describe('Request', () => { beforeEach(() => { request.runQueryStream = sandbox.spy(() => { - const stream = through.obj(); + const stream = new Transform({objectMode: true}); setImmediate(() => { stream.emit('error', error); From d33ba3e8b28c17396cb853c92932b49ccce49768 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Fri, 19 Jul 2019 13:13:24 -0700 Subject: [PATCH 2/2] fixy --- samples/.eslintrc.yml | 1 + test/request.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/.eslintrc.yml b/samples/.eslintrc.yml index 282535f55..aee43ae4b 100644 --- a/samples/.eslintrc.yml +++ b/samples/.eslintrc.yml @@ -1,3 +1,4 @@ --- rules: no-console: off + require-atomic-updates: off diff --git a/test/request.ts b/test/request.ts index 8e704be96..a6a1d0db3 100644 --- a/test/request.ts +++ b/test/request.ts @@ -21,7 +21,7 @@ import * as extend from 'extend'; import * as is from 'is'; import * as proxyquire from 'proxyquire'; import * as sinon from 'sinon'; -import { Transform } from 'stream'; +import {Transform} from 'stream'; import {google} from '../proto/datastore'; import * as ds from '../src';