Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
unreleased
=================

* Use `Array.flat` instead of `array-flatten` package

2.0.0 / 2024-09-09
==================

Expand Down
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
Loading