Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/openpgpjs/openpgpjs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/enums.js')
-rw-r--r--src/enums.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/enums.js b/src/enums.js
index 16c31601..3f2e15ab 100644
--- a/src/enums.js
+++ b/src/enums.js
@@ -448,7 +448,13 @@ export default {
v5Keys: 4
},
- /** Asserts validity and converts from string/integer to integer. */
+ /**
+ * Asserts validity of given value and converts from string/integer to integer.
+ * @param {Object} type target enum type
+ * @param {String|Integer} e value to check and/or convert
+ * @returns {Integer} enum value if it exists
+ * @throws {Error} if the value is invalid
+ */
write: function(type, e) {
if (typeof e === 'number') {
e = this.read(type, e);
@@ -461,7 +467,13 @@ export default {
throw new Error('Invalid enum value.');
},
- /** Converts from an integer to string. */
+ /**
+ * Converts enum integer value to the corresponding string, if it exists.
+ * @param {Object} type target enum type
+ * @param {Integer} e value to convert
+ * @returns {String} name of enum value if it exists
+ * @throws {Error} if the value is invalid
+ */
read: function(type, e) {
if (!type[byValue]) {
type[byValue] = [];
@@ -476,5 +488,4 @@ export default {
throw new Error('Invalid enum value.');
}
-
};