Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsdoc: adds some jsdoc to fetch headers implementation, minor changes #3687

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions lib/web/fetch/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ const util = require('node:util')

/**
* @param {number} code
* @returns {code is (0x0a | 0x0d | 0x09 | 0x20)}
*/
function isHTTPWhiteSpaceCharCode (code) {
return code === 0x00a || code === 0x00d || code === 0x009 || code === 0x020
return code === 0x0a || code === 0x0d || code === 0x09 || code === 0x20
}

/**
* @see https://fetch.spec.whatwg.org/#concept-header-value-normalize
* @param {string} potentialValue
* @returns {string}
*/
function headerValueNormalize (potentialValue) {
// To normalize a byte sequence potentialValue, remove
Expand All @@ -36,6 +38,10 @@ function headerValueNormalize (potentialValue) {
return i === 0 && j === potentialValue.length ? potentialValue : potentialValue.substring(i, j)
}

/**
* @param {Headers} headers
* @param {Array|Object} object
*/
function fill (headers, object) {
// To fill a Headers object headers with a given object object, run these steps:

Expand Down Expand Up @@ -75,6 +81,9 @@ function fill (headers, object) {

/**
* @see https://fetch.spec.whatwg.org/#concept-headers-append
* @param {Headers} headers
* @param {string} name
* @param {string} value
*/
function appendHeader (headers, name, value) {
// 1. Normalize value.
Expand Down Expand Up @@ -417,8 +426,15 @@ class HeadersList {
// https://fetch.spec.whatwg.org/#headers-class
class Headers {
#guard
/**
* @type {HeadersList}
*/
#headersList

/**
* @param {HeadersInit|Symbol} [init]
* @returns
*/
constructor (init = undefined) {
if (init === kConstruct) {
return
Expand Down Expand Up @@ -627,8 +643,12 @@ class Headers {
return o.#headersList
}

static setHeadersList (o, list) {
o.#headersList = list
/**
* @param {Headers} target
* @param {HeadersList} list
*/
static setHeadersList (target, list) {
target.#headersList = list
}
}

Expand Down
Loading