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 22, 2024
1 parent 2e7fb67 commit 19b42bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
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

0 comments on commit 19b42bb

Please sign in to comment.