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

Function counter_parse_months

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

Source from the content-addressed store, hash-verified

3928}
3929
3930function counter_parse_months(value, year, opt) {
3931
3932 var arr = value.trim().split(';');
3933 var tmp = {};
3934
3935 for (var i = 1, length = arr.length; i < length; i++) {
3936 var val = arr[i].substring(5);
3937 var key = year + arr[i].substring(0, 2);
3938
3939 if (tmp[key]) {
3940 switch (opt.type2 || opt.type) {
3941 case 'max':
3942 var a = counter_minmax(opt, val);
3943 if (tmp[key].value < a)
3944 tmp[key].value = a;
3945 break;
3946 case 'min':
3947 var a = counter_minmax(opt, val);
3948 if (tmp[key].value > a)
3949 tmp[key].value = a;
3950 break;
3951 case 'sum':
3952 tmp[key].value += +val;
3953 break;
3954 }
3955 } else
3956 tmp[key] = { id: key, year: +year, month: +key.substring(4), value: opt.type2 ? counter_minmax(opt, val) : +val };
3957 }
3958
3959 var output = [];
3960 var keys = Object.keys(tmp);
3961 for (var i = 0, length = keys.length; i < length; i++)
3962 output.push(tmp[keys[i]]);
3963
3964 return output;
3965}
3966
3967function counter_parse_days(value, year, opt) {
3968

Callers 1

nosql.jsFile · 0.85

Calls 1

counter_minmaxFunction · 0.85

Tested by

no test coverage detected