@@ -53,8 +53,8 @@ const {
53
53
promisify : { custom : customPromisify } ,
54
54
deprecate
55
55
} = require ( 'internal/util' ) ;
56
- const { ERR_INVALID_CALLBACK } = require ( 'internal/errors' ) . codes ;
57
56
const debug = require ( 'internal/util/debuglog' ) . debuglog ( 'timer' ) ;
57
+ const { validateCallback } = require ( 'internal/validators' ) ;
58
58
59
59
const {
60
60
destroyHooksExist,
@@ -118,9 +118,7 @@ function enroll(item, msecs) {
118
118
119
119
120
120
function setTimeout ( callback , after , arg1 , arg2 , arg3 ) {
121
- if ( typeof callback !== 'function' ) {
122
- throw new ERR_INVALID_CALLBACK ( callback ) ;
123
- }
121
+ validateCallback ( callback ) ;
124
122
125
123
let i , args ;
126
124
switch ( arguments . length ) {
@@ -165,9 +163,7 @@ function clearTimeout(timer) {
165
163
}
166
164
167
165
function setInterval ( callback , repeat , arg1 , arg2 , arg3 ) {
168
- if ( typeof callback !== 'function' ) {
169
- throw new ERR_INVALID_CALLBACK ( callback ) ;
170
- }
166
+ validateCallback ( callback ) ;
171
167
172
168
let i , args ;
173
169
switch ( arguments . length ) {
@@ -249,9 +245,7 @@ const Immediate = class Immediate {
249
245
} ;
250
246
251
247
function setImmediate ( callback , arg1 , arg2 , arg3 ) {
252
- if ( typeof callback !== 'function' ) {
253
- throw new ERR_INVALID_CALLBACK ( callback ) ;
254
- }
248
+ validateCallback ( callback ) ;
255
249
256
250
let i , args ;
257
251
switch ( arguments . length ) {
0 commit comments