MCPcopy Index your code
hub / github.com/feiyu563/PrometheusAlert / isDurationValid

Function isDurationValid

static/plugins/chart.js/Chart.bundle.js:17428–17448  ·  view source on GitHub ↗
(m)

Source from the content-addressed store, hash-verified

17426 var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
17427
17428 function isDurationValid(m) {
17429 for (var key in m) {
17430 if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
17431 return false;
17432 }
17433 }
17434
17435 var unitHasDecimal = false;
17436 for (var i = 0; i < ordering.length; ++i) {
17437 if (m[ordering[i]]) {
17438 if (unitHasDecimal) {
17439 return false; // only allow non-integers for smallest unit
17440 }
17441 if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
17442 unitHasDecimal = true;
17443 }
17444 }
17445 }
17446
17447 return true;
17448 }
17449
17450 function isValid$1() {
17451 return this._isValid;

Callers 1

DurationFunction · 0.85

Calls 1

toIntFunction · 0.85

Tested by

no test coverage detected