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

Function counter_parse_years

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

Source from the content-addressed store, hash-verified

3893}
3894
3895function counter_parse_years(value, year, opt) {
3896
3897 var arr = value.trim().split(';');
3898 var tmp = {};
3899
3900 for (var i = 1, length = arr.length; i < length; i++) {
3901 var val = arr[i].substring(5);
3902 if (tmp[year]) {
3903 switch (opt.type2 || opt.type) {
3904 case 'max':
3905 var a = counter_minmax(opt, val);
3906 if (tmp[year].value < a)
3907 tmp[year].value = a;
3908 break;
3909 case 'min':
3910 var a = counter_minmax(opt, val);
3911 if (tmp[year].value > a)
3912 tmp[year].value = a;
3913 break;
3914 case 'sum':
3915 tmp[year].value += +val;
3916 break;
3917 }
3918 } else
3919 tmp[year] = { id: year, year: +year, value: opt.type2 ? counter_minmax(opt, val) : +val };
3920 }
3921
3922 var output = [];
3923 var keys = Object.keys(tmp);
3924 for (var i = 0, length = keys.length; i < length; i++)
3925 output.push(tmp[keys[i]]);
3926
3927 return output;
3928}
3929
3930function counter_parse_months(value, year, opt) {
3931

Callers 1

nosql.jsFile · 0.85

Calls 1

counter_minmaxFunction · 0.85

Tested by

no test coverage detected