From c04204ef10be45f30bed51aba0ed89bd310c654a Mon Sep 17 00:00:00 2001 From: Phillip9587 Date: Mon, 21 Oct 2024 13:21:11 +0200 Subject: [PATCH] Use `Array.flat` instead of `array-flatten` package --- index.js | 4 ++-- lib/route.js | 6 +++--- package.json | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 0dbe740..fac31f1 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,6 @@ * @private */ -const flatten = require('array-flatten').flatten const isPromise = require('is-promise') const Layer = require('./lib/layer') const methods = require('methods') @@ -27,6 +26,7 @@ const setPrototypeOf = require('setprototypeof') */ const slice = Array.prototype.slice +const flatten = Array.prototype.flat /** * Expose `Router`. @@ -374,7 +374,7 @@ Router.prototype.use = function use (handler) { } } - const callbacks = flatten(slice.call(arguments, offset)) + const callbacks = flatten.call(slice.call(arguments, offset), Infinity) if (callbacks.length === 0) { throw new TypeError('argument handler is required') diff --git a/lib/route.js b/lib/route.js index c9c53e7..5e9a778 100644 --- a/lib/route.js +++ b/lib/route.js @@ -12,7 +12,6 @@ * @private */ -const flatten = require('array-flatten').flatten const Layer = require('./layer') const methods = require('methods') @@ -22,6 +21,7 @@ const methods = require('methods') */ const slice = Array.prototype.slice +const flatten = Array.prototype.flat /* istanbul ignore next */ const defer = typeof setImmediate === 'function' @@ -192,7 +192,7 @@ Route.prototype.dispatch = function dispatch (req, res, done) { */ Route.prototype.all = function all (handler) { - const callbacks = flatten(slice.call(arguments)) + const callbacks = flatten.call(slice.call(arguments), Infinity) if (callbacks.length === 0) { throw new TypeError('argument handler is required') @@ -217,7 +217,7 @@ Route.prototype.all = function all (handler) { methods.forEach(function (method) { Route.prototype[method] = function (handler) { - const callbacks = flatten(slice.call(arguments)) + const callbacks = flatten.call(slice.call(arguments), Infinity) if (callbacks.length === 0) { throw new TypeError('argument handler is required') diff --git a/package.json b/package.json index c118ec6..153e133 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "license": "MIT", "repository": "pillarjs/router", "dependencies": { - "array-flatten": "3.0.0", "is-promise": "4.0.0", "methods": "~1.1.2", "parseurl": "~1.3.3",