Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): drop dependency on through2 #457

Merged
merged 2 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
1 change: 1 addition & 0 deletions samples/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
rules:
no-console: off
require-atomic-updates: off
5 changes: 2 additions & 3 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -302,7 +301,7 @@ class DatastoreRequest {
);
};

const stream = streamEvents(through.obj());
const stream = streamEvents(new Transform({objectMode: true}));
stream.once('reading', () => {
makeRequest(keys);
});
Expand Down Expand Up @@ -778,7 +777,7 @@ class DatastoreRequest {
});
}

const stream = streamEvents(through.obj());
const stream = streamEvents(new Transform({objectMode: true}));
stream.once('reading', () => {
makeRequest(query);
});
Expand Down
14 changes: 6 additions & 8 deletions test/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
});
});
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down