@@ -53,8 +53,8 @@ const {
5353 promisify : { custom : customPromisify } ,
5454 deprecate
5555} = require ( 'internal/util' ) ;
56- const { ERR_INVALID_CALLBACK } = require ( 'internal/errors' ) . codes ;
5756const debug = require ( 'internal/util/debuglog' ) . debuglog ( 'timer' ) ;
57+ const { validateCallback } = require ( 'internal/validators' ) ;
5858
5959const {
6060 destroyHooksExist,
@@ -118,9 +118,7 @@ function enroll(item, msecs) {
118118
119119
120120function setTimeout ( callback , after , arg1 , arg2 , arg3 ) {
121- if ( typeof callback !== 'function' ) {
122- throw new ERR_INVALID_CALLBACK ( callback ) ;
123- }
121+ validateCallback ( callback ) ;
124122
125123 let i , args ;
126124 switch ( arguments . length ) {
@@ -165,9 +163,7 @@ function clearTimeout(timer) {
165163}
166164
167165function setInterval ( callback , repeat , arg1 , arg2 , arg3 ) {
168- if ( typeof callback !== 'function' ) {
169- throw new ERR_INVALID_CALLBACK ( callback ) ;
170- }
166+ validateCallback ( callback ) ;
171167
172168 let i , args ;
173169 switch ( arguments . length ) {
@@ -249,9 +245,7 @@ const Immediate = class Immediate {
249245} ;
250246
251247function setImmediate ( callback , arg1 , arg2 , arg3 ) {
252- if ( typeof callback !== 'function' ) {
253- throw new ERR_INVALID_CALLBACK ( callback ) ;
254- }
248+ validateCallback ( callback ) ;
255249
256250 let i , args ;
257251 switch ( arguments . length ) {
0 commit comments