Skip to content
Open
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
Expand Up @@ -4,6 +4,11 @@ unreleased
* Remove `setImmediate` support check
* Restore `debug` dependency

3.0.0 / ????-??-??
==================

* Replace `is-promise` dependency with `instanceof` check (drops support for non-native promises)

2.1.0 / 2025-02-10
==================

Expand Down
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* @private
*/

const isPromise = require('is-promise')
const Layer = require('./lib/layer')
const { METHODS } = require('node:http')
const parseUrl = require('parseurl')
Expand Down Expand Up @@ -646,7 +645,7 @@ function processParams (params, layer, called, req, res, done) {

try {
const ret = fn(req, res, paramCallback, paramVal, key)
if (isPromise(ret)) {
if (ret instanceof Promise) {
ret.then(null, function (error) {
paramCallback(error || new Error('Rejected promise'))
})
Expand Down
5 changes: 2 additions & 3 deletions lib/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* @private
*/

const isPromise = require('is-promise')
const pathRegexp = require('path-to-regexp')
const debug = require('debug')('router:layer')

Expand Down Expand Up @@ -115,7 +114,7 @@ Layer.prototype.handleError = function handleError (error, req, res, next) {
const ret = fn(error, req, res, next)

// wait for returned promise
if (isPromise(ret)) {
if (ret instanceof Promise) {
ret.then(null, function (error) {
next(error || new Error('Rejected promise'))
})
Expand Down Expand Up @@ -147,7 +146,7 @@ Layer.prototype.handleRequest = function handleRequest (req, res, next) {
const ret = fn(req, res, next)

// wait for returned promise
if (isPromise(ret)) {
if (ret instanceof Promise) {
ret.then(null, function (error) {
next(error || new Error('Rejected promise'))
})
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"repository": "pillarjs/router",
"dependencies": {
"debug": "^4.4.0",
"is-promise": "^4.0.0",
"parseurl": "^1.3.3",
"path-to-regexp": "^8.0.0"
},
Expand Down