aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/Helpers.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/Helpers.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 'lang/js/src/Helpers.js')
-rw-r--r--lang/js/src/Helpers.js29
1 files changed, 14 insertions, 15 deletions
diff --git a/lang/js/src/Helpers.js b/lang/js/src/Helpers.js
index 5064d03e..b01fbc30 100644
--- a/lang/js/src/Helpers.js
+++ b/lang/js/src/Helpers.js
@@ -16,14 +16,18 @@
* 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 { gpgme_error } from "./Errors";
-import { GPGME_Key } from "./Key";
+
+import { gpgme_error } from './Errors';
+import { GPGME_Key } from './Key';
/**
* Tries to return an array of fingerprints, either from input fingerprints or
- * from Key objects
- * @param {Key |Array<Key>| GPGME_Key | Array<GPGME_Key>|String|Array<String>} input
+ * from Key objects (openpgp Keys or GPGME_Keys are both expected)
+ * @param {Object |Array<Object>| String|Array<String>} input
* @returns {Array<String>} Array of fingerprints.
*/
@@ -48,7 +52,7 @@ export function toKeyIdArray(input){
fpr = input[i].fingerprint;
} else if (input[i].hasOwnProperty('primaryKey') &&
input[i].primaryKey.hasOwnProperty('getFingerprint')){
- fpr = input[i].primaryKey.getFingerprint();
+ fpr = input[i].primaryKey.getFingerprint();
}
if (isFingerprint(fpr) === true){
result.push(fpr);
@@ -64,7 +68,7 @@ export function toKeyIdArray(input){
} else {
return result;
}
-};
+}
/**
* check if values are valid hexadecimal values of a specified length
@@ -72,7 +76,7 @@ export function toKeyIdArray(input){
* @param {int} len the expected length of the value
*/
function hextest(key, len){
- if (!key || typeof(key) !== "string"){
+ if (!key || typeof(key) !== 'string'){
return false;
}
if (key.length !== len){
@@ -80,23 +84,18 @@ function hextest(key, len){
}
let regexp= /^[0-9a-fA-F]*$/i;
return regexp.test(key);
-};
+}
/**
* check if the input is a valid Hex string with a length of 40
*/
export function isFingerprint(string){
return hextest(string, 40);
-};
+}
/**
* check if the input is a valid Hex string with a length of 16
*/
export function isLongId(string){
return hextest(string, 16);
-};
-
-// TODO still not needed anywhere
-function isShortId(string){
- return hextest(string, 8);
-};
+}