From 130559ff1fe80be2ac5b774a7786e9299ab31747 Mon Sep 17 00:00:00 2001 From: Phillip9587 Date: Tue, 5 Nov 2024 11:47:58 +0100 Subject: [PATCH] cleanup: remove `setImmediate` support check setImmediate is available since Node.js v0.9.1 --- HISTORY.md | 1 + lib/route.js | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 5f69004..c70518f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,7 @@ unreleased ================== +* Remove `setImmediate` support check * Remove `Object.setPrototypeOf` polyfill * Use `Array.flat` instead of `array-flatten` package * Replace `methods` dependency with standard library diff --git a/lib/route.js b/lib/route.js index ec98414..0b25910 100644 --- a/lib/route.js +++ b/lib/route.js @@ -24,11 +24,6 @@ const slice = Array.prototype.slice const flatten = Array.prototype.flat const methods = METHODS.map((method) => method.toLowerCase()) -/* istanbul ignore next */ -const defer = typeof setImmediate === 'function' - ? setImmediate - : function (fn) { process.nextTick(fn.bind.apply(fn, arguments)) } - /** * Expose `Route`. */ @@ -137,7 +132,7 @@ Route.prototype.dispatch = function dispatch (req, res, done) { // max sync stack if (++sync > 100) { - return defer(next, err) + return setImmediate(next, err) } let layer