Commit ed223188 authored by Tristan Cavelier's avatar Tristan Cavelier

Adding revision generator to localstorage.js

parent 345b57d3
...@@ -22,6 +22,29 @@ var newLocalStorage = function ( spec, my ) { ...@@ -22,6 +22,29 @@ var newLocalStorage = function ( spec, my ) {
} }
}; };
/**
* Generates a hash code of a string
* @method hashCode
* @param {string} string The string to hash
* @return {string} The string hash code
*/
priv.hashCode = function (string) {
return hex_sha256(string);
};
/**
* Generates the next revision of [previous_revision]. [string] helps us
* to generate a hash code.
* @methode generateNextRev
* @param {string} previous_revision The previous revision
* @param {string} string String to help generate hash code
* @return {string} The next revision
*/
priv.generateNextRev = function (previous_revision, string) {
return (parseInt(previous_revision.split('-')[0],10)+1) + '-' +
priv.hashCode(previous_revision + string);
};
/** /**
* Replace substrings to others substring following a [list_of_replacement]. * Replace substrings to others substring following a [list_of_replacement].
* It will be executed recusively to replace substrings which are not * It will be executed recusively to replace substrings which are not
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment