0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-21 18:18:57 +01:00

perf(context): improve performance of context (setHeaders) (#3592)

* perf(context): improve performance of context (newResponse, setHeaders)

* Revert context.ts
This commit is contained in:
EdamAmex 2024-10-31 15:55:49 +09:00 committed by GitHub
parent a16bcda120
commit 4dd8b2b435
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -266,7 +266,10 @@ export const TEXT_PLAIN = 'text/plain; charset=UTF-8'
* @returns The updated Headers object.
*/
const setHeaders = (headers: Headers, map: Record<string, string> = {}) => {
Object.entries(map).forEach(([key, value]) => headers.set(key, value))
for (let i = 0, keys = Object.keys(map), len = keys.length; i < len; i++) {
const key = keys[i]
headers.set(key, map[key])
}
return headers
}