MCPcopy Index your code
hub / github.com/totaljs/framework / counter_parse_days

Function counter_parse_days

nosql.js:3967–4001  ·  view source on GitHub ↗
(value, year, opt)

Source from the content-addressed store, hash-verified

3965}
3966
3967function counter_parse_days(value, year, opt) {
3968
3969 var arr = value.trim().split(';');
3970 var tmp = {};
3971
3972 for (var i = 1, length = arr.length; i < length; i++) {
3973 var val = arr[i].substring(5);
3974 var key = year + arr[i].substring(0, 4);
3975
3976 if (tmp[key]) {
3977 switch (opt.type2 || opt.type) {
3978 case 'max':
3979 var a = counter_minmax(opt, val);
3980 if (tmp[key].value < a)
3981 tmp[key].value = a;
3982 break;
3983 case 'min':
3984 var a = counter_minmax(opt, val);
3985 if (tmp[key].value > a)
3986 tmp[key].value = a;
3987 break;
3988 case 'sum':
3989 tmp[key].value += +val;
3990 break;
3991 }
3992 } else
3993 tmp[key] = { id: key, year: +year, month: +key.substring(4, 6), day: +key.substring(6), value: opt.type2 ? counter_minmax(opt, val) : +val };
3994 }
3995
3996 var output = [];
3997 var keys = Object.keys(tmp);
3998 for (var i = 0, length = keys.length; i < length; i++)
3999 output.push(tmp[keys[i]]);
4000 return output;
4001}
4002
4003function counter_parse_years_all(output, value, year, opt) {
4004 var arr = value.trim().split(';');

Callers 1

nosql.jsFile · 0.85

Calls 1

counter_minmaxFunction · 0.85

Tested by

no test coverage detected