MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / isDurationValid

Function isDurationValid

tests/test_code/js/moment/moment.js:3102–3130  ·  view source on GitHub ↗
(m)

Source from the content-addressed store, hash-verified

3100 ];
3101
3102 function isDurationValid(m) {
3103 var key,
3104 unitHasDecimal = false,
3105 i;
3106 for (key in m) {
3107 if (
3108 hasOwnProp(m, key) &&
3109 !(
3110 indexOf.call(ordering, key) !== -1 &&
3111 (m[key] == null || !isNaN(m[key]))
3112 )
3113 ) {
3114 return false;
3115 }
3116 }
3117
3118 for (i = 0; i < ordering.length; ++i) {
3119 if (m[ordering[i]]) {
3120 if (unitHasDecimal) {
3121 return false; // only allow non-integers for smallest unit
3122 }
3123 if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
3124 unitHasDecimal = true;
3125 }
3126 }
3127 }
3128
3129 return true;
3130 }
3131
3132 function isValid$1() {
3133 return this._isValid;

Callers 1

DurationFunction · 0.85

Calls 2

hasOwnPropFunction · 0.85
toIntFunction · 0.85

Tested by

no test coverage detected