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:
parent
a16bcda120
commit
4dd8b2b435
@ -266,7 +266,10 @@ export const TEXT_PLAIN = 'text/plain; charset=UTF-8'
|
|||||||
* @returns The updated Headers object.
|
* @returns The updated Headers object.
|
||||||
*/
|
*/
|
||||||
const setHeaders = (headers: Headers, map: Record<string, string> = {}) => {
|
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
|
return headers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user