Implements common structures.
- Source:
- See:
Example
var structs = require("bitmessage").structs;
var encoded = Buffer.concat([
structs.var_int.encode(4),
Buffer("test"),
structs.var_str.encode("test2"),
structs.var_int_list.encode([1, 2, 3]),
]);
var decoded1 = structs.var_str.decode(encoded);
console.log(decoded1.str); // test
var decoded2 = structs.var_str.decode(decoded1.rest);
console.log(decoded2.str); // test2
var decoded3 = structs.var_int.decode(decoded2.rest);
console.log(decoded3.value); // 3
var decoded4 = structs.var_int_list.decode(decoded2.rest);
console.log(decoded4.list); // [1, 2, 3]