(input)
| 94 | * @category constructors |
| 95 | */ |
| 96 | export const fromInput: (input?: Input) => Headers = (input) => { |
| 97 | if (input === undefined) { |
| 98 | return empty |
| 99 | } else if (Symbol.iterator in input) { |
| 100 | const out: Record<string, string> = Object.create(Proto) |
| 101 | for (const [k, v] of input) { |
| 102 | out[k.toLowerCase()] = v |
| 103 | } |
| 104 | return out as Headers |
| 105 | } |
| 106 | const out: Record<string, string> = Object.create(Proto) |
| 107 | for (const [k, v] of Object.entries(input)) { |
| 108 | if (Array.isArray(v)) { |
| 109 | out[k.toLowerCase()] = v.join(", ") |
| 110 | } else if (v !== undefined) { |
| 111 | out[k.toLowerCase()] = v as string |
| 112 | } |
| 113 | } |
| 114 | return out as Headers |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * @since 1.0.0 |
no test coverage detected
searching dependent graphs…