summaryrefslogtreecommitdiff
path: root/lib/internal/timers.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/timers.js')
-rw-r--r--lib/internal/timers.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/internal/timers.js b/lib/internal/timers.js
index 8c1a87a65f..26fc3f941b 100644
--- a/lib/internal/timers.js
+++ b/lib/internal/timers.js
@@ -10,7 +10,11 @@ const {
const async_id_symbol = Symbol('asyncId');
const trigger_async_id_symbol = Symbol('triggerId');
-const errors = require('internal/errors');
+const {
+ ERR_INVALID_ARG_TYPE,
+ ERR_INVALID_CALLBACK,
+ ERR_OUT_OF_RANGE
+} = require('internal/errors').codes;
// Timeout values > TIMEOUT_MAX are set to 1.
const TIMEOUT_MAX = 2 ** 31 - 1;
@@ -94,7 +98,7 @@ Timeout.prototype[refreshFnSymbol] = function refresh() {
function setUnrefTimeout(callback, after, arg1, arg2, arg3) {
// Type checking identical to setTimeout()
if (typeof callback !== 'function') {
- throw new errors.TypeError('ERR_INVALID_CALLBACK');
+ throw new ERR_INVALID_CALLBACK();
}
let i, args;
@@ -127,13 +131,11 @@ function setUnrefTimeout(callback, after, arg1, arg2, arg3) {
// Type checking used by timers.enroll() and Socket#setTimeout()
function validateTimerDuration(msecs) {
if (typeof msecs !== 'number') {
- throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'msecs',
- 'number', msecs);
+ throw new ERR_INVALID_ARG_TYPE('msecs', 'number', msecs);
}
if (msecs < 0 || !isFinite(msecs)) {
- throw new errors.RangeError('ERR_OUT_OF_RANGE', 'msecs',
- 'a non-negative finite number', msecs);
+ throw new ERR_OUT_OF_RANGE('msecs', 'a non-negative finite number', msecs);
}
// Ensure that msecs fits into signed int32