Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: requires Node.js >= v18 (#29) #30

Merged
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
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ Pending

* change:
- requires Node.js 18 or newer
- remove deprecated number argument for options
* breaking:
- drop support for Node.js 16 and older
- response-time no longer supports passing a single number as the `options` argument. Use the `{ digits: <number> }` format instead.
UlisesGascon marked this conversation as resolved.
Show resolved Hide resolved
* deps:
- remove [email protected]

2.3.3 / 2024-10-07
==========
Expand Down
7 changes: 0 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* @private
*/

var deprecate = require('depd')('response-time')
var onHeaders = require('on-headers')

/**
Expand All @@ -38,12 +37,6 @@ module.exports = responseTime
function responseTime (options) {
var opts = options || {}

if (typeof options === 'number') {
// back-compat single number argument
deprecate('number argument: use {digits: ' + JSON.stringify(options) + '} instead')
opts = { digits: options }
}

// get the function to invoke
var fn = typeof opts !== 'function'
? createSetHeader(opts)
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
],
"repository": "expressjs/response-time",
"dependencies": {
"depd": "~2.0.0",
"on-headers": "~1.0.1"
},
"devDependencies": {
Expand Down
49 changes: 5 additions & 44 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,11 @@ describe('responseTime()', function () {
.expect('X-Response-Time', 'bogus', done)
})

describe('with "digits"', function () {
it('should default to 3', function (done) {
var server = createServer()
request(server)
.get('/')
.expect('X-Response-Time', /^[0-9]+\.[0-9]{3}ms$/, done)
})

it('should allow custom digits', function (done) {
var server = createServer(5)
request(server)
.get('/')
.expect('X-Response-Time', /^[0-9]+\.[0-9]{5}ms$/, done)
})

it('should allow no digits', function (done) {
var server = createServer(0)
request(server)
.get('/')
.expect('X-Response-Time', /^[0-9]+ms$/, done)
})
it('should default to 3 digits', function (done) {
var server = createServer()
request(server)
.get('/')
.expect('X-Response-Time', /^[0-9]+\.[0-9]{3}ms$/, done)
})
})

Expand Down Expand Up @@ -82,29 +66,6 @@ describe('responseTime(fn)', function () {
})

describe('responseTime(options)', function () {
describe('with "digits" option', function () {
it('should default to 3', function (done) {
var server = createServer()
request(server)
.get('/')
.expect('X-Response-Time', /^[0-9]+\.[0-9]{3}ms$/, done)
})

it('should allow custom digits', function (done) {
var server = createServer({ digits: 5 })
request(server)
.get('/')
.expect('X-Response-Time', /^[0-9]+\.[0-9]{5}ms$/, done)
})

it('should allow no digits', function (done) {
var server = createServer({ digits: 0 })
request(server)
.get('/')
.expect('X-Response-Time', /^[0-9]+ms$/, done)
})
})

describe('with "header" option', function () {
it('should default to X-Response-Time', function (done) {
var server = createServer()
Expand Down
Loading