Skip to content

Commit 1b25008

Browse files
haramjtargos
authored andcommitted
http: improve writeEarlyHints by avoiding for-of loop
PR-URL: #59958 Refs: https://github.com/nodejs/node/blob/main/doc/contributing/primordials.md#unsafe-array-iteration Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 6529ae9 commit 1b25008

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/_http_server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ ServerResponse.prototype.writeEarlyHints = function writeEarlyHints(hints, cb) {
330330

331331
head += 'Link: ' + link + '\r\n';
332332

333-
for (const key of ObjectKeys(hints)) {
333+
const keys = ObjectKeys(hints);
334+
for (let i = 0; i < keys.length; i++) {
335+
const key = keys[i];
334336
if (key !== 'link') {
335337
head += key + ': ' + hints[key] + '\r\n';
336338
}

0 commit comments

Comments
 (0)