Skip to content

Commit

Permalink
Added U.groupify(id, [count]) method for grouping identifiers.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersirka committed Aug 2, 2023
1 parent a941de7 commit 7c2a418
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- fixed a file validation for encrypted word/excel files
- updated Tangular template engine
- added a new global keyword `PLUGINS`
- added `U.groupify(id, [count])` method for grouping identifiers

========================
0.0.87
Expand Down
14 changes: 1 addition & 13 deletions filestorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,7 @@ FP.count = function(callback) {
};

FP.makedirectory = function(id) {

var val = (HASH(id, true) % 10000) + '';
var diff = 4 - val.length;

if (diff > 0) {
for (var i = 0; i < diff; i++)
val = '0' + val;
}

if (diff.length > 4)
val = val.substring(0, 4);

return Path.join(this.directory, val);
return Path.join(this.directory, U.groupify(id));
};

FP.readfilename = function(id) {
Expand Down
23 changes: 23 additions & 0 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,29 @@ global.DIFFARR = exports.diffarr = function(prop, db, form) {
return obj;
};

exports.groupify = function(id, count) {

var number = 1;

if (!count)
count = 4;

for (var i = 0; i < count; i++)
number *= 10;

var val = (HASH(id, true) % number) + '';
var diff = count - val.length;
if (diff > 0) {
for (var i = 0; i < diff; i++)
val = '0' + val;
}

if (diff.length > 4)
val = val.substring(0, 4);

return val;
};

exports.toURLEncode = function(value) {
var builder = [];

Expand Down

0 comments on commit 7c2a418

Please sign in to comment.