MCPcopy
hub / github.com/Effect-TS/effect / fromInput

Function fromInput

packages/platform/src/Headers.ts:96–115  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

94 * @category constructors
95 */
96export 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

Callers 1

Headers.tsFile · 0.70

Calls 3

createMethod · 0.80
entriesMethod · 0.80
joinMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…