Skip to content

Commit 517c34b

Browse files
Use arrow functions (#188)
1 parent 929b941 commit 517c34b

11 files changed

Lines changed: 1075 additions & 1089 deletions

File tree

handwritten/bigquery/benchmark/bench.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const queryJson = fs.readFileSync(process.argv[2]);
3030
const queries = JSON.parse(queryJson);
3131
const client = new BigQuery(env);
3232

33-
const doQuery = function(queryTxt, callback) {
33+
const doQuery = (queryTxt, callback) =>{
3434
const startMilli = new Date().getTime();
3535
let numRows = 0;
3636
let numCols;
@@ -61,9 +61,8 @@ const doQuery = function(queryTxt, callback) {
6161
}
6262
numRows++;
6363
})
64-
.on('end', function() {
64+
.on('end', () => {
6565
const timeTotalMilli = new Date().getTime() - startMilli;
66-
6766
console.log(
6867
`query ${queryTxt}:`,
6968
`got ${numRows} rows,`,

handwritten/bigquery/samples/quickstart.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ bigquery
3535
.createDataset(datasetName)
3636
.then(results => {
3737
const dataset = results[0];
38-
3938
console.log(`Dataset ${dataset.id} created.`);
4039
})
4140
.catch(err => {

handwritten/bigquery/src/dataset.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ class Dataset extends ServiceObject {
204204
super({
205205
parent: bigQuery,
206206
baseUrl: '/datasets',
207-
id: id,
208-
methods: methods,
207+
id,
208+
methods,
209209
requestModule: request,
210210
createMethod: (id, options, callback) => {
211211
if (is.fn(options)) {
@@ -226,12 +226,11 @@ class Dataset extends ServiceObject {
226226
// Catch all for read-modify-write cycle
227227
// https://cloud.google.com/bigquery/docs/api-performance#read-patch-write
228228
this.interceptors.push({
229-
request: function(reqOpts) {
229+
request: reqOpts => {
230230
if (reqOpts.method === 'PATCH' && reqOpts.json.etag) {
231231
reqOpts.headers = reqOpts.headers || {};
232232
reqOpts.headers['If-Match'] = reqOpts.json.etag;
233233
}
234-
235234
return reqOpts;
236235
},
237236
});
@@ -295,7 +294,7 @@ class Dataset extends ServiceObject {
295294
});
296295

297296
return this.bigQuery.createQueryJob(options, callback);
298-
};
297+
}
299298

300299
/**
301300
* Run a query scoped to your dataset as a readable object stream.
@@ -322,7 +321,7 @@ class Dataset extends ServiceObject {
322321
});
323322

324323
return this.bigQuery.createQueryStream(options);
325-
};
324+
}
326325

327326
/**
328327
* Create a table given a tableId or configuration object.
@@ -400,7 +399,7 @@ class Dataset extends ServiceObject {
400399
callback(null, table, resp);
401400
}
402401
);
403-
};
402+
}
404403

405404
/**
406405
* Delete the dataset.
@@ -454,7 +453,7 @@ class Dataset extends ServiceObject {
454453
},
455454
callback
456455
);
457-
};
456+
}
458457

459458
/**
460459
* Get a list of tables.
@@ -540,7 +539,7 @@ class Dataset extends ServiceObject {
540539
callback(null, tables, nextQuery, resp);
541540
}
542541
);
543-
};
542+
}
544543

545544
/**
546545
* Run a query scoped to your dataset.
@@ -566,7 +565,7 @@ class Dataset extends ServiceObject {
566565
});
567566

568567
return this.bigQuery.query(options, callback);
569-
};
568+
}
570569

571570
/**
572571
* Create a Table object.
@@ -597,7 +596,7 @@ class Dataset extends ServiceObject {
597596
);
598597

599598
return new Table(this, id, options);
600-
};
599+
}
601600
}
602601

603602
/*! Developer Documentation

handwritten/bigquery/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ util.inherits(BigQuery, common.Service);
579579
if (typeName === 'ARRAY') {
580580
queryParameter.parameterValue.arrayValues = value.map(function(value) {
581581
return {
582-
value: value,
582+
value,
583583
};
584584
});
585585
} else if (typeName === 'STRUCT') {
@@ -795,7 +795,7 @@ BigQuery.prototype.createQueryJob = function(options, callback) {
795795

796796
const reqOpts = {
797797
configuration: {
798-
query: query,
798+
query,
799799
} as any,
800800
} as any;
801801

@@ -931,7 +931,7 @@ BigQuery.prototype.createJob = function(options, callback) {
931931

932932
reqOpts.jobReference = {
933933
projectId: this.projectId,
934-
jobId: jobId,
934+
jobId,
935935
location: this.location,
936936
};
937937

handwritten/bigquery/src/job.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ class Job extends Operation {
223223
super({
224224
parent: bigQuery,
225225
baseUrl: '/jobs',
226-
id: id,
227-
methods: methods,
226+
id,
227+
methods,
228228
requestModule: request,
229229
} as any);
230230

@@ -306,7 +306,7 @@ class Job extends Operation {
306306
},
307307
callback
308308
);
309-
};
309+
}
310310

311311
/**
312312
* @callback QueryResultsCallback
@@ -434,7 +434,7 @@ class Job extends Operation {
434434
callback(null, rows, nextQuery, resp);
435435
}
436436
);
437-
};
437+
}
438438

439439
/**
440440
* This method will be called by `getQueryResultsStream()`. It is required to
@@ -445,7 +445,7 @@ class Job extends Operation {
445445
getQueryResultsAsStream_(options, callback) {
446446
options = extend({autoPaginate: false}, options);
447447
this.getQueryResults(options, callback);
448-
};
448+
}
449449

450450
/**
451451
* Poll for a status update. Execute the callback:
@@ -476,7 +476,7 @@ class Job extends Operation {
476476

477477
callback(null, metadata);
478478
});
479-
};
479+
}
480480
}
481481

482482
/*! Developer Documentation

0 commit comments

Comments
 (0)