From daf18762c8242b952f4122a43a175b02f981d5bb Mon Sep 17 00:00:00 2001 From: Kagami Hiiragi Date: Sat, 3 Jan 2015 18:58:41 +0300 Subject: [PATCH] Tune docs --- .gitignore | 1 + .jshintignore | 1 + .npmignore | 1 + lib/address.js | 1 + lib/index.js | 12 ++++++------ lib/structs.js | 21 +++++++++++++-------- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 0c0aa04..9546ce4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /node_modules/ /npm-debug.log +/docs/ diff --git a/.jshintignore b/.jshintignore index 94d9180..165b077 100644 --- a/.jshintignore +++ b/.jshintignore @@ -1,3 +1,4 @@ node_modules test* karma* +docs diff --git a/.npmignore b/.npmignore index 65b80c6..f9206e6 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,4 @@ .travis.yml .jshint* karma* +docs diff --git a/lib/address.js b/lib/address.js index f978db8..5d73e72 100644 --- a/lib/address.js +++ b/lib/address.js @@ -17,6 +17,7 @@ var bmcrypto = require("./crypto"); * Create a new Bitmessage address object. * @param {?Object} opts - Address options * @constructor + * @static */ function Address(opts) { if (!(this instanceof Address)) { diff --git a/lib/index.js b/lib/index.js index c9cfa6d..dfcd472 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,17 +5,17 @@ "use strict"; -/** Common structures. */ +/** [Common structures.]{@link module:bitmessage/structs} */ exports.structs = require("./structs"); -/** Messages. */ +/** [Messages.]{@link module:bitmessage/messages} */ exports.messages = require("./messages"); -/** Objects. */ +/** [Objects.]{@link module:bitmessage/objects} */ exports.objects = require("./objects"); -/** Working with WIF. */ +/** [Working with WIF.]{@link module:bitmessage/wif} */ exports.WIF = require("./wif"); -/** Proof of work. */ +/** [Proof of work.]{@link module:bitmessage/pow} */ exports.POW = require("./pow"); -/** Working with addresses. */ +/** [Working with addresses.]{@link module:bitmessage/address} */ exports.Address = require("./address"); diff --git a/lib/structs.js b/lib/structs.js index 82f4082..f152493 100644 --- a/lib/structs.js +++ b/lib/structs.js @@ -1,7 +1,7 @@ /** * Implements common structures. * @see {@link https://bitmessage.org/wiki/Protocol_specification#Common_structures} - * @module bitmessage/struct + * @module bitmessage/structs */ "use strict"; @@ -11,11 +11,13 @@ var assert = require("assert"); /** * var_int. * @see {@link https://bitmessage.org/wiki/Protocol_specification#Variable_length_integer} + * @namespace + * @static */ var var_int = exports.var_int = { /** * Decode var_int. - * @param {Buffer} buf - Buffer that starts with encoded var_int + * @param {Buffer} buf - A buffer that starts with encoded var_int * @return {{value: number, length: number, rest: Buffer}} * Decoded var_int structure. */ @@ -73,17 +75,17 @@ var var_int = exports.var_int = { } else if (value < 65536) { buf = new Buffer(3); buf[0] = 253; - buf.writeUInt16BE(value, 1); + buf.writeUInt16BE(value, 1, true); } else if (value < 4294967296) { buf = new Buffer(5); buf[0] = 254; - buf.writeUInt32BE(value, 1); + buf.writeUInt32BE(value, 1, true); } else { assert(value <= 9007199254740991, "Unsafe integer"); buf = new Buffer(9); buf[0] = 255; - buf.writeUInt32BE(Math.floor(value / 4294967296), 1); // high32 - buf.writeUInt32BE(value % 4294967296, 5); // low32 + buf.writeUInt32BE(Math.floor(value / 4294967296), 1, true); // high32 + buf.writeUInt32BE(value % 4294967296, 5, true); // low32 } } else if (Buffer.isBuffer(value)) { assert(value.length <= 8, "Buffer is too big"); @@ -102,11 +104,12 @@ var var_int = exports.var_int = { /** * var_str. * @see {@link https://bitmessage.org/wiki/Protocol_specification#Variable_length_string} + * @namespace */ exports.var_str = { /** * Decode var_str. - * @param {Buffer} buf - Buffer that starts with encoded var_str + * @param {Buffer} buf - A buffer that starts with encoded var_str * @return {{str: string, length: number, rest: Buffer}} * Decoded var_str structure. */ @@ -134,11 +137,13 @@ exports.var_str = { /** * var_int_list. * @see {@link https://bitmessage.org/wiki/Protocol_specification#Variable_length_list_of_integers} + * @namespace */ exports.var_int_list = { /** * Decode var_int_list. - * @param {Buffer} buf - Buffer that starts with encoded var_int_list + * @param {Buffer} buf - A buffer that starts with encoded + * var_int_list * @return {{list: number[], length: number, rest: Buffer}} * Decoded var_int_list structure. */