From a057a3484e401d89968052834724fc77b86374ad Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 21 Apr 2020 08:21:36 +0200 Subject: [PATCH] Use const instead of let where applicable Signed-off-by: Daniel Bevenius --- lib/bindings/http/emitter_binary_0_1.js | 4 ++-- lib/bindings/http/receiver_binary.js | 4 ++-- lib/bindings/http/receiver_structured.js | 4 ++-- lib/specs/spec_0_3.js | 6 +++--- lib/specs/spec_1.js | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/bindings/http/emitter_binary_0_1.js b/lib/bindings/http/emitter_binary_0_1.js index 62a51c39..e817746f 100644 --- a/lib/bindings/http/emitter_binary_0_1.js +++ b/lib/bindings/http/emitter_binary_0_1.js @@ -67,7 +67,7 @@ HTTPBinary.prototype.emit = function(cloudevent){ Object.keys(headerByGetter) .filter((getter) => cloudevent[getter]()) .forEach((getter) => { - let header = headerByGetter[getter]; + const header = headerByGetter[getter]; _headers[header.name] = header.parser( cloudevent[getter]() @@ -82,7 +82,7 @@ HTTPBinary.prototype.emit = function(cloudevent){ Object.keys(exts) .filter((ext) => Object.hasOwnProperty.call(exts, ext)) .forEach((ext) => { - let capsExt = ext.charAt(0).toUpperCase() + ext.slice(1); + const capsExt = ext.charAt(0).toUpperCase() + ext.slice(1); _headers["CE-X-" + capsExt] = exts[ext]; }); diff --git a/lib/bindings/http/receiver_binary.js b/lib/bindings/http/receiver_binary.js index a0aa1826..ddd3d9f1 100644 --- a/lib/bindings/http/receiver_binary.js +++ b/lib/bindings/http/receiver_binary.js @@ -80,7 +80,7 @@ BinaryHTTPReceiver.prototype.check = function(payload, headers) { }; function parserFor(parsersByEncoding, cloudevent, headers){ - let encoding = cloudevent.spec.payload["datacontentencoding"]; + const encoding = cloudevent.spec.payload["datacontentencoding"]; return parsersByEncoding[encoding][headers[Constants.HEADER_CONTENT_TYPE]]; } @@ -108,7 +108,7 @@ BinaryHTTPReceiver.prototype.parse = function(payload, headers) { }); // Parses the payload - let parsedPayload = + const parsedPayload = parserFor(this.parsersByEncoding, cloudevent, sanityHeaders) .parse(payload); diff --git a/lib/bindings/http/receiver_structured.js b/lib/bindings/http/receiver_structured.js index 5e3e5b8a..a2424285 100644 --- a/lib/bindings/http/receiver_structured.js +++ b/lib/bindings/http/receiver_structured.js @@ -68,8 +68,8 @@ StructuredHTTPReceiver.prototype.parse = function(payload, headers) { Array.from(Object.keys(this.setterByAttribute)) .filter((attribute) => event[attribute]) .forEach((attribute) => { - let setterName = this.setterByAttribute[attribute].name; - let parserFun = this.setterByAttribute[attribute].parser; + const setterName = this.setterByAttribute[attribute].name; + const parserFun = this.setterByAttribute[attribute].parser; // invoke the setter function cloudevent[setterName](parserFun(event[attribute])); diff --git a/lib/specs/spec_0_3.js b/lib/specs/spec_0_3.js index ffbd2648..63e7e3a9 100644 --- a/lib/specs/spec_0_3.js +++ b/lib/specs/spec_0_3.js @@ -102,7 +102,7 @@ Spec03.prototype.check = function(ce){ .filter((tc) => tc["datacontentencoding"]) .filter((tc) => (typeof tc.data) === "string") .map((tc) => { - let newtc = clone(tc); + const newtc = clone(tc); newtc.datacontentencoding = newtc.datacontentencoding.toLocaleLowerCase("en-US"); @@ -210,8 +210,8 @@ Spec03.prototype.data = function(_data){ return this; }; Spec03.prototype.getData = function() { - let dct = this.payload["datacontenttype"]; - let dce = this.payload["datacontentencoding"]; + const dct = this.payload["datacontenttype"]; + const dce = this.payload["datacontentencoding"]; if(dct && !dce){ this.payload["data"] = asData(this.payload["data"], dct); diff --git a/lib/specs/spec_1.js b/lib/specs/spec_1.js index ad101f24..d8b373c0 100644 --- a/lib/specs/spec_1.js +++ b/lib/specs/spec_1.js @@ -85,10 +85,10 @@ function Spec1(_caller) { this.spec.check(); // Check before getData() call - let isbin = isBinary(this.spec.payload[RESERVED_ATTRIBUTES.data]); + const isbin = isBinary(this.spec.payload[RESERVED_ATTRIBUTES.data]); // May be used, if isbin==true - let payload = clone(this.spec.payload); + const payload = clone(this.spec.payload); // To run asData() this.getData(); @@ -190,7 +190,7 @@ Spec1.prototype.data = function(_data){ return this; }; Spec1.prototype.getData = function() { - let dct = this.payload["datacontenttype"]; + const dct = this.payload["datacontenttype"]; if(dct){ this.payload["data"] = asData(this.payload["data"], dct);