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

Use let and const #217

Merged
merged 3 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 5 additions & 5 deletions samples/fluent.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@

'use strict';

var express = require('express');
var app = express();
const express = require('express');
const app = express();

app.get('*', function(req, res, next) {
return next('oops');
});

// [START fluent]
var structuredLogger = require('fluent-logger').createFluentSender('myapp', {
const structuredLogger = require('fluent-logger').createFluentSender('myapp', {
host: 'localhost',
port: 24224,
timeout: 3.0,
});

var report = function(err, req) {
var payload = {
const report = function(err, req) {
const payload = {
serviceContext: {
service: 'myapp',
},
Expand Down
32 changes: 16 additions & 16 deletions src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

'use strict';

var {Service} = require('@google-cloud/common-grpc');
var EventId = require('eventid');
var extend = require('extend');
var is = require('is');
const {Service} = require('@google-cloud/common-grpc');
const EventId = require('eventid');
const extend = require('extend');
const is = require('is');

var eventId = new EventId();
const eventId = new EventId();

/**
* Create an entry object to define new data to insert into a log.
Expand All @@ -46,11 +46,11 @@ var eventId = new EventId();
* Any other types are stringified with `String(value)`.
*
* @example
* var Logging = require('@google-cloud/logging');
* var logging = new Logging();
* var syslog = logging.log('syslog');
* const Logging = require('@google-cloud/logging');
* const logging = new Logging();
* const syslog = logging.log('syslog');
*
* var metadata = {
* const metadata = {
* resource: {
* type: 'gce_instance',
* labels: {
Expand All @@ -60,7 +60,7 @@ var eventId = new EventId();
* }
* };
*
* var entry = syslog.entry(metadata, {
* const entry = syslog.entry(metadata, {
* delegate: 'my_username'
* });
*
Expand Down Expand Up @@ -123,16 +123,16 @@ function Entry(metadata, data) {
* @returns {Entry}
*/
Entry.fromApiResponse_ = function(entry) {
var data = entry[entry.payload];
let data = entry[entry.payload];

if (entry.payload === 'jsonPayload') {
data = Service.structToObj_(data);
}

var serializedEntry = new Entry(entry, data);
const serializedEntry = new Entry(entry, data);

if (serializedEntry.metadata.timestamp) {
var ms = serializedEntry.metadata.timestamp.seconds * 1000;
let ms = serializedEntry.metadata.timestamp.seconds * 1000;
ms += serializedEntry.metadata.timestamp.nanos / 1e6;
serializedEntry.metadata.timestamp = new Date(ms);
}
Expand All @@ -150,7 +150,7 @@ Entry.fromApiResponse_ = function(entry) {
Entry.prototype.toJSON = function(options) {
options = options || {};

var entry = extend(true, {}, this.metadata);
const entry = extend(true, {}, this.metadata);

if (is.object(this.data)) {
entry.jsonPayload = Service.objToStruct_(this.data, {
Expand All @@ -162,8 +162,8 @@ Entry.prototype.toJSON = function(options) {
}

if (is.date(entry.timestamp)) {
var seconds = entry.timestamp.getTime() / 1000;
var secondsRounded = Math.floor(seconds);
const seconds = entry.timestamp.getTime() / 1000;
const secondsRounded = Math.floor(seconds);

entry.timestamp = {
seconds: secondsRounded,
Expand Down
Loading