Skip to content

Commit ae0cfc9

Browse files
VoltrexKeyvajasnell
authored andcommittedAug 12, 2021
lib: cleanup validation
Used the `validateInteger()` validator to cleanup validation and keep consistency. PR-URL: nodejs#39652 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent 0b69ac7 commit ae0cfc9

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed
 

‎lib/internal/tty.js

+3-10
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ const {
2929
StringPrototypeToLowerCase,
3030
} = primordials;
3131

32-
const {
33-
ERR_INVALID_ARG_TYPE,
34-
ERR_OUT_OF_RANGE
35-
} = require('internal/errors').codes;
32+
const { validateInteger } = require('internal/validators');
3633

3734
let OSRelease;
3835

@@ -221,13 +218,9 @@ function hasColors(count, env) {
221218
env = count;
222219
count = 16;
223220
} 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-
}
221+
validateInteger(count, 'count', 2);
230222
}
223+
231224
return count <= 2 ** getColorDepth(env);
232225
}
233226

0 commit comments

Comments
 (0)
Please sign in to comment.