Tune docs

This commit is contained in:
Kagami Hiiragi 2015-01-03 18:58:41 +03:00
parent bf8b663c5d
commit daf18762c8
6 changed files with 23 additions and 14 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/node_modules/
/npm-debug.log
/docs/

View File

@ -1,3 +1,4 @@
node_modules
test*
karma*
docs

View File

@ -1,3 +1,4 @@
.travis.yml
.jshint*
karma*
docs

View File

@ -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)) {

View File

@ -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");

View File

@ -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.
*/