Skip to content

Commit 0bf47b4

Browse files
committed
docs(setHeaders): Add JsDoc
1 parent 1c75332 commit 0bf47b4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/setHeaders.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ function setPojoHeaders(headers: Record<string, string>, newHeaders: HeaderInput
102102
}
103103
}
104104

105+
/**
106+
* Sets the provided HTTP headers into the `init.headers` property of the given `init` object.
107+
*
108+
* The function sets headers, and doesn't append values to existing headers. The only exception is when the new
109+
* headers are specified with a POJO or Map object, where the value can be an array of strings. In these cases, the
110+
* array of values are combined and this combination becomes the value of the header.
111+
* @param init The `init` object that will receive the specified headers.
112+
* @param headers The collection of headers to include in the `init` object.
113+
*/
105114
export function setHeaders(init: Exclude<Parameters<typeof fetch>[1], undefined>, headers: HeaderInput) {
106115
if (!init) {
107116
throw new Error("The 'init' argument cannot be undefined.");

0 commit comments

Comments
 (0)