Skip to content

Commit 9e09979

Browse files
committed
clean up is-valid-colorscale logic
1 parent dd69e12 commit 9e09979

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/components/colorscale/is_valid_scale_array.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ var tinycolor = require('tinycolor2');
1313

1414

1515
module.exports = function isValidScaleArray(scl) {
16-
var isValid = true,
17-
highestVal = 0;
16+
var highestVal = 0;
1817

19-
if(!Array.isArray(scl) || scl.length === 0) return false;
18+
if(!Array.isArray(scl) || scl.length < 2) return false;
2019

2120
if(!scl[0] || !scl[scl.length - 1]) return false;
2221

@@ -26,12 +25,11 @@ module.exports = function isValidScaleArray(scl) {
2625
var si = scl[i];
2726

2827
if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) {
29-
isValid = false;
30-
break;
28+
return false;
3129
}
3230

3331
highestVal = +si[0];
3432
}
3533

36-
return isValid;
34+
return true;
3735
};

0 commit comments

Comments
 (0)