Skip to content

Commit feaf057

Browse files
authored
lib: cleanup validation
Used the `validateInteger()` validator to cleanup validation and keep consistency.
1 parent dd18795 commit feaf057

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/internal/tty.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ const {
3434
ERR_OUT_OF_RANGE
3535
} = require('internal/errors').codes;
3636

37+
const { validateInteger } = require('internal/validators');
38+
3739
let OSRelease;
3840

3941
const COLORS_2 = 1;
@@ -220,14 +222,9 @@ function hasColors(count, env) {
220222
(count === undefined || (typeof count === 'object' && count !== null))) {
221223
env = count;
222224
count = 16;
223-
} else {
224-
if (typeof count !== 'number') {
225-
throw new ERR_INVALID_ARG_TYPE('count', 'number', count);
226-
}
227-
if (count < 2) {
228-
throw new ERR_OUT_OF_RANGE('count', '>= 2', count);
229-
}
230-
}
225+
} else
226+
validateInteger(count, 'count', 2);
227+
231228
return count <= 2 ** getColorDepth(env);
232229
}
233230

0 commit comments

Comments
 (0)