commented general functions

pull/505/head
Constantin Jucovschi 2012-02-26 10:27:56 +00:00
parent 6467a1a40f
commit 1e8ef3bb6a
1 changed files with 14 additions and 1 deletions

View File

@ -29,12 +29,17 @@ var AttributePoolFactory = require("/AttributePoolFactory");
var _opt = null;
//var exports = {};
// ==================== General Util Functions =======================
// This method is called whenever there is an error in the sync process
exports.error = function error(msg) {
var e = new Error(msg);
e.easysync = true;
throw e;
};
// This method is user for assertions with Messages
// if assert fails, the error function called.
exports.assert = function assert(b, msgParts) {
if (!b) {
var msg = Array.prototype.slice.call(arguments, 1).join('');
@ -42,12 +47,17 @@ exports.assert = function assert(b, msgParts) {
}
};
// Parses a number from string base 36
exports.parseNum = function (str) {
return parseInt(str, 36);
};
// Writes a number in base 36 and puts it in a string
exports.numToString = function (num) {
return num.toString(36).toLowerCase();
};
// Converts stuff before $ to base 10
exports.toBaseTen = function (cs) {
var dollarIndex = cs.indexOf('$');
var beforeDollar = cs.substring(0, dollarIndex);
@ -57,6 +67,9 @@ exports.toBaseTen = function (cs) {
}) + fromDollar;
};
// ==================== Changeset Functions =======================
exports.oldLen = function (cs) {
return exports.unpack(cs).oldLen;
};