From 320efc2435fd97fae437bd3afc6834785e487c12 Mon Sep 17 00:00:00 2001 From: Matthew Shaylor Date: Mon, 18 May 2020 11:22:31 +0100 Subject: [PATCH] Fix keyId types in JSDoc comments (#1100) --- src/packet/public_key.js | 2 +- src/type/keyid.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/packet/public_key.js b/src/packet/public_key.js index db16b81e..cc8415d4 100644 --- a/src/packet/public_key.js +++ b/src/packet/public_key.js @@ -198,7 +198,7 @@ PublicKey.prototype.getCreationTime = function() { /** * Calculates the key id of the key - * @returns {String} A 8 byte key id + * @returns {module:type/keyid} A 8 byte key id */ PublicKey.prototype.getKeyId = function () { if (this.keyid) { diff --git a/src/type/keyid.js b/src/type/keyid.js index a393b02b..382b8246 100644 --- a/src/type/keyid.js +++ b/src/type/keyid.js @@ -44,10 +44,18 @@ Keyid.prototype.read = function(bytes) { this.bytes = util.Uint8Array_to_str(bytes.subarray(0, 8)); }; +/** + * Serializes the Key ID + * @returns {Uint8Array} Key ID as a Uint8Array + */ Keyid.prototype.write = function() { return util.str_to_Uint8Array(this.bytes); }; +/** + * Returns the Key ID represented as a hexadecimal string + * @returns {String} Key ID as a hexadecimal string + */ Keyid.prototype.toHex = function() { return util.str_to_hex(this.bytes); }; @@ -61,10 +69,18 @@ Keyid.prototype.equals = function(keyid, matchWildcard = false) { return (matchWildcard && (keyid.isWildcard() || this.isWildcard())) || this.bytes === keyid.bytes; }; +/** + * Checks to see if the Key ID is unset + * @returns {Boolean} true if the Key ID is null + */ Keyid.prototype.isNull = function() { return this.bytes === ''; }; +/** + * Checks to see if the Key ID is a "wildcard" Key ID (all zeros) + * @returns {Boolean} true if this is a wildcard Key ID + */ Keyid.prototype.isWildcard = function() { return /^0+$/.test(this.toHex()); };