From d24644694516eee889320a25954b6413db24440a Mon Sep 17 00:00:00 2001 From: Phillip9587 Date: Fri, 15 Nov 2024 17:08:49 +0100 Subject: [PATCH] cleanup: remove unnecessary require for global Buffer The Buffer object is globally available in Node.js, so there is no need to explicitly require it. --- History.md | 1 + lib/response.js | 1 - lib/utils.js | 1 - test/express.json.js | 1 - test/express.raw.js | 1 - test/express.static.js | 1 - test/express.text.js | 1 - test/express.urlencoded.js | 1 - test/res.attachment.js | 1 - test/res.download.js | 1 - test/res.send.js | 1 - test/res.sendFile.js | 1 - test/support/utils.js | 1 - test/utils.js | 1 - 14 files changed, 1 insertion(+), 13 deletions(-) diff --git a/History.md b/History.md index ae5a167a69..80eaabe420 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ======================== * Remove `Object.setPrototypeOf` polyfill +* cleanup: remove unnecessary require for global Buffer 5.0.1 / 2024-10-08 ========== diff --git a/lib/response.js b/lib/response.js index 29511a74e0..e439a06ae8 100644 --- a/lib/response.js +++ b/lib/response.js @@ -12,7 +12,6 @@ * @private */ -var Buffer = require('node:buffer').Buffer var contentDisposition = require('content-disposition'); var createError = require('http-errors') var encodeUrl = require('encodeurl'); diff --git a/lib/utils.js b/lib/utils.js index 35b2781306..0092629f17 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -12,7 +12,6 @@ * @api private */ -var Buffer = require('node:buffer').Buffer var contentType = require('content-type'); var etag = require('etag'); var mime = require('mime-types') diff --git a/test/express.json.js b/test/express.json.js index c92d8234bb..a46cc16fb8 100644 --- a/test/express.json.js +++ b/test/express.json.js @@ -2,7 +2,6 @@ var assert = require('assert') var asyncHooks = tryRequire('async_hooks') -var Buffer = require('node:buffer').Buffer var express = require('..') var request = require('supertest') diff --git a/test/express.raw.js b/test/express.raw.js index cd526e3913..08f44904a4 100644 --- a/test/express.raw.js +++ b/test/express.raw.js @@ -2,7 +2,6 @@ var assert = require('assert') var asyncHooks = tryRequire('async_hooks') -var Buffer = require('node:buffer').Buffer var express = require('..') var request = require('supertest') diff --git a/test/express.static.js b/test/express.static.js index c7c7d4df89..65a3718a60 100644 --- a/test/express.static.js +++ b/test/express.static.js @@ -1,7 +1,6 @@ 'use strict' var assert = require('assert') -var Buffer = require('node:buffer').Buffer var express = require('..') var path = require('path') var request = require('supertest') diff --git a/test/express.text.js b/test/express.text.js index e5fd9e415a..1bcc034b86 100644 --- a/test/express.text.js +++ b/test/express.text.js @@ -2,7 +2,6 @@ var assert = require('assert') var asyncHooks = tryRequire('async_hooks') -var Buffer = require('node:buffer').Buffer var express = require('..') var request = require('supertest') diff --git a/test/express.urlencoded.js b/test/express.urlencoded.js index 2bf72b79b9..8503e0079a 100644 --- a/test/express.urlencoded.js +++ b/test/express.urlencoded.js @@ -2,7 +2,6 @@ var assert = require('assert') var asyncHooks = tryRequire('async_hooks') -var Buffer = require('node:buffer').Buffer var express = require('..') var request = require('supertest') diff --git a/test/res.attachment.js b/test/res.attachment.js index 1281584f3c..68e611bbc7 100644 --- a/test/res.attachment.js +++ b/test/res.attachment.js @@ -1,6 +1,5 @@ 'use strict' -var Buffer = require('node:buffer').Buffer var express = require('../') , request = require('supertest'); diff --git a/test/res.download.js b/test/res.download.js index 3ccd0c7744..82243d8b00 100644 --- a/test/res.download.js +++ b/test/res.download.js @@ -3,7 +3,6 @@ var after = require('after'); var assert = require('assert') var asyncHooks = tryRequire('async_hooks') -var Buffer = require('node:buffer').Buffer var express = require('..'); var path = require('path') var request = require('supertest'); diff --git a/test/res.send.js b/test/res.send.js index 1f9b372c8c..23ffd9305c 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -1,7 +1,6 @@ 'use strict' var assert = require('assert') -var Buffer = require('node:buffer').Buffer var express = require('..'); var methods = require('methods'); var request = require('supertest'); diff --git a/test/res.sendFile.js b/test/res.sendFile.js index d0b4b1b50c..e211fe9cb6 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -3,7 +3,6 @@ var after = require('after'); var assert = require('assert') var asyncHooks = tryRequire('async_hooks') -var Buffer = require('node:buffer').Buffer var express = require('../') , request = require('supertest') var onFinished = require('on-finished'); diff --git a/test/support/utils.js b/test/support/utils.js index 50350943d4..c74f8efe0c 100644 --- a/test/support/utils.js +++ b/test/support/utils.js @@ -5,7 +5,6 @@ */ var assert = require('assert'); -var Buffer = require('node:buffer').Buffer /** * Module exports. diff --git a/test/utils.js b/test/utils.js index 0b68d38a69..ae73988b01 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,7 +1,6 @@ 'use strict' var assert = require('assert'); -var Buffer = require('node:buffer').Buffer var utils = require('../lib/utils'); describe('utils.etag(body, encoding)', function(){