THRIFT-5811: Update eslint & prettier
Client: js
Patch: Cameron Martin
This closes #3087
diff --git a/tutorial/nodejs/NodeClient.js b/tutorial/nodejs/NodeClient.js
index b4886e8..e4e92cc 100644
--- a/tutorial/nodejs/NodeClient.js
+++ b/tutorial/nodejs/NodeClient.js
@@ -17,47 +17,44 @@
* under the License.
*/
-var thrift = require('thrift');
-var Calculator = require('./gen-nodejs/Calculator');
-var ttypes = require('./gen-nodejs/tutorial_types');
-const assert = require('assert');
+var thrift = require("thrift");
+var Calculator = require("./gen-nodejs/Calculator");
+var ttypes = require("./gen-nodejs/tutorial_types");
+const assert = require("assert");
var transport = thrift.TBufferedTransport;
var protocol = thrift.TBinaryProtocol;
var connection = thrift.createConnection("localhost", 9090, {
- transport : transport,
- protocol : protocol
+ transport: transport,
+ protocol: protocol,
});
-connection.on('error', function(err) {
+connection.on("error", function (err) {
assert(false, err);
});
// Create a Calculator client with the connection
var client = thrift.createClient(Calculator, connection);
-
-client.ping(function(err, response) {
- console.log('ping()');
+client.ping(function (err, response) {
+ console.log("ping()");
});
-
-client.add(1,1, function(err, response) {
+client.add(1, 1, function (err, response) {
console.log("1+1=" + response);
});
-
work = new ttypes.Work();
work.op = ttypes.Operation.DIVIDE;
work.num1 = 1;
work.num2 = 0;
-client.calculate(1, work, function(err, message) {
+client.calculate(1, work, function (err, message) {
if (err) {
console.log("InvalidOperation " + err);
} else {
- console.log('Whoa? You know how to divide by zero?');
+ console.log("Whoa? You know how to divide by zero?");
}
});
@@ -65,11 +62,11 @@
work.num1 = 15;
work.num2 = 10;
-client.calculate(1, work, function(err, message) {
- console.log('15-10=' + message);
+client.calculate(1, work, function (err, message) {
+ console.log("15-10=" + message);
- client.getStruct(1, function(err, message){
- console.log('Check log: ' + message.value);
+ client.getStruct(1, function (err, message) {
+ console.log("Check log: " + message.value);
//close the connection once we're done
connection.end();
diff --git a/tutorial/nodejs/NodeClientPromise.js b/tutorial/nodejs/NodeClientPromise.js
index e6ff2d7..0ba5f4f 100644
--- a/tutorial/nodejs/NodeClientPromise.js
+++ b/tutorial/nodejs/NodeClientPromise.js
@@ -17,64 +17,62 @@
* under the License.
*/
-var thrift = require('thrift');
-var Calculator = require('./gen-nodejs/Calculator');
-var ttypes = require('./gen-nodejs/tutorial_types');
-const assert = require('assert');
+var thrift = require("thrift");
+var Calculator = require("./gen-nodejs/Calculator");
+var ttypes = require("./gen-nodejs/tutorial_types");
+const assert = require("assert");
var transport = thrift.TBufferedTransport;
var protocol = thrift.TBinaryProtocol;
var connection = thrift.createConnection("localhost", 9090, {
- transport : transport,
- protocol : protocol
+ transport: transport,
+ protocol: protocol,
});
-connection.on('error', function(err) {
+connection.on("error", function (err) {
assert(false, err);
});
// Create a Calculator client with the connection
var client = thrift.createClient(Calculator, connection);
+client.ping().then(function () {
+ console.log("ping()");
+});
-client.ping()
- .then(function() {
- console.log('ping()');
- });
-
-client.add(1,1)
- .then(function(response) {
- console.log("1+1=" + response);
- });
+client.add(1, 1).then(function (response) {
+ console.log("1+1=" + response);
+});
work = new ttypes.Work();
work.op = ttypes.Operation.DIVIDE;
work.num1 = 1;
work.num2 = 0;
-client.calculate(1, work)
- .then(function(message) {
- console.log('Whoa? You know how to divide by zero?');
+client
+ .calculate(1, work)
+ .then(function (message) {
+ console.log("Whoa? You know how to divide by zero?");
})
- .catch(function(err) {
+ .catch(function (err) {
console.log("InvalidOperation " + err);
});
-
work.op = ttypes.Operation.SUBTRACT;
work.num1 = 15;
work.num2 = 10;
-client.calculate(1, work)
- .then(function(value) {
- console.log('15-10=' + value);
- return client.getStruct(1);
+client
+ .calculate(1, work)
+ .then(function (value) {
+ console.log("15-10=" + value);
+ return client.getStruct(1);
})
- .then(function(message) {
- console.log('Check log: ' + message.value);
+ .then(function (message) {
+ console.log("Check log: " + message.value);
})
- .finally(function() {
- //close the connection once we're done
- connection.end();
+ .finally(function () {
+ //close the connection once we're done
+ connection.end();
});
diff --git a/tutorial/nodejs/NodeServer.js b/tutorial/nodejs/NodeServer.js
index 2e19882..5181e51 100644
--- a/tutorial/nodejs/NodeServer.js
+++ b/tutorial/nodejs/NodeServer.js
@@ -25,17 +25,17 @@
var data = {};
var server = thrift.createServer(Calculator, {
- ping: function(result) {
+ ping: function (result) {
console.log("ping()");
result(null);
},
- add: function(n1, n2, result) {
+ add: function (n1, n2, result) {
console.log("add(", n1, ",", n2, ")");
result(null, n1 + n2);
},
- calculate: function(logid, work, result) {
+ calculate: function (logid, work, result) {
console.log("calculate(", logid, ",", work, ")");
var val = 0;
@@ -49,7 +49,7 @@
if (work.num2 === 0) {
var x = new ttypes.InvalidOperation();
x.whatOp = work.op;
- x.why = 'Cannot divide by 0';
+ x.why = "Cannot divide by 0";
result(x);
return;
}
@@ -57,28 +57,27 @@
} else {
var x = new ttypes.InvalidOperation();
x.whatOp = work.op;
- x.why = 'Invalid operation';
+ x.why = "Invalid operation";
result(x);
return;
}
var entry = new SharedStruct();
entry.key = logid;
- entry.value = ""+val;
+ entry.value = "" + val;
data[logid] = entry;
result(null, val);
},
- getStruct: function(key, result) {
+ getStruct: function (key, result) {
console.log("getStruct(", key, ")");
result(null, data[key]);
},
- zip: function() {
+ zip: function () {
console.log("zip()");
- }
-
+ },
});
server.listen(9090);
diff --git a/tutorial/nodejs/NodeServerPromise.js b/tutorial/nodejs/NodeServerPromise.js
index bff287b..ddd18f4 100644
--- a/tutorial/nodejs/NodeServerPromise.js
+++ b/tutorial/nodejs/NodeServerPromise.js
@@ -25,16 +25,16 @@
var data = {};
var server = thrift.createServer(Calculator, {
- ping: function() {
+ ping: function () {
console.log("ping()");
},
- add: function(n1, n2) {
+ add: function (n1, n2) {
console.log("add(", n1, ",", n2, ")");
return n1 + n2;
},
- calculate: function(logid, work) {
+ calculate: function (logid, work) {
console.log("calculate(", logid, ",", work, ")");
var val = 0;
@@ -48,33 +48,32 @@
if (work.num2 === 0) {
var x = new ttypes.InvalidOperation();
x.whatOp = work.op;
- x.why = 'Cannot divide by 0';
- throw x;
+ x.why = "Cannot divide by 0";
+ throw x;
}
val = work.num1 / work.num2;
} else {
var x = new ttypes.InvalidOperation();
x.whatOp = work.op;
- x.why = 'Invalid operation';
+ x.why = "Invalid operation";
throw x;
}
var entry = new SharedStruct();
entry.key = logid;
- entry.value = ""+val;
+ entry.value = "" + val;
data[logid] = entry;
return val;
},
- getStruct: function(key) {
+ getStruct: function (key) {
console.log("getStruct(", key, ")");
return data[key];
},
- zip: function() {
+ zip: function () {
console.log("zip()");
- }
-
+ },
});
server.listen(9090);