Skip to content

Commit

Permalink
jsdoc: adds some jsdoc to fetch headers implementation, minor changes (
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored and flakey5 committed Oct 8, 2024
1 parent a99f32a commit be9b5ee
Showing 1 changed file with 23 additions and 3 deletions.
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

0 comments on commit be9b5ee

Please sign in to comment.