From 38bae9a1dafd59c26ba53ab3b943e9c2ab8167f5 Mon Sep 17 00:00:00 2001 From: dskloet Date: Sat, 21 Feb 2015 19:42:38 +0100 Subject: [PATCH 1/2] Fix JS doc annotations in publickey.js --- lib/publickey.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/publickey.js b/lib/publickey.js index cd134fb93..5f83afd3a 100644 --- a/lib/publickey.js +++ b/lib/publickey.js @@ -1,5 +1,5 @@ 'use strict'; - +strin var Address = require('./address'); var BN = require('./crypto/bn'); var Point = require('./crypto/point'); @@ -117,7 +117,7 @@ PublicKey._isBuffer = function(param) { /** * Internal function to detect if a param is a JSON string or plain object * - * @param {*} param - value to test + * @param {*} json - value to test * @returns {boolean} * @private */ @@ -146,7 +146,7 @@ PublicKey._transformPrivateKey = function(privkey) { * Internal function to transform DER into a public key point * * @param {Buffer} buf - An hex encoded buffer - * @param {bool} [strict] - if set to false, will loosen some conditions + * @param {bool=} strict - if set to false, will loosen some conditions * @returns {Object} An object with keys: point and compressed * @private */ @@ -220,7 +220,7 @@ PublicKey.fromJSON = function(json) { /** * Internal function to transform a JSON into a public key point * - * @param {Buffer} buf - a JSON string or plain object + * @param {String|Object} json - a JSON string or plain object * @returns {Object} An object with keys: point and compressed * @private */ @@ -254,7 +254,7 @@ PublicKey.fromPrivateKey = function(privkey) { /** * Instantiate a PublicKey from a Buffer * @param {Buffer} buf - A DER hex buffer - * @param {bool} [strict] - if set to false, will loosen some conditions + * @param {bool=} strict - if set to false, will loosen some conditions * @returns {PublicKey} A new valid instance of PublicKey */ PublicKey.fromDER = PublicKey.fromBuffer = function(buf, strict) { @@ -285,7 +285,7 @@ PublicKey.fromPoint = function(point, compressed) { * Instantiate a PublicKey from a DER hex encoded string * * @param {String} str - A DER hex string - * @param {String} [encoding] - The type of string encoding + * @param {String=} encoding - The type of string encoding * @returns {PublicKey} A new valid instance of PublicKey */ PublicKey.fromString = function(str, encoding) { @@ -314,7 +314,6 @@ PublicKey.fromX = function(odd, x) { * Check if there would be any errors when initializing a PublicKey * * @param {String} data - The encoded data in various formats - * @param {String} [compressed] - If the public key is compressed * @returns {null|Error} An error if exists */ PublicKey.getValidationError = function(data) { @@ -332,7 +331,6 @@ PublicKey.getValidationError = function(data) { * Check if the parameters are valid * * @param {String} data - The encoded data in various formats - * @param {String} [compressed] - If the public key is compressed * @returns {Boolean} If the public key would be valid */ PublicKey.isValid = function(data) { @@ -350,6 +348,9 @@ PublicKey.prototype.toObject = function toObject() { }; }; +/** + * @returns {String} A JSON string of the PublicKey + */ PublicKey.prototype.toJSON = function toJSON() { return JSON.stringify(this.toObject()); }; @@ -397,6 +398,7 @@ PublicKey.prototype._getID = function _getID() { /** * Will return an address for the public key * + * @param {String|Network=} network - Which network should the address be for * @returns {Address} An address generated from the public key */ PublicKey.prototype.toAddress = function(network) { From 2c5219e32c24b3cf9ae60dae9d6cbb19574ce7dc Mon Sep 17 00:00:00 2001 From: dskloet Date: Sat, 21 Feb 2015 19:46:26 +0100 Subject: [PATCH 2/2] typo --- lib/publickey.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/publickey.js b/lib/publickey.js index 5f83afd3a..c6d4927e9 100644 --- a/lib/publickey.js +++ b/lib/publickey.js @@ -1,5 +1,5 @@ 'use strict'; -strin + var Address = require('./address'); var BN = require('./crypto/bn'); var Point = require('./crypto/point');