From 4015f5b4983c8a4590aa71776880d8bc42c7918d Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Tue, 10 Jul 2018 14:32:26 +0200 Subject: js: documentation -- * Fixed errors: - src/Message.js post(): Set chunksize to defined default value instead of hardcoded - src/Keys.js: added getHasSecret() to refreshKey operation. * Reviewed and updated the documentation * non-documentation changes which do not affect functionality: - src/Errors: disabled a console.warn that is only useful for debugging - helpers.js: renamed "string" to "value" in isFingerprint and isLongId to avoid confusion - src/Keyring: prepare_sync, search are both explicitly set to false by default --- lang/js/src/Helpers.js | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'lang/js/src/Helpers.js') diff --git a/lang/js/src/Helpers.js b/lang/js/src/Helpers.js index b01fbc30..0fd14994 100644 --- a/lang/js/src/Helpers.js +++ b/lang/js/src/Helpers.js @@ -26,11 +26,11 @@ import { GPGME_Key } from './Key'; /** * Tries to return an array of fingerprints, either from input fingerprints or - * from Key objects (openpgp Keys or GPGME_Keys are both expected) - * @param {Object |Array| String|Array} input - * @returns {Array} Array of fingerprints. + * from Key objects (openpgp Keys or GPGME_Keys are both accepted). + * + * @param {Object | Array | String | Array} input + * @returns {Array} Array of fingerprints, or an empty array */ - export function toKeyIdArray(input){ if (!input){ return []; @@ -44,6 +44,8 @@ export function toKeyIdArray(input){ if (isFingerprint(input[i]) === true){ result.push(input[i]); } else { + // MSG_NOT_A_FPR is just a console warning if warning enabled + // in src/Errors.js gpgme_error('MSG_NOT_A_FPR'); } } else if (typeof(input[i]) === 'object'){ @@ -71,9 +73,11 @@ export function toKeyIdArray(input){ } /** - * check if values are valid hexadecimal values of a specified length - * @param {*} key input value. + * Check if values are valid hexadecimal values of a specified length + * @param {String} key input value. * @param {int} len the expected length of the value + * @returns {Boolean} true if value passes test + * @private */ function hextest(key, len){ if (!key || typeof(key) !== 'string'){ @@ -87,15 +91,21 @@ function hextest(key, len){ } /** - * check if the input is a valid Hex string with a length of 40 + * check if the input is a valid Fingerprint + * (Hex string with a length of 40 characters) + * @param {String} value to check + * @returns {Boolean} true if value passes test */ -export function isFingerprint(string){ - return hextest(string, 40); +export function isFingerprint(value){ + return hextest(value, 40); } /** - * check if the input is a valid Hex string with a length of 16 + * check if the input is a valid gnupg long ID (Hex string with a length of 16 + * characters) + * @param {String} value to check + * @returns {Boolean} true if value passes test */ -export function isLongId(string){ - return hextest(string, 16); +export function isLongId(value){ + return hextest(value, 16); } -- cgit v1.2.3