Skip to content

Commit

Permalink
perf: avoid Array.isArray
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx committed Dec 3, 2023
1 parent 05c9301 commit fb804d5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,13 @@ function parseHeaders (headers, obj = {}) {
let val = obj[lowerCasedKey]

if (!val) {
if (Array.isArray(headers[i + 1])) {
obj[lowerCasedKey] = headers[i + 1].map(x => x.toString('utf8'))
const headersValue = headers[i + 1]
if (typeof headersValue === 'string') {
obj[lowerCasedKey] = headersValue
} else if (Array.isArray(headersValue)) {
obj[lowerCasedKey] = headersValue.map(x => x.toString('utf8'))
} else {
obj[lowerCasedKey] = headers[i + 1].toString('utf8')
obj[lowerCasedKey] = headersValue.toString('utf8')
}
} else {
if (!Array.isArray(val)) {
Expand Down

0 comments on commit fb804d5

Please sign in to comment.