From 10805a5dc00b9b60022827164e149c7c9760143d Mon Sep 17 00:00:00 2001 From: Nanasi Date: Thu, 6 Aug 2026 03:03:31 -0400 Subject: [PATCH] feat(res.send): add BigInt support --- lib/response.js | 10 ++++++++++ test/res.send.js | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/response.js b/lib/response.js index b4755a5c060..b373dc1e103 100644 --- a/lib/response.js +++ b/lib/response.js @@ -156,6 +156,16 @@ res.send = function send(body) { return this.json(chunk); } break; + case 'bigint': + chunk = chunk.toString(); + encoding = 'utf8'; + const ct = this.get('Content-Type'); + if (typeof ct === 'string') { + this.set('Content-Type', setCharset(ct, 'utf-8')); + } else { + this.type('txt'); + } + break; } // determine if ETag should be generated diff --git a/test/res.send.js b/test/res.send.js index f38ffde9776..519f19e2783 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -617,4 +617,19 @@ describe('res', function(){ }) }); }) + + describe('when chunk is bigint', function(){ + it('should send the string representation of bigint', function(done){ + var app = express(); + + app.use(function(req, res){ + res.send(123n); + }); + + request(app) + .get('/') + .expect('Content-Type', 'text/plain; charset=utf-8') + .expect(200, '123', done); + }) + }) })