From 1e8ef3bb6af45110001294b3ab70d80955b7f6fc Mon Sep 17 00:00:00 2001 From: Constantin Jucovschi Date: Sun, 26 Feb 2012 10:27:56 +0000 Subject: [PATCH] commented general functions --- static/js/Changeset.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/static/js/Changeset.js b/static/js/Changeset.js index 715836d5f..78066e29f 100644 --- a/static/js/Changeset.js +++ b/static/js/Changeset.js @@ -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; };