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(ts): drop dependency on @types/duplexify #458

Merged
merged 1 commit into from
Mar 28, 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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"dependencies": {
"@grpc/grpc-js": "^0.3.0",
"@grpc/proto-loader": "^0.4.0",
"@types/duplexify": "^3.6.0",
"duplexify": "^3.6.0",
"google-auth-library": "^3.0.0",
"google-proto-files": "^0.20.0",
Expand Down
28 changes: 25 additions & 3 deletions src/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,35 @@

/* This file describes the gRPC-streaming. */

import * as Duplexify from 'duplexify';
import {Duplex, DuplexOptions, Stream} from 'stream';
import {Duplex, DuplexOptions, Readable, Stream, Writable} from 'stream';

import {APICall, APICallback} from './apiCallable';
import {warn} from './warnings';

const duplexify: DuplexifyConstructor = require('duplexify');
const retryRequest = require('retry-request');

// Directly copy over Duplexify interfaces
export interface DuplexifyOptions extends DuplexOptions {
autoDestroy?: boolean;
end?: boolean;
}

export interface Duplexify extends Duplex {
readonly destroyed: boolean;
setWritable(writable: Writable|false|null): void;
setReadable(readable: Readable|false|null): void;
}

export interface DuplexifyConstructor {
obj(writable?: Writable|false|null, readable?: Readable|false|null,
options?: DuplexifyOptions): Duplexify;
new(writable?: Writable|false|null, readable?: Readable|false|null,
options?: DuplexifyOptions): Duplexify;
(writable?: Writable|false|null, readable?: Readable|false|null,
options?: DuplexifyOptions): Duplexify;
}

/**
* The type of gRPC streaming.
* @enum {number}
Expand All @@ -53,7 +75,7 @@ export enum StreamType {
BIDI_STREAMING = 3,
}

export class StreamProxy extends Duplexify {
export class StreamProxy extends duplexify {
type: StreamType;
private _callback?: Function;
private _isCancelCalled: boolean;
Expand Down