Skip to content

Commit e7343b7

Browse files
authored
Merge pull request #58 from danbev/use-const
Use const instead of var where applicable
2 parents 23426fc + df85189 commit e7343b7

19 files changed

+55
-55
lines changed

lib/bindings/http/commons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function sanityContentType(contentType) {
1414

1515
function sanityAndClone(headers) {
1616

17-
var sanityHeaders = {};
17+
const sanityHeaders = {};
1818

1919
Array.from(Object.keys(headers))
2020
.filter((header) => Object.hasOwnProperty.call(headers, header))

lib/bindings/http/emitter_binary.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var axios = require("axios");
2-
var empty = require("is-empty");
1+
const axios = require("axios");
2+
const empty = require("is-empty");
33

44
const Constants = require("./constants.js");
55
const defaults = {};

lib/bindings/http/emitter_binary_0_1.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var axios = require("axios");
1+
const axios = require("axios");
22

33
const Constants = require("./constants.js");
44

@@ -59,10 +59,10 @@ function HTTPBinary(configuration){
5959
HTTPBinary.prototype.emit = function(cloudevent){
6060

6161
// Create new request object
62-
var _config = JSON.parse(JSON.stringify(this.config));
62+
const _config = JSON.parse(JSON.stringify(this.config));
6363

6464
// Always set stuff in _config
65-
var _headers = _config["headers"];
65+
const _headers = _config["headers"];
6666

6767
Object.keys(headerByGetter)
6868
.filter((getter) => cloudevent[getter]())
@@ -78,7 +78,7 @@ HTTPBinary.prototype.emit = function(cloudevent){
7878
_config["data"] = cloudevent.format().data;
7979

8080
// EXTENSION CONTEXT ATTRIBUTES
81-
var exts = cloudevent.getExtensions();
81+
const exts = cloudevent.getExtensions();
8282
Object.keys(exts)
8383
.filter((ext) => Object.hasOwnProperty.call(exts, ext))
8484
.forEach((ext) => {

lib/bindings/http/emitter_structured.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var axios = require("axios");
1+
const axios = require("axios");
22

33
const Constants = require("./constants.js");
44
const defaults = {};

lib/bindings/http/emitter_structured_0_1.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var axios = require("axios");
1+
const axios = require("axios");
22

33
const Constants = require("./constants.js");
44

@@ -17,7 +17,7 @@ function HTTPStructured(configuration){
1717
HTTPStructured.prototype.emit = function(cloudevent){
1818

1919
// Create new request object
20-
var _config = JSON.parse(JSON.stringify(this.config));
20+
const _config = JSON.parse(JSON.stringify(this.config));
2121

2222

2323
// Set the cloudevent payload

lib/bindings/http/receiver_binary.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ BinaryHTTPReceiver.prototype.check = function(payload, headers) {
5252
}
5353

5454
// Clone and low case all headers names
55-
var sanityHeaders = Commons.sanityAndClone(headers);
55+
const sanityHeaders = Commons.sanityAndClone(headers);
5656

5757
// Validation Level 1
5858
if(!this.allowedContentTypes
@@ -88,17 +88,17 @@ BinaryHTTPReceiver.prototype.parse = function(payload, headers) {
8888
this.check(payload, headers);
8989

9090
// Clone and low case all headers names
91-
var sanityHeaders = Commons.sanityAndClone(headers);
91+
const sanityHeaders = Commons.sanityAndClone(headers);
9292

93-
var processedHeaders = [];
94-
var cloudevent = new Cloudevent(this.Spec);
93+
const processedHeaders = [];
94+
const cloudevent = new Cloudevent(this.Spec);
9595

9696
// dont worry, check() have seen what was required or not
9797
Array.from(Object.keys(this.setterByHeader))
9898
.filter((header) => sanityHeaders[header])
9999
.forEach((header) => {
100-
var setterName = this.setterByHeader[header].name;
101-
var parserFun = this.setterByHeader[header].parser;
100+
const setterName = this.setterByHeader[header].name;
101+
const parserFun = this.setterByHeader[header].parser;
102102

103103
// invoke the setter function
104104
cloudevent[setterName](parserFun(sanityHeaders[header]));

lib/bindings/http/receiver_structured.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function StructuredHTTPReceiver(
3737
StructuredHTTPReceiver.prototype.check = function(payload, headers) {
3838
validateArgs(payload, headers);
3939

40-
var sanityHeaders = Commons.sanityAndClone(headers);
40+
const sanityHeaders = Commons.sanityAndClone(headers);
4141

4242
// Validation Level 1
4343
if(!this.allowedContentTypes
@@ -54,16 +54,16 @@ StructuredHTTPReceiver.prototype.check = function(payload, headers) {
5454
StructuredHTTPReceiver.prototype.parse = function(payload, headers) {
5555
this.check(payload, headers);
5656

57-
var sanityHeaders = Commons.sanityAndClone(headers);
57+
const sanityHeaders = Commons.sanityAndClone(headers);
5858

59-
var contentType = sanityHeaders[Constants.HEADER_CONTENT_TYPE];
59+
const contentType = sanityHeaders[Constants.HEADER_CONTENT_TYPE];
6060

61-
var parser = this.parserByMime[contentType];
62-
var event = parser.parse(payload);
61+
const parser = this.parserByMime[contentType];
62+
const event = parser.parse(payload);
6363
this.spec.check(event);
6464

65-
var processedAttributes = [];
66-
var cloudevent = new Cloudevent(this.Spec);
65+
const processedAttributes = [];
66+
const cloudevent = new Cloudevent(this.Spec);
6767

6868
Array.from(Object.keys(this.setterByAttribute))
6969
.filter((attribute) => event[attribute])

lib/bindings/http/receiver_structured_0_2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const Constants = require("./constants.js");
22
const Spec02 = require("../../specs/spec_0_2.js");
3-
var JSONParser = require("../../formats/json/parser.js");
3+
const JSONParser = require("../../formats/json/parser.js");
44

55
const StructuredHTTPReceiver = require("./receiver_structured.js");
66

lib/bindings/http/receiver_structured_0_3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const Constants = require("./constants.js");
22
const Spec = require("../../specs/spec_0_3.js");
3-
var JSONParser = require("../../formats/json/parser.js");
3+
const JSONParser = require("../../formats/json/parser.js");
44

55
const StructuredHTTPReceiver = require("./receiver_structured.js");
66

lib/bindings/http/receiver_structured_1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const Constants = require("./constants.js");
22
const Spec = require("../../specs/spec_1.js");
3-
var JSONParser = require("../../formats/json/parser.js");
3+
const JSONParser = require("../../formats/json/parser.js");
44

55
const StructuredHTTPReceiver = require("./receiver_structured.js");
66

0 commit comments

Comments
 (0)