Skip to content

Commit

Permalink
Revert "build!: remove is-stream & fast-text-encoding dependencies (g…
Browse files Browse the repository at this point in the history
…oogleapis#1442)"

This reverts commit 111133c.
  • Loading branch information
leahecole committed Aug 18, 2023
1 parent ca9c253 commit 59fd85c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"@types/rimraf": "^3.0.2",
"abort-controller": "^3.0.0",
"duplexify": "^4.0.0",
"fast-text-encoding": "^1.0.3",
"google-auth-library": "^8.0.2",
"is-stream-ended": "^0.1.4",
"node-fetch": "^2.6.1",
"object-hash": "^3.0.0",
"proto3-json-serializer": "^1.0.0",
Expand Down
5 changes: 5 additions & 0 deletions src/fallbackRest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
import * as serializer from 'proto3-json-serializer';
import {defaultToObjectOptions} from './fallback';
import {FetchParameters, FetchParametersMethod} from './fallbackServiceStub';
import {hasTextDecoder, hasTextEncoder} from './featureDetection';
import {GoogleError} from './googleError';
import {transcode} from './transcoding';

if (!hasTextEncoder() || !hasTextDecoder()) {
require('fast-text-encoding');
}

export function encodeRequest(
rpc: protobuf.Method,
protocol: string,
Expand Down
8 changes: 8 additions & 0 deletions src/featureDetection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ export function hasWindowFetch() {
return features.windowFetch;
}

export function hasTextEncoder() {
return features.textEncoder;
}

export function hasTextDecoder() {
return features.textDecoder;
}

export function isNodeJS() {
return features.nodeJS;
}
Expand Down
5 changes: 3 additions & 2 deletions src/paginationCalls/pageDescriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import * as ended from 'is-stream-ended';
import {PassThrough, Transform} from 'stream';

import {APICaller} from '../apiCaller';
Expand Down Expand Up @@ -81,7 +82,7 @@ export class PageDescriptor implements Descriptor {
// emit full api response with every page.
stream.emit('response', apiResp);
for (let i = 0; i < resources.length; ++i) {
if ((stream as any)._readableState.ended) {
if (ended(stream)) {
return;
}
if (resources[i] === null) {
Expand All @@ -93,7 +94,7 @@ export class PageDescriptor implements Descriptor {
stream.end();
}
}
if ((stream as any)._readableState.ended) {
if (ended(stream)) {
return;
}
if (!next) {
Expand Down

0 comments on commit 59fd85c

Please sign in to comment.