Skip to content

Commit

Permalink
Use Array.flat instead of array-flatten package
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillip9587 committed Oct 21, 2024
1 parent 2e7fb67 commit c04204e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -27,6 +26,7 @@ const setPrototypeOf = require('setprototypeof')
*/

const slice = Array.prototype.slice
const flatten = Array.prototype.flat

/**
* Expose `Router`.
Expand Down Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions lib/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* @private
*/

const flatten = require('array-flatten').flatten
const Layer = require('./layer')
const methods = require('methods')

Expand All @@ -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'
Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c04204e

Please sign in to comment.