Skip to content

Commit c5f5216

Browse files
callmehiphopstephenplusplus
authored andcommitted
docs: add documentation for ending streams early (#1263)
1 parent 4d754ac commit c5f5216

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

lib/bigquery/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,15 @@ BigQuery.prototype.job = function(id) {
457457
* .on('end', function() {
458458
* // All rows retrieved.
459459
* });
460+
*
461+
* //-
462+
* // If you anticipate many results, you can end a stream early to prevent
463+
* // unnecessary processing and API requests.
464+
* //-
465+
* bigquery.query(query)
466+
* .on('data', function(row) {
467+
* this.end();
468+
* });
460469
*/
461470
BigQuery.prototype.query = function(options, callback) {
462471
var that = this;

lib/datastore/request.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,15 @@ DatastoreRequest.prototype.insert = function(entities, callback) {
413413
* });
414414
*
415415
* //-
416+
* // If you anticipate many results, you can end a stream early to prevent
417+
* // unnecessary processing and API requests.
418+
* //-
419+
* datastore.runQuery(query)
420+
* .on('data', function (entity) {
421+
* this.end();
422+
* });
423+
*
424+
* //-
416425
* // A keys-only query returns just the keys of the result entities instead of
417426
* // the entities themselves, at lower latency and cost.
418427
* //-

lib/dns/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,27 @@ DNS.prototype.createZone = function(name, config, callback) {
171171
*
172172
* @example
173173
* dns.getZones(function(err, zones, apiResponse) {});
174+
*
175+
* //-
176+
* // Get the zones from your project as a readable object stream.
177+
* //-
178+
* dns.getZones()
179+
* .on('error', console.error)
180+
* .on('data', function(zone) {
181+
* // zone is a Zone object.
182+
* })
183+
* .on('end', function() {
184+
* // All zones retrieved.
185+
* });
186+
*
187+
* //-
188+
* // If you anticipate many results, you can end a stream early to prevent
189+
* // unnecessary processing and API requests.
190+
* //-
191+
* dns.getZones()
192+
* .on('data', function(zone) {
193+
* this.end();
194+
* });
174195
*/
175196
DNS.prototype.getZones = function(query, callback) {
176197
var self = this;

lib/logging/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,15 @@ Logging.prototype.getEntries = function(options, callback) {
411411
* .on('end', function() {
412412
* // All sinks retrieved.
413413
* });
414+
*
415+
* //-
416+
* // If you anticipate many results, you can end a stream early to prevent
417+
* // unnecessary processing and API requests.
418+
* //-
419+
* logging.getSinks()
420+
* .on('data', function(sink) {
421+
* this.end();
422+
* });
414423
*/
415424
Logging.prototype.getSinks = function(options, callback) {
416425
var self = this;

0 commit comments

Comments
 (0)