aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/Message.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-06-06 11:05:53 +0000
committerMaximilian Krambach <[email protected]>2018-06-06 11:05:53 +0000
commitbfd3799d39df265882deedeee083fd5246a2f35d (patch)
treebfee0a85d6373fa578de075cbce4d26ddced14e4 /lang/js/src/Message.js
parentjs: implement import/delete Key, some fixes (diff)
downloadgpgme-bfd3799d39df265882deedeee083fd5246a2f35d.tar.gz
gpgme-bfd3799d39df265882deedeee083fd5246a2f35d.zip
js: code cleanup (eslint)
-- * trying to stick to eslint from now on for readability * As some attribution was lost in previous git confusions, I added my name into some of the licence headers
Diffstat (limited to '')
-rw-r--r--lang/js/src/Message.js95
1 files changed, 48 insertions, 47 deletions
diff --git a/lang/js/src/Message.js b/lang/js/src/Message.js
index 5664f723..0ddda6c4 100644
--- a/lang/js/src/Message.js
+++ b/lang/js/src/Message.js
@@ -16,9 +16,13 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
* SPDX-License-Identifier: LGPL-2.1+
+ *
+ * Author(s):
+ * Maximilian Krambach <[email protected]>
*/
-import { permittedOperations } from './permittedOperations'
-import { gpgme_error } from './Errors'
+
+import { permittedOperations } from './permittedOperations';
+import { gpgme_error } from './Errors';
import { Connection } from './Connection';
export function createMessage(operation){
@@ -46,7 +50,7 @@ export class GPGME_Message {
}
set operation (op){
- if (typeof(op) === "string"){
+ if (typeof(op) === 'string'){
if (!this._msg){
this._msg = {};
}
@@ -67,10 +71,10 @@ export class GPGME_Message {
}
get expected() {
- if (this._expected === "base64"){
- return this._expected;
- }
- return "string";
+ if (this._expected === 'base64'){
+ return this._expected;
+ }
+ return 'string';
}
/**
@@ -98,52 +102,50 @@ export class GPGME_Message {
}
let checktype = function(val){
switch(typeof(val)){
- case 'string':
- if (poparam.allowed.indexOf(typeof(val)) >= 0
+ case 'string':
+ if (poparam.allowed.indexOf(typeof(val)) >= 0
&& val.length > 0) {
- return true;
- }
- return gpgme_error('PARAM_WRONG');
- break;
- case 'number':
- if (
- poparam.allowed.indexOf('number') >= 0
+ return true;
+ }
+ return gpgme_error('PARAM_WRONG');
+ case 'number':
+ if (
+ poparam.allowed.indexOf('number') >= 0
&& isNaN(value) === false){
- return true;
+ return true;
+ }
+ return gpgme_error('PARAM_WRONG');
+
+ case 'boolean':
+ if (poparam.allowed.indexOf('boolean') >= 0){
+ return true;
+ }
+ return gpgme_error('PARAM_WRONG');
+ case 'object':
+ if (Array.isArray(val)){
+ if (poparam.array_allowed !== true){
+ return gpgme_error('PARAM_WRONG');
}
- return gpgme_error('PARAM_WRONG');
- break;
- case 'boolean':
- if (poparam.allowed.indexOf('boolean') >= 0){
+ for (let i=0; i < val.length; i++){
+ let res = checktype(val[i]);
+ if (res !== true){
+ return res;
+ }
+ }
+ if (val.length > 0) {
return true;
}
- return gpgme_error('PARAM_WRONG');
- break;
- case 'object':
- if (Array.isArray(val)){
- if (poparam.array_allowed !== true){
- return gpgme_error('PARAM_WRONG');
- }
- for (let i=0; i < val.length; i++){
- let res = checktype(val[i]);
- if (res !== true){
- return res;
- }
- }
- if (val.length > 0) {
- return true;
- }
- } else if (val instanceof Uint8Array){
- if (poparam.allowed.indexOf('Uint8Array') >= 0){
- return true;
- }
- return gpgme_error('PARAM_WRONG');
- } else {
- return gpgme_error('PARAM_WRONG');
+ } else if (val instanceof Uint8Array){
+ if (poparam.allowed.indexOf('Uint8Array') >= 0){
+ return true;
}
- break;
- default:
return gpgme_error('PARAM_WRONG');
+ } else {
+ return gpgme_error('PARAM_WRONG');
+ }
+ break;
+ default:
+ return gpgme_error('PARAM_WRONG');
}
};
let typechecked = checktype(value);
@@ -173,7 +175,6 @@ export class GPGME_Message {
let msg_params = Object.keys(this._msg);
for (let i=0; i < reqParams.length; i++){
if (msg_params.indexOf(reqParams[i]) < 0){
- console.log(reqParams[i] + ' missing');
return false;
}
}