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/ /node_modules/
/npm-debug.log /npm-debug.log
/docs/

View File

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

View File

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

View File

@ -17,6 +17,7 @@ var bmcrypto = require("./crypto");
* Create a new Bitmessage address object. * Create a new Bitmessage address object.
* @param {?Object} opts - Address options * @param {?Object} opts - Address options
* @constructor * @constructor
* @static
*/ */
function Address(opts) { function Address(opts) {
if (!(this instanceof Address)) { if (!(this instanceof Address)) {

View File

@ -5,17 +5,17 @@
"use strict"; "use strict";
/** Common structures. */ /** [Common structures.]{@link module:bitmessage/structs} */
exports.structs = require("./structs"); exports.structs = require("./structs");
/** Messages. */ /** [Messages.]{@link module:bitmessage/messages} */
exports.messages = require("./messages"); exports.messages = require("./messages");
/** Objects. */ /** [Objects.]{@link module:bitmessage/objects} */
exports.objects = require("./objects"); exports.objects = require("./objects");
/** Working with WIF. */ /** [Working with WIF.]{@link module:bitmessage/wif} */
exports.WIF = require("./wif"); exports.WIF = require("./wif");
/** Proof of work. */ /** [Proof of work.]{@link module:bitmessage/pow} */
exports.POW = require("./pow"); exports.POW = require("./pow");
/** Working with addresses. */ /** [Working with addresses.]{@link module:bitmessage/address} */
exports.Address = require("./address"); exports.Address = require("./address");

View File

@ -1,7 +1,7 @@
/** /**
* Implements common structures. * Implements common structures.
* @see {@link https://bitmessage.org/wiki/Protocol_specification#Common_structures} * @see {@link https://bitmessage.org/wiki/Protocol_specification#Common_structures}
* @module bitmessage/struct * @module bitmessage/structs
*/ */
"use strict"; "use strict";
@ -11,11 +11,13 @@ var assert = require("assert");
/** /**
* var_int. * var_int.
* @see {@link https://bitmessage.org/wiki/Protocol_specification#Variable_length_integer} * @see {@link https://bitmessage.org/wiki/Protocol_specification#Variable_length_integer}
* @namespace
* @static
*/ */
var var_int = exports.var_int = { var var_int = exports.var_int = {
/** /**
* Decode 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}} * @return {{value: number, length: number, rest: Buffer}}
* Decoded var_int structure. * Decoded var_int structure.
*/ */
@ -73,17 +75,17 @@ var var_int = exports.var_int = {
} else if (value < 65536) { } else if (value < 65536) {
buf = new Buffer(3); buf = new Buffer(3);
buf[0] = 253; buf[0] = 253;
buf.writeUInt16BE(value, 1); buf.writeUInt16BE(value, 1, true);
} else if (value < 4294967296) { } else if (value < 4294967296) {
buf = new Buffer(5); buf = new Buffer(5);
buf[0] = 254; buf[0] = 254;
buf.writeUInt32BE(value, 1); buf.writeUInt32BE(value, 1, true);
} else { } else {
assert(value <= 9007199254740991, "Unsafe integer"); assert(value <= 9007199254740991, "Unsafe integer");
buf = new Buffer(9); buf = new Buffer(9);
buf[0] = 255; buf[0] = 255;
buf.writeUInt32BE(Math.floor(value / 4294967296), 1); // high32 buf.writeUInt32BE(Math.floor(value / 4294967296), 1, true); // high32
buf.writeUInt32BE(value % 4294967296, 5); // low32 buf.writeUInt32BE(value % 4294967296, 5, true); // low32
} }
} else if (Buffer.isBuffer(value)) { } else if (Buffer.isBuffer(value)) {
assert(value.length <= 8, "Buffer is too big"); assert(value.length <= 8, "Buffer is too big");
@ -102,11 +104,12 @@ var var_int = exports.var_int = {
/** /**
* var_str. * var_str.
* @see {@link https://bitmessage.org/wiki/Protocol_specification#Variable_length_string} * @see {@link https://bitmessage.org/wiki/Protocol_specification#Variable_length_string}
* @namespace
*/ */
exports.var_str = { exports.var_str = {
/** /**
* Decode 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}} * @return {{str: string, length: number, rest: Buffer}}
* Decoded var_str structure. * Decoded var_str structure.
*/ */
@ -134,11 +137,13 @@ exports.var_str = {
/** /**
* var_int_list. * var_int_list.
* @see {@link https://bitmessage.org/wiki/Protocol_specification#Variable_length_list_of_integers} * @see {@link https://bitmessage.org/wiki/Protocol_specification#Variable_length_list_of_integers}
* @namespace
*/ */
exports.var_int_list = { exports.var_int_list = {
/** /**
* Decode 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}} * @return {{list: number[], length: number, rest: Buffer}}
* Decoded var_int_list structure. * Decoded var_int_list structure.
*/ */