Socket
Socket
Sign inDemoInstall

google-gax

Package Overview
Dependencies
Maintainers
1
Versions
362
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-gax - npm Package Compare versions

Comparing version 0.12.3 to 0.13.0

12

lib/bundling.js

@@ -373,2 +373,7 @@ /*

task.extend(bundledField, requestBytes, callback);
var ret = {
cancel: function() {
self._cancel(callback.id);
}
};

@@ -380,2 +385,3 @@ var countThreshold = this._options.elementCountThreshold || 0;

this._runNow(bundleId);
return ret;
}

@@ -390,7 +396,3 @@

return {
cancel: function() {
self._cancel(callback.id);
}
};
return ret;
};

@@ -397,0 +399,0 @@

@@ -54,7 +54,11 @@ /**

* @property {boolean=} autoPaginate - If set to false and the call is
* configured for page streaming, page streaming is not performed, instead
* configured for paged iteration, page unrolling is not performed, instead
* the callback will be called with the response object.
* @property {Object=} pageToken - If set and the call is configured for
* page streaming, page streaming is not performed and requested with this
* paged iteration, paged iteration is not performed and requested with this
* pageToken.
* @property {number} maxResults - If set and the call is configured for
* paged iteration, the call will stop when the number of response elements
* reaches to the specified size. By default, it will unroll the page to
* the end of the list.
* @property {boolean=} isBundling - If set to false and the call is configured

@@ -168,2 +172,3 @@ * for bundling, bundling is not performed.

this.pageToken = settings.pageToken;
this.maxResults = settings.maxResults;
this.otherArgs = settings.otherArgs || {};

@@ -194,2 +199,3 @@ this.bundleOptions = settings.bundleOptions;

var pageToken = this.pageToken;
var maxResults = this.maxResults;
var otherArgs = this.otherArgs;

@@ -215,2 +221,6 @@ var isBundling = this.isBundling;

if ('maxResults' in options) {
maxResults = options.maxResults;
}
if ('otherArgs' in options) {

@@ -250,2 +260,3 @@ otherArgs = {};

pageToken: pageToken,
maxResults: maxResults,
otherArgs: otherArgs,

@@ -252,0 +263,0 @@ isBundling: isBundling,

@@ -37,3 +37,4 @@ /**

var NormalApiCaller = require('./api_callable').NormalApiCaller;
var ReadableStream = require('readable-stream');
var through2 = require('through2');
var ended = require('is-stream-ended');

@@ -101,2 +102,3 @@ /**

var maxResults = settings.maxResults || -1;
var allResources = [];

@@ -109,3 +111,9 @@ function pushResources(err, resources, next) {

allResources.push.apply(allResources, resources);
for (var i = 0; i < resources.length; ++i) {
allResources.push(resources[i]);
if (allResources.length === maxResults) {
next = null;
break;
}
}
if (!next) {

@@ -115,3 +123,3 @@ canceller.callback(null, allResources);

}
nextTick(apiCall, argument, pushResources);
nextTick(apiCall, next, pushResources);
}

@@ -123,27 +131,2 @@

/**
* An implementation of readalbe stream which fits for the usage of paged iteration.
* @private
* @constructor
*/
function PagedStream() {
ReadableStream.call(this, {objectMode: true});
}
util.inherits(PagedStream, ReadableStream);
PagedStream.prototype._read = function(n) {
};
/**
*/
PagedStream.prototype.end = function() {
// pushing a null will cause ending the stream.
this.push(null);
// onEof callback of ReadableStream does not update 'readable' field immediately,
// thus settings here explicitly.
this.readable = false;
};
/**
* Describes the structure of a page-streaming call.

@@ -182,9 +165,14 @@ *

apiCall, request, options) {
var stream = new PagedStream();
options = extend({}, options);
options.autoPaginate = false;
function callback(response) {
var resources = response[0];
var stream = through2.obj();
options = extend({}, options, {autoPaginate: false});
var maxResults = ('maxResults' in options) ? options.maxResults : -1;
var pushCount = 0;
var started = false;
function callback(err, resources, next) {
if (err) {
stream.emit('error', err);
return;
}
for (var i = 0; i < resources.length; ++i) {
if (!stream.readable) {
if (ended(stream)) {
return;

@@ -196,7 +184,11 @@ }

stream.push(resources[i]);
pushCount++;
if (pushCount === maxResults) {
stream.end();
}
}
if (!stream.readable) {
if (ended(stream)) {
return;
}
if (!response[1]) {
if (!next) {
stream.end();

@@ -210,13 +202,15 @@ return;

}
return apiCall(response[1], options)
.then(callback)
.catch(function(err) {
stream.emit('error', err);
});
if (stream.isPaused()) {
request = next;
started = false;
} else {
nextTick(apiCall, next, options, callback);
}
}
apiCall(request, options)
.then(callback)
.catch(function(err) {
stream.emit('error', err);
});
stream.on('resume', function() {
if (!started) {
started = true;
apiCall(request, options, callback);
}
});
return stream;

@@ -223,0 +217,0 @@ };

{
"name": "google-gax",
"version": "0.12.3",
"version": "0.13.0",
"description": "Google API Extensions",

@@ -13,6 +13,8 @@ "main": "index.js",

"google-proto-files": "^0.9.1",
"grpc": "^1.1",
"grpc": "^1.2",
"is-stream-ended": "^0.1.0",
"lodash": "^4.17.2",
"process-nextick-args": "^1.0.7",
"readable-stream": "^2.2.2"
"readable-stream": "^2.2.2",
"through2": "^2.0.3"
},

@@ -28,4 +30,5 @@ "devDependencies": {

"pegjs": "~0.9.0",
"pumpify": "^1.3.5",
"sinon": "~1.17.3",
"through2": "~2.0.1"
"stream-events": "^1.0.1"
},

@@ -32,0 +35,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc