code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function headerValueNormalize (potentialValue) { // To normalize a byte sequence potentialValue, remove // any leading and trailing HTTP whitespace bytes from // potentialValue. let i = 0; let j = potentialValue.length while (j > i && isHTTPWhiteSpaceCharCode(potentialValue.charCodeAt(j - 1))) --j while (j > i && isHTTPWhiteSpaceCharCode(potentialValue.charCodeAt(i))) ++i return i === 0 && j === potentialValue.length ? potentialValue : potentialValue.substring(i, j) }
@see https://fetch.spec.whatwg.org/#concept-header-value-normalize @param {string} potentialValue
headerValueNormalize
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
keys () { webidl.brandCheck(this, Headers) if (this[kGuard] === 'immutable') { const value = this[kHeadersSortedMap] return makeIterator(() => value, 'Headers', 'key') } return makeIterator( () => [...this[kHeadersSortedMap].values()], 'Headers', 'key' ) }
@param {(value: string, key: string, self: Headers) => void} callbackFn @param {unknown} thisArg
keys
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
values () { webidl.brandCheck(this, Headers) if (this[kGuard] === 'immutable') { const value = this[kHeadersSortedMap] return makeIterator(() => value, 'Headers', 'value') } return makeIterator( () => [...this[kHeadersSortedMap].values()], 'Headers', 'value' ) }
@param {(value: string, key: string, self: Headers) => void} callbackFn @param {unknown} thisArg
values
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
entries () { webidl.brandCheck(this, Headers) if (this[kGuard] === 'immutable') { const value = this[kHeadersSortedMap] return makeIterator(() => value, 'Headers', 'key+value') } return makeIterator( () => [...this[kHeadersSortedMap].values()], 'Headers', 'key+value' ) }
@param {(value: string, key: string, self: Headers) => void} callbackFn @param {unknown} thisArg
entries
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
forEach (callbackFn, thisArg = globalThis) { webidl.brandCheck(this, Headers) webidl.argumentLengthCheck(arguments, 1, { header: 'Headers.forEach' }) if (typeof callbackFn !== 'function') { throw new TypeError( "Failed to execute 'forEach' on 'Headers': parameter 1 is not of type 'Function'." ) } for (const [key, value] of this) { callbackFn.apply(thisArg, [value, key, this]) } }
@param {(value: string, key: string, self: Headers) => void} callbackFn @param {unknown} thisArg
forEach
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function requestCurrentURL (request) { return request.urlList[request.urlList.length - 1] }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
requestCurrentURL
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isErrorLike (object) { return object instanceof Error || ( object?.constructor?.name === 'Error' || object?.constructor?.name === 'DOMException' ) }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
isErrorLike
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isValidReasonPhrase (statusText) { for (let i = 0; i < statusText.length; ++i) { const c = statusText.charCodeAt(i) if ( !( ( c === 0x09 || // HTAB (c >= 0x20 && c <= 0x7e) || // SP / VCHAR (c >= 0x80 && c <= 0xff) ) // obs-text ) ) { return false } } return true }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
isValidReasonPhrase
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isTokenCharCode (c) { switch (c) { case 0x22: case 0x28: case 0x29: case 0x2c: case 0x2f: case 0x3a: case 0x3b: case 0x3c: case 0x3d: case 0x3e: case 0x3f: case 0x40: case 0x5b: case 0x5c: case 0x5d: case 0x7b: case 0x7d: // DQUOTE and "(),/:;<=>?@[\]{}" return false default: // VCHAR %x21-7E return c >= 0x21 && c <= 0x7e } }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
isTokenCharCode
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isValidHTTPToken (characters) { if (characters.length === 0) { return false } for (let i = 0; i < characters.length; ++i) { if (!isTokenCharCode(characters.charCodeAt(i))) { return false } } return true }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
isValidHTTPToken
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isValidHeaderName (potentialValue) { return isValidHTTPToken(potentialValue) }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
isValidHeaderName
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isValidHeaderValue (potentialValue) { // - Has no leading or trailing HTTP tab or space bytes. // - Contains no 0x00 (NUL) or HTTP newline bytes. if ( potentialValue.startsWith('\t') || potentialValue.startsWith(' ') || potentialValue.endsWith('\t') || potentialValue.endsWith(' ') ) { return false } if ( potentialValue.includes('\0') || potentialValue.includes('\r') || potentialValue.includes('\n') ) { return false } return true }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
isValidHeaderValue
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function crossOriginResourcePolicyCheck () { // TODO return 'allowed' }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
crossOriginResourcePolicyCheck
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function corsCheck () { // TODO return 'success' }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
corsCheck
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function TAOCheck () { // TODO return 'success' }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
TAOCheck
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function coarsenedSharedCurrentTime (crossOriginIsolatedCapability) { // TODO return performance.now() }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
coarsenedSharedCurrentTime
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function createOpaqueTimingInfo (timingInfo) { return { startTime: timingInfo.startTime ?? 0, redirectStartTime: 0, redirectEndTime: 0, postRedirectStartTime: timingInfo.startTime ?? 0, finalServiceWorkerStartTime: 0, finalNetworkResponseStartTime: 0, finalNetworkRequestStartTime: 0, endTime: 0, encodedBodySize: 0, decodedBodySize: 0, finalConnectionTimingInfo: null } }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
createOpaqueTimingInfo
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function makePolicyContainer () { // Note: the fetch spec doesn't make use of embedder policy or CSP list return { referrerPolicy: 'strict-origin-when-cross-origin' } }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
makePolicyContainer
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function clonePolicyContainer (policyContainer) { return { referrerPolicy: policyContainer.referrerPolicy } }
@see https://fetch.spec.whatwg.org/#header-value @param {string} potentialValue
clonePolicyContainer
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isURLPotentiallyTrustworthy (url) { if (!(url instanceof URL)) { return false } // If child of about, return true if (url.href === 'about:blank' || url.href === 'about:srcdoc') { return true } // If scheme is data, return true if (url.protocol === 'data:') return true // If file, return true if (url.protocol === 'file:') return true return isOriginPotentiallyTrustworthy(url.origin) function isOriginPotentiallyTrustworthy (origin) { // If origin is explicitly null, return false if (origin == null || origin === 'null') return false const originAsURL = new URL(origin) // If secure, return true if (originAsURL.protocol === 'https:' || originAsURL.protocol === 'wss:') { return true } // If localhost or variants, return true if (/^127(?:\.[0-9]+){0,2}\.[0-9]+$|^\[(?:0*:)*?:?0*1\]$/.test(originAsURL.hostname) || (originAsURL.hostname === 'localhost' || originAsURL.hostname.includes('localhost.')) || (originAsURL.hostname.endsWith('.localhost'))) { return true } // If any other, return false return false } }
@see https://w3c.github.io/webappsec-subresource-integrity/#does-response-match-metadatalist @param {Uint8Array} bytes @param {string} metadataList
isURLPotentiallyTrustworthy
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isOriginPotentiallyTrustworthy (origin) { // If origin is explicitly null, return false if (origin == null || origin === 'null') return false const originAsURL = new URL(origin) // If secure, return true if (originAsURL.protocol === 'https:' || originAsURL.protocol === 'wss:') { return true } // If localhost or variants, return true if (/^127(?:\.[0-9]+){0,2}\.[0-9]+$|^\[(?:0*:)*?:?0*1\]$/.test(originAsURL.hostname) || (originAsURL.hostname === 'localhost' || originAsURL.hostname.includes('localhost.')) || (originAsURL.hostname.endsWith('.localhost'))) { return true } // If any other, return false return false }
@see https://w3c.github.io/webappsec-subresource-integrity/#does-response-match-metadatalist @param {Uint8Array} bytes @param {string} metadataList
isOriginPotentiallyTrustworthy
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function getStrongestMetadata (metadataList) { // Let algorithm be the algo component of the first item in metadataList. // Can be sha256 let algorithm = metadataList[0].algo // If the algorithm is sha512, then it is the strongest // and we can return immediately if (algorithm[3] === '5') { return algorithm } for (let i = 1; i < metadataList.length; ++i) { const metadata = metadataList[i] // If the algorithm is sha512, then it is the strongest // and we can break the loop immediately if (metadata.algo[3] === '5') { algorithm = 'sha512' break // If the algorithm is sha384, then a potential sha256 or sha384 is ignored } else if (algorithm[3] === '3') { continue // algorithm is sha256, check if algorithm is sha384 and if so, set it as // the strongest } else if (metadata.algo[3] === '3') { algorithm = 'sha384' } } return algorithm }
@link {https://html.spec.whatwg.org/multipage/origin.html#same-origin} @param {URL} A @param {URL} B
getStrongestMetadata
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function filterMetadataListByAlgorithm (metadataList, algorithm) { if (metadataList.length === 1) { return metadataList } let pos = 0 for (let i = 0; i < metadataList.length; ++i) { if (metadataList[i].algo === algorithm) { metadataList[pos++] = metadataList[i] } } metadataList.length = pos return metadataList }
@see https://fetch.spec.whatwg.org/#concept-method-normalize @param {string} method
filterMetadataListByAlgorithm
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function compareBase64Mixed (actualValue, expectedValue) { if (actualValue.length !== expectedValue.length) { return false } for (let i = 0; i < actualValue.length; ++i) { if (actualValue[i] !== expectedValue[i]) { if ( (actualValue[i] === '+' && expectedValue[i] === '-') || (actualValue[i] === '/' && expectedValue[i] === '_') ) { continue } return false } } return true }
@see https://fetch.spec.whatwg.org/#concept-method-normalize @param {string} method
compareBase64Mixed
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function tryUpgradeRequestToAPotentiallyTrustworthyURL (request) { // TODO }
@see https://webidl.spec.whatwg.org/#dfn-iterator-prototype-object @param {() => unknown[]} iterator @param {string} name name of the instance @param {'key'|'value'|'key+value'} kind
tryUpgradeRequestToAPotentiallyTrustworthyURL
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function sameOrigin (A, B) { // 1. If A and B are the same opaque origin, then return true. if (A.origin === B.origin && A.origin === 'null') { return true } // 2. If A and B are both tuple origins and their schemes, // hosts, and port are identical, then return true. if (A.protocol === B.protocol && A.hostname === B.hostname && A.port === B.port) { return true } // 3. Return false. return false }
@see https://webidl.spec.whatwg.org/#dfn-iterator-prototype-object @param {() => unknown[]} iterator @param {string} name name of the instance @param {'key'|'value'|'key+value'} kind
sameOrigin
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function createDeferredPromise () { let res let rej const promise = new Promise((resolve, reject) => { res = resolve rej = reject }) return { promise, resolve: res, reject: rej } }
@see https://webidl.spec.whatwg.org/#dfn-iterator-prototype-object @param {() => unknown[]} iterator @param {string} name name of the instance @param {'key'|'value'|'key+value'} kind
createDeferredPromise
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isAborted (fetchParams) { return fetchParams.controller.state === 'aborted' }
@see https://webidl.spec.whatwg.org/#dfn-iterator-prototype-object @param {() => unknown[]} iterator @param {string} name name of the instance @param {'key'|'value'|'key+value'} kind
isAborted
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isCancelled (fetchParams) { return fetchParams.controller.state === 'aborted' || fetchParams.controller.state === 'terminated' }
@see https://webidl.spec.whatwg.org/#dfn-iterator-prototype-object @param {() => unknown[]} iterator @param {string} name name of the instance @param {'key'|'value'|'key+value'} kind
isCancelled
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function normalizeMethod (method) { return normalizeMethodRecord[method.toLowerCase()] ?? method }
@see https://webidl.spec.whatwg.org/#dfn-iterator-prototype-object @param {() => unknown[]} iterator @param {string} name name of the instance @param {'key'|'value'|'key+value'} kind
normalizeMethod
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isReadableStreamLike (stream) { if (!ReadableStream) { ReadableStream = (__nccwpck_require__(3774).ReadableStream) } return stream instanceof ReadableStream || ( stream[Symbol.toStringTag] === 'ReadableStream' && typeof stream.tee === 'function' ) }
@see https://fetch.spec.whatwg.org/#is-local @param {URL} url
isReadableStreamLike
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function readableStreamClose (controller) { try { controller.close() } catch (err) { // TODO: add comment explaining why this error occurs. if (!err.message.includes('Controller is already closed')) { throw err } } }
Fetch supports node >= 16.8.0, but Object.hasOwn was added in v16.9.0.
readableStreamClose
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function getEncoding (label) { if (!label) { return 'failure' } // 1. Remove any leading and trailing ASCII whitespace from label. // 2. If label is an ASCII case-insensitive match for any of the // labels listed in the table below, then return the // corresponding encoding; otherwise return failure. switch (label.trim().toLowerCase()) { case 'unicode-1-1-utf-8': case 'unicode11utf8': case 'unicode20utf8': case 'utf-8': case 'utf8': case 'x-unicode20utf8': return 'UTF-8' case '866': case 'cp866': case 'csibm866': case 'ibm866': return 'IBM866' case 'csisolatin2': case 'iso-8859-2': case 'iso-ir-101': case 'iso8859-2': case 'iso88592': case 'iso_8859-2': case 'iso_8859-2:1987': case 'l2': case 'latin2': return 'ISO-8859-2' case 'csisolatin3': case 'iso-8859-3': case 'iso-ir-109': case 'iso8859-3': case 'iso88593': case 'iso_8859-3': case 'iso_8859-3:1988': case 'l3': case 'latin3': return 'ISO-8859-3' case 'csisolatin4': case 'iso-8859-4': case 'iso-ir-110': case 'iso8859-4': case 'iso88594': case 'iso_8859-4': case 'iso_8859-4:1988': case 'l4': case 'latin4': return 'ISO-8859-4' case 'csisolatincyrillic': case 'cyrillic': case 'iso-8859-5': case 'iso-ir-144': case 'iso8859-5': case 'iso88595': case 'iso_8859-5': case 'iso_8859-5:1988': return 'ISO-8859-5' case 'arabic': case 'asmo-708': case 'csiso88596e': case 'csiso88596i': case 'csisolatinarabic': case 'ecma-114': case 'iso-8859-6': case 'iso-8859-6-e': case 'iso-8859-6-i': case 'iso-ir-127': case 'iso8859-6': case 'iso88596': case 'iso_8859-6': case 'iso_8859-6:1987': return 'ISO-8859-6' case 'csisolatingreek': case 'ecma-118': case 'elot_928': case 'greek': case 'greek8': case 'iso-8859-7': case 'iso-ir-126': case 'iso8859-7': case 'iso88597': case 'iso_8859-7': case 'iso_8859-7:1987': case 'sun_eu_greek': return 'ISO-8859-7' case 'csiso88598e': case 'csisolatinhebrew': case 'hebrew': case 'iso-8859-8': case 'iso-8859-8-e': case 'iso-ir-138': case 'iso8859-8': case 'iso88598': case 'iso_8859-8': case 'iso_8859-8:1988': case 'visual': return 'ISO-8859-8' case 'csiso88598i': case 'iso-8859-8-i': case 'logical': return 'ISO-8859-8-I' case 'csisolatin6': case 'iso-8859-10': case 'iso-ir-157': case 'iso8859-10': case 'iso885910': case 'l6': case 'latin6': return 'ISO-8859-10' case 'iso-8859-13': case 'iso8859-13': case 'iso885913': return 'ISO-8859-13' case 'iso-8859-14': case 'iso8859-14': case 'iso885914': return 'ISO-8859-14' case 'csisolatin9': case 'iso-8859-15': case 'iso8859-15': case 'iso885915': case 'iso_8859-15': case 'l9': return 'ISO-8859-15' case 'iso-8859-16': return 'ISO-8859-16' case 'cskoi8r': case 'koi': case 'koi8': case 'koi8-r': case 'koi8_r': return 'KOI8-R' case 'koi8-ru': case 'koi8-u': return 'KOI8-U' case 'csmacintosh': case 'mac': case 'macintosh': case 'x-mac-roman': return 'macintosh' case 'iso-8859-11': case 'iso8859-11': case 'iso885911': case 'tis-620': case 'windows-874': return 'windows-874' case 'cp1250': case 'windows-1250': case 'x-cp1250': return 'windows-1250' case 'cp1251': case 'windows-1251': case 'x-cp1251': return 'windows-1251' case 'ansi_x3.4-1968': case 'ascii': case 'cp1252': case 'cp819': case 'csisolatin1': case 'ibm819': case 'iso-8859-1': case 'iso-ir-100': case 'iso8859-1': case 'iso88591': case 'iso_8859-1': case 'iso_8859-1:1987': case 'l1': case 'latin1': case 'us-ascii': case 'windows-1252': case 'x-cp1252': return 'windows-1252' case 'cp1253': case 'windows-1253': case 'x-cp1253': return 'windows-1253' case 'cp1254': case 'csisolatin5': case 'iso-8859-9': case 'iso-ir-148': case 'iso8859-9': case 'iso88599': case 'iso_8859-9': case 'iso_8859-9:1989': case 'l5': case 'latin5': case 'windows-1254': case 'x-cp1254': return 'windows-1254' case 'cp1255': case 'windows-1255': case 'x-cp1255': return 'windows-1255' case 'cp1256': case 'windows-1256': case 'x-cp1256': return 'windows-1256' case 'cp1257': case 'windows-1257': case 'x-cp1257': return 'windows-1257' case 'cp1258': case 'windows-1258': case 'x-cp1258': return 'windows-1258' case 'x-mac-cyrillic': case 'x-mac-ukrainian': return 'x-mac-cyrillic' case 'chinese': case 'csgb2312': case 'csiso58gb231280': case 'gb2312': case 'gb_2312': case 'gb_2312-80': case 'gbk': case 'iso-ir-58': case 'x-gbk': return 'GBK' case 'gb18030': return 'gb18030' case 'big5': case 'big5-hkscs': case 'cn-big5': case 'csbig5': case 'x-x-big5': return 'Big5' case 'cseucpkdfmtjapanese': case 'euc-jp': case 'x-euc-jp': return 'EUC-JP' case 'csiso2022jp': case 'iso-2022-jp': return 'ISO-2022-JP' case 'csshiftjis': case 'ms932': case 'ms_kanji': case 'shift-jis': case 'shift_jis': case 'sjis': case 'windows-31j': case 'x-sjis': return 'Shift_JIS' case 'cseuckr': case 'csksc56011987': case 'euc-kr': case 'iso-ir-149': case 'korean': case 'ks_c_5601-1987': case 'ks_c_5601-1989': case 'ksc5601': case 'ksc_5601': case 'windows-949': return 'EUC-KR' case 'csiso2022kr': case 'hz-gb-2312': case 'iso-2022-cn': case 'iso-2022-cn-ext': case 'iso-2022-kr': case 'replacement': return 'replacement' case 'unicodefffe': case 'utf-16be': return 'UTF-16BE' case 'csunicode': case 'iso-10646-ucs-2': case 'ucs-2': case 'unicode': case 'unicodefeff': case 'utf-16': case 'utf-16le': return 'UTF-16LE' case 'x-user-defined': return 'x-user-defined' default: return 'failure' } }
@see https://encoding.spec.whatwg.org/#concept-encoding-get @param {string|undefined} label
getEncoding
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor () { super() this[kState] = 'empty' this[kResult] = null this[kError] = null this[kEvents] = { loadend: null, error: null, abort: null, load: null, progress: null, loadstart: null } }
@see https://w3c.github.io/FileAPI/#dfn-abort
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
readAsArrayBuffer (blob) { webidl.brandCheck(this, FileReader) webidl.argumentLengthCheck(arguments, 1, { header: 'FileReader.readAsArrayBuffer' }) blob = webidl.converters.Blob(blob, { strict: false }) // The readAsArrayBuffer(blob) method, when invoked, // must initiate a read operation for blob with ArrayBuffer. readOperation(this, blob, 'ArrayBuffer') }
@see https://w3c.github.io/FileAPI/#dfn-abort
readAsArrayBuffer
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
readAsBinaryString (blob) { webidl.brandCheck(this, FileReader) webidl.argumentLengthCheck(arguments, 1, { header: 'FileReader.readAsBinaryString' }) blob = webidl.converters.Blob(blob, { strict: false }) // The readAsBinaryString(blob) method, when invoked, // must initiate a read operation for blob with BinaryString. readOperation(this, blob, 'BinaryString') }
@see https://w3c.github.io/FileAPI/#dom-filereader-readystate
readAsBinaryString
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
readAsText (blob, encoding = undefined) { webidl.brandCheck(this, FileReader) webidl.argumentLengthCheck(arguments, 1, { header: 'FileReader.readAsText' }) blob = webidl.converters.Blob(blob, { strict: false }) if (encoding !== undefined) { encoding = webidl.converters.DOMString(encoding) } // The readAsText(blob, encoding) method, when invoked, // must initiate a read operation for blob with Text and encoding. readOperation(this, blob, 'Text', encoding) }
@see https://w3c.github.io/FileAPI/#dom-filereader-error
readAsText
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
readAsDataURL (blob) { webidl.brandCheck(this, FileReader) webidl.argumentLengthCheck(arguments, 1, { header: 'FileReader.readAsDataURL' }) blob = webidl.converters.Blob(blob, { strict: false }) // The readAsDataURL(blob) method, when invoked, must // initiate a read operation for blob with DataURL. readOperation(this, blob, 'DataURL') }
@see https://w3c.github.io/FileAPI/#dom-filereader-error
readAsDataURL
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
abort () { // 1. If this's state is "empty" or if this's state is // "done" set this's result to null and terminate // this algorithm. if (this[kState] === 'empty' || this[kState] === 'done') { this[kResult] = null return } // 2. If this's state is "loading" set this's state to // "done" and set this's result to null. if (this[kState] === 'loading') { this[kState] = 'done' this[kResult] = null } // 3. If there are any tasks from this on the file reading // task source in an affiliated task queue, then remove // those tasks from that task queue. this[kAborted] = true // 4. Terminate the algorithm for the read method being processed. // TODO // 5. Fire a progress event called abort at this. fireAProgressEvent('abort', this) // 6. If this's state is not "loading", fire a progress // event called loadend at this. if (this[kState] !== 'loading') { fireAProgressEvent('loadend', this) } }
@see https://w3c.github.io/FileAPI/#dom-filereader-error
abort
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get readyState () { webidl.brandCheck(this, FileReader) switch (this[kState]) { case 'empty': return this.EMPTY case 'loading': return this.LOADING case 'done': return this.DONE } }
@see https://w3c.github.io/FileAPI/#dom-filereader-error
readyState
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get onloadend () { webidl.brandCheck(this, FileReader) return this[kEvents].loadend }
@see https://w3c.github.io/FileAPI/#dom-filereader-error
onloadend
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
set onloadend (fn) { webidl.brandCheck(this, FileReader) if (this[kEvents].loadend) { this.removeEventListener('loadend', this[kEvents].loadend) } if (typeof fn === 'function') { this[kEvents].loadend = fn this.addEventListener('loadend', fn) } else { this[kEvents].loadend = null } }
@see https://w3c.github.io/FileAPI/#dom-filereader-error
onloadend
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get onerror () { webidl.brandCheck(this, FileReader) return this[kEvents].error }
@see https://w3c.github.io/FileAPI/#dom-filereader-error
onerror
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
set onerror (fn) { webidl.brandCheck(this, FileReader) if (this[kEvents].error) { this.removeEventListener('error', this[kEvents].error) } if (typeof fn === 'function') { this[kEvents].error = fn this.addEventListener('error', fn) } else { this[kEvents].error = null } }
@see https://w3c.github.io/FileAPI/#dom-filereader-error
onerror
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get onloadstart () { webidl.brandCheck(this, FileReader) return this[kEvents].loadstart }
@see https://w3c.github.io/FileAPI/#dom-filereader-error
onloadstart
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
set onloadstart (fn) { webidl.brandCheck(this, FileReader) if (this[kEvents].loadstart) { this.removeEventListener('loadstart', this[kEvents].loadstart) } if (typeof fn === 'function') { this[kEvents].loadstart = fn this.addEventListener('loadstart', fn) } else { this[kEvents].loadstart = null } }
@see https://w3c.github.io/FileAPI/#dom-filereader-error
onloadstart
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
set onprogress (fn) { webidl.brandCheck(this, FileReader) if (this[kEvents].progress) { this.removeEventListener('progress', this[kEvents].progress) } if (typeof fn === 'function') { this[kEvents].progress = fn this.addEventListener('progress', fn) } else { this[kEvents].progress = null } }
@see https://xhr.spec.whatwg.org/#progressevent
onprogress
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get onload () { webidl.brandCheck(this, FileReader) return this[kEvents].load }
@see https://xhr.spec.whatwg.org/#progressevent
onload
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
set onload (fn) { webidl.brandCheck(this, FileReader) if (this[kEvents].load) { this.removeEventListener('load', this[kEvents].load) } if (typeof fn === 'function') { this[kEvents].load = fn this.addEventListener('load', fn) } else { this[kEvents].load = null } }
@see https://xhr.spec.whatwg.org/#progressevent
onload
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get onabort () { webidl.brandCheck(this, FileReader) return this[kEvents].abort }
@see https://xhr.spec.whatwg.org/#progressevent
onabort
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
set onabort (fn) { webidl.brandCheck(this, FileReader) if (this[kEvents].abort) { this.removeEventListener('abort', this[kEvents].abort) } if (typeof fn === 'function') { this[kEvents].abort = fn this.addEventListener('abort', fn) } else { this[kEvents].abort = null } }
@see https://xhr.spec.whatwg.org/#progressevent
onabort
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (type, eventInitDict = {}) { type = webidl.converters.DOMString(type) eventInitDict = webidl.converters.ProgressEventInit(eventInitDict ?? {}) super(type, eventInitDict) this[kState] = { lengthComputable: eventInitDict.lengthComputable, loaded: eventInitDict.loaded, total: eventInitDict.total } }
@see https://w3c.github.io/FileAPI/#readOperation @param {import('./filereader').FileReader} fr @param {import('buffer').Blob} blob @param {string} type @param {string?} encodingName
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get lengthComputable () { webidl.brandCheck(this, ProgressEvent) return this[kState].lengthComputable }
@see https://w3c.github.io/FileAPI/#readOperation @param {import('./filereader').FileReader} fr @param {import('buffer').Blob} blob @param {string} type @param {string?} encodingName
lengthComputable
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function fireAProgressEvent (e, reader) { // The progress event e does not bubble. e.bubbles must be false // The progress event e is NOT cancelable. e.cancelable must be false const event = new ProgressEvent(e, { bubbles: false, cancelable: false }) reader.dispatchEvent(event) }
@see https://w3c.github.io/FileAPI/#blob-package-data @param {Uint8Array[]} bytes @param {string} type @param {string?} mimeType @param {string?} encodingName
fireAProgressEvent
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (origin, opts) { super(origin, opts) if (!opts || !opts.agent || typeof opts.agent.dispatch !== 'function') { throw new InvalidArgumentError('Argument opts.agent must implement Agent') } this[kMockAgent] = opts.agent this[kOrigin] = origin this[kDispatches] = [] this[kConnected] = 1 this[kOriginalDispatch] = this.dispatch this[kOriginalClose] = this.close.bind(this) this.dispatch = buildMockDispatch.call(this) this.close = this[kClose] }
Allow one to define a reply for a set amount of matching requests.
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
persist () { this[kMockDispatch].persist = true return this }
Mock an undici request with a defined reply.
persist
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
times (repeatTimes) { if (typeof repeatTimes !== 'number' || !Number.isInteger(repeatTimes) || repeatTimes <= 0) { throw new InvalidArgumentError('repeatTimes must be a valid integer > 0') } this[kMockDispatch].times = repeatTimes return this }
Mock an undici request with a defined reply.
times
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (opts, mockDispatches) { if (typeof opts !== 'object') { throw new InvalidArgumentError('opts must be an object') } if (typeof opts.path === 'undefined') { throw new InvalidArgumentError('opts.path must be defined') } if (typeof opts.method === 'undefined') { opts.method = 'GET' } // See https://github.com/nodejs/undici/issues/1245 // As per RFC 3986, clients are not supposed to send URI // fragments to servers when they retrieve a document, if (typeof opts.path === 'string') { if (opts.query) { opts.path = buildURL(opts.path, opts.query) } else { // Matches https://github.com/nodejs/undici/blob/main/lib/fetch/index.js#L1811 const parsedURL = new URL(opts.path, 'data://') opts.path = parsedURL.pathname + parsedURL.search } } if (typeof opts.method === 'string') { opts.method = opts.method.toUpperCase() } this[kDispatchKey] = buildKey(opts) this[kDispatches] = mockDispatches this[kDefaultHeaders] = {} this[kDefaultTrailers] = {} this[kContentLength] = false }
Mock an undici request with a defined reply.
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
createMockScopeDispatchData (statusCode, data, responseOptions = {}) { const responseData = getResponseData(data) const contentLength = this[kContentLength] ? { 'content-length': responseData.length } : {} const headers = { ...this[kDefaultHeaders], ...contentLength, ...responseOptions.headers } const trailers = { ...this[kDefaultTrailers], ...responseOptions.trailers } return { statusCode, data, headers, trailers } }
Mock an undici request with a defined reply.
createMockScopeDispatchData
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
validateReplyParameters (statusCode, data, responseOptions) { if (typeof statusCode === 'undefined') { throw new InvalidArgumentError('statusCode must be defined') } if (typeof data === 'undefined') { throw new InvalidArgumentError('data must be defined') } if (typeof responseOptions !== 'object') { throw new InvalidArgumentError('responseOptions must be an object') } }
Mock an undici request with a defined error.
validateReplyParameters
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
reply (replyData) { // Values of reply aren't available right now as they // can only be available when the reply callback is invoked. if (typeof replyData === 'function') { // We'll first wrap the provided callback in another function, // this function will properly resolve the data from the callback // when invoked. const wrappedDefaultsCallback = (opts) => { // Our reply options callback contains the parameter for statusCode, data and options. const resolvedData = replyData(opts) // Check if it is in the right format if (typeof resolvedData !== 'object') { throw new InvalidArgumentError('reply options callback must return an object') } const { statusCode, data = '', responseOptions = {} } = resolvedData this.validateReplyParameters(statusCode, data, responseOptions) // Since the values can be obtained immediately we return them // from this higher order function that will be resolved later. return { ...this.createMockScopeDispatchData(statusCode, data, responseOptions) } } // Add usual dispatch data, but this time set the data parameter to function that will eventually provide data. const newMockDispatch = addMockDispatch(this[kDispatches], this[kDispatchKey], wrappedDefaultsCallback) return new MockScope(newMockDispatch) } // We can have either one or three parameters, if we get here, // we should have 1-3 parameters. So we spread the arguments of // this function to obtain the parameters, since replyData will always // just be the statusCode. const [statusCode, data = '', responseOptions = {}] = [...arguments] this.validateReplyParameters(statusCode, data, responseOptions) // Send in-already provided data like usual const dispatchData = this.createMockScopeDispatchData(statusCode, data, responseOptions) const newMockDispatch = addMockDispatch(this[kDispatches], this[kDispatchKey], dispatchData) return new MockScope(newMockDispatch) }
Set default reply trailers on the interceptor for subsequent replies
reply
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
wrappedDefaultsCallback = (opts) => { // Our reply options callback contains the parameter for statusCode, data and options. const resolvedData = replyData(opts) // Check if it is in the right format if (typeof resolvedData !== 'object') { throw new InvalidArgumentError('reply options callback must return an object') } const { statusCode, data = '', responseOptions = {} } = resolvedData this.validateReplyParameters(statusCode, data, responseOptions) // Since the values can be obtained immediately we return them // from this higher order function that will be resolved later. return { ...this.createMockScopeDispatchData(statusCode, data, responseOptions) } }
Set reply content length header for replies on the interceptor
wrappedDefaultsCallback
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
wrappedDefaultsCallback = (opts) => { // Our reply options callback contains the parameter for statusCode, data and options. const resolvedData = replyData(opts) // Check if it is in the right format if (typeof resolvedData !== 'object') { throw new InvalidArgumentError('reply options callback must return an object') } const { statusCode, data = '', responseOptions = {} } = resolvedData this.validateReplyParameters(statusCode, data, responseOptions) // Since the values can be obtained immediately we return them // from this higher order function that will be resolved later. return { ...this.createMockScopeDispatchData(statusCode, data, responseOptions) } }
Set reply content length header for replies on the interceptor
wrappedDefaultsCallback
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (origin, opts) { super(origin, opts) if (!opts || !opts.agent || typeof opts.agent.dispatch !== 'function') { throw new InvalidArgumentError('Argument opts.agent must implement Agent') } this[kMockAgent] = opts.agent this[kOrigin] = origin this[kDispatches] = [] this[kConnected] = 1 this[kOriginalDispatch] = this.dispatch this[kOriginalClose] = this.close.bind(this) this.dispatch = buildMockDispatch.call(this) this.close = this[kClose] }
@param {import('../../index').Headers|string[]|Record<string, string>} headers @param {string} key
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function addMockDispatch (mockDispatches, key, data) { const baseData = { timesInvoked: 0, times: 1, persist: false, consumed: false } const replyData = typeof data === 'function' ? { callback: data } : { ...data } const newMockDispatch = { ...baseData, ...key, pending: true, data: { error: null, ...replyData } } mockDispatches.push(newMockDispatch) return newMockDispatch }
Mock dispatch function used to simulate undici dispatches
addMockDispatch
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function deleteMockDispatch (mockDispatches, key) { const index = mockDispatches.findIndex(dispatch => { if (!dispatch.consumed) { return false } return matchKey(dispatch, key) }) if (index !== -1) { mockDispatches.splice(index, 1) } }
Mock dispatch function used to simulate undici dispatches
deleteMockDispatch
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function buildKey (opts) { const { path, method, body, headers, query } = opts return { path, method, body, headers, query } }
Mock dispatch function used to simulate undici dispatches
buildKey
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function generateKeyValues (data) { return Object.entries(data).reduce((keyValuePairs, [key, value]) => [ ...keyValuePairs, Buffer.from(`${key}`), Array.isArray(value) ? value.map(x => Buffer.from(`${x}`)) : Buffer.from(`${value}`) ], []) }
Mock dispatch function used to simulate undici dispatches
generateKeyValues
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function getStatusText (statusCode) { return STATUS_CODES[statusCode] || 'unknown' }
Mock dispatch function used to simulate undici dispatches
getStatusText
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async function getResponse (body) { const buffers = [] for await (const data of body) { buffers.push(data) } return Buffer.concat(buffers).toString('utf8') }
Mock dispatch function used to simulate undici dispatches
getResponse
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function mockDispatch (opts, handler) { // Get mock dispatch from built key const key = buildKey(opts) const mockDispatch = getMockDispatch(this[kDispatches], key) mockDispatch.timesInvoked++ // Here's where we resolve a callback if a callback is present for the dispatch data. if (mockDispatch.data.callback) { mockDispatch.data = { ...mockDispatch.data, ...mockDispatch.data.callback(opts) } } // Parse mockDispatch data const { data: { statusCode, data, headers, trailers, error }, delay, persist } = mockDispatch const { timesInvoked, times } = mockDispatch // If it's used up and not persistent, mark as consumed mockDispatch.consumed = !persist && timesInvoked >= times mockDispatch.pending = timesInvoked < times // If specified, trigger dispatch error if (error !== null) { deleteMockDispatch(this[kDispatches], key) handler.onError(error) return true } // Handle the request with a delay if necessary if (typeof delay === 'number' && delay > 0) { setTimeout(() => { handleReply(this[kDispatches]) }, delay) } else { handleReply(this[kDispatches]) } function handleReply (mockDispatches, _data = data) { // fetch's HeadersList is a 1D string array const optsHeaders = Array.isArray(opts.headers) ? buildHeadersFromArray(opts.headers) : opts.headers const body = typeof _data === 'function' ? _data({ ...opts, headers: optsHeaders }) : _data // util.types.isPromise is likely needed for jest. if (isPromise(body)) { // If handleReply is asynchronous, throwing an error // in the callback will reject the promise, rather than // synchronously throw the error, which breaks some tests. // Rather, we wait for the callback to resolve if it is a // promise, and then re-run handleReply with the new body. body.then((newData) => handleReply(mockDispatches, newData)) return } const responseData = getResponseData(body) const responseHeaders = generateKeyValues(headers) const responseTrailers = generateKeyValues(trailers) handler.abort = nop handler.onHeaders(statusCode, responseHeaders, resume, getStatusText(statusCode)) handler.onData(Buffer.from(responseData)) handler.onComplete(responseTrailers) deleteMockDispatch(mockDispatches, key) } function resume () {} return true }
Mock dispatch function used to simulate undici dispatches
mockDispatch
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function handleReply (mockDispatches, _data = data) { // fetch's HeadersList is a 1D string array const optsHeaders = Array.isArray(opts.headers) ? buildHeadersFromArray(opts.headers) : opts.headers const body = typeof _data === 'function' ? _data({ ...opts, headers: optsHeaders }) : _data // util.types.isPromise is likely needed for jest. if (isPromise(body)) { // If handleReply is asynchronous, throwing an error // in the callback will reject the promise, rather than // synchronously throw the error, which breaks some tests. // Rather, we wait for the callback to resolve if it is a // promise, and then re-run handleReply with the new body. body.then((newData) => handleReply(mockDispatches, newData)) return } const responseData = getResponseData(body) const responseHeaders = generateKeyValues(headers) const responseTrailers = generateKeyValues(trailers) handler.abort = nop handler.onHeaders(statusCode, responseHeaders, resume, getStatusText(statusCode)) handler.onData(Buffer.from(responseData)) handler.onComplete(responseTrailers) deleteMockDispatch(mockDispatches, key) }
Mock dispatch function used to simulate undici dispatches
handleReply
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function refreshTimeout () { if (fastNowTimeout && fastNowTimeout.refresh) { fastNowTimeout.refresh() } else { clearTimeout(fastNowTimeout) fastNowTimeout = setTimeout(onTimeout, 1e3) if (fastNowTimeout.unref) { fastNowTimeout.unref() } } }
@see https://websockets.spec.whatwg.org/#concept-websocket-establish @param {URL} url @param {string|string[]} protocols @param {import('./websocket').WebSocket} ws @param {(response: any) => void} onEstablish @param {Partial<import('../../types/websocket').WebSocketInit>} options
refreshTimeout
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (callback, delay, opaque) { this.callback = callback this.delay = delay this.opaque = opaque // -2 not in timer list // -1 in timer list but inactive // 0 in timer list waiting for time // > 0 in timer list waiting for time to expire this.state = -2 this.refresh() }
@see https://websockets.spec.whatwg.org/#concept-websocket-establish @param {URL} url @param {string|string[]} protocols @param {import('./websocket').WebSocket} ws @param {(response: any) => void} onEstablish @param {Partial<import('../../types/websocket').WebSocketInit>} options
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
refresh () { if (this.state === -2) { fastTimers.push(this) if (!fastNowTimeout || fastTimers.length === 1) { refreshTimeout() } } this.state = 0 }
@see https://websockets.spec.whatwg.org/#concept-websocket-establish @param {URL} url @param {string|string[]} protocols @param {import('./websocket').WebSocket} ws @param {(response: any) => void} onEstablish @param {Partial<import('../../types/websocket').WebSocketInit>} options
refresh
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
clear () { this.state = -1 }
@see https://websockets.spec.whatwg.org/#concept-websocket-establish @param {URL} url @param {string|string[]} protocols @param {import('./websocket').WebSocket} ws @param {(response: any) => void} onEstablish @param {Partial<import('../../types/websocket').WebSocketInit>} options
clear
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
setTimeout (callback, delay, opaque) { return delay < 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque) }
@see https://websockets.spec.whatwg.org/#concept-websocket-establish @param {URL} url @param {string|string[]} protocols @param {import('./websocket').WebSocket} ws @param {(response: any) => void} onEstablish @param {Partial<import('../../types/websocket').WebSocketInit>} options
setTimeout
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
clearTimeout (timeout) { if (timeout instanceof Timeout) { timeout.clear() } else { clearTimeout(timeout) } }
@see https://websockets.spec.whatwg.org/#concept-websocket-establish @param {URL} url @param {string|string[]} protocols @param {import('./websocket').WebSocket} ws @param {(response: any) => void} onEstablish @param {Partial<import('../../types/websocket').WebSocketInit>} options
clearTimeout
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function onSocketError (error) { const { ws } = this ws[kReadyState] = states.CLOSING if (channels.socketError.hasSubscribers) { channels.socketError.publish(error) } this.destroy() }
@see https://html.spec.whatwg.org/multipage/comms.html#messageevent
onSocketError
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (type, eventInitDict = {}) { webidl.argumentLengthCheck(arguments, 1, { header: 'MessageEvent constructor' }) type = webidl.converters.DOMString(type) eventInitDict = webidl.converters.MessageEventInit(eventInitDict) super(type, eventInitDict) this.#eventInit = eventInitDict }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get data () { webidl.brandCheck(this, MessageEvent) return this.#eventInit.data }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
data
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get origin () { webidl.brandCheck(this, MessageEvent) return this.#eventInit.origin }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
origin
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get lastEventId () { webidl.brandCheck(this, MessageEvent) return this.#eventInit.lastEventId }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
lastEventId
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get source () { webidl.brandCheck(this, MessageEvent) return this.#eventInit.source }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
source
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get ports () { webidl.brandCheck(this, MessageEvent) if (!Object.isFrozen(this.#eventInit.ports)) { Object.freeze(this.#eventInit.ports) } return this.#eventInit.ports }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
ports
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
initMessageEvent ( type, bubbles = false, cancelable = false, data = null, origin = '', lastEventId = '', source = null, ports = [] ) { webidl.brandCheck(this, MessageEvent) webidl.argumentLengthCheck(arguments, 1, { header: 'MessageEvent.initMessageEvent' }) return new MessageEvent(type, { bubbles, cancelable, data, origin, lastEventId, source, ports }) }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
initMessageEvent
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (type, eventInitDict = {}) { webidl.argumentLengthCheck(arguments, 1, { header: 'CloseEvent constructor' }) type = webidl.converters.DOMString(type) eventInitDict = webidl.converters.CloseEventInit(eventInitDict) super(type, eventInitDict) this.#eventInit = eventInitDict }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get wasClean () { webidl.brandCheck(this, CloseEvent) return this.#eventInit.wasClean }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
wasClean
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get code () { webidl.brandCheck(this, CloseEvent) return this.#eventInit.code }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
code
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get reason () { webidl.brandCheck(this, CloseEvent) return this.#eventInit.reason }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
reason
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (type, eventInitDict) { webidl.argumentLengthCheck(arguments, 1, { header: 'ErrorEvent constructor' }) super(type, eventInitDict) type = webidl.converters.DOMString(type) eventInitDict = webidl.converters.ErrorEventInit(eventInitDict ?? {}) this.#eventInit = eventInitDict }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get message () { webidl.brandCheck(this, ErrorEvent) return this.#eventInit.message }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
message
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get filename () { webidl.brandCheck(this, ErrorEvent) return this.#eventInit.filename }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
filename
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get lineno () { webidl.brandCheck(this, ErrorEvent) return this.#eventInit.lineno }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
lineno
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get colno () { webidl.brandCheck(this, ErrorEvent) return this.#eventInit.colno }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
colno
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get error () { webidl.brandCheck(this, ErrorEvent) return this.#eventInit.error }
@see https://websockets.spec.whatwg.org/#the-closeevent-interface
error
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (data) { this.frameData = data this.maskKey = crypto.randomBytes(4) }
@param {Buffer} chunk @param {() => void} callback
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
createFrame (opcode) { const bodyLength = this.frameData?.byteLength ?? 0 /** @type {number} */ let payloadLength = bodyLength // 0-125 let offset = 6 if (bodyLength > maxUnsigned16Bit) { offset += 8 // payload length is next 8 bytes payloadLength = 127 } else if (bodyLength > 125) { offset += 2 // payload length is next 2 bytes payloadLength = 126 } const buffer = Buffer.allocUnsafe(bodyLength + offset) // Clear first 2 bytes, everything else is overwritten buffer[0] = buffer[1] = 0 buffer[0] |= 0x80 // FIN buffer[0] = (buffer[0] & 0xF0) + opcode // opcode /*! ws. MIT License. Einar Otto Stangvik <[email protected]> */ buffer[offset - 4] = this.maskKey[0] buffer[offset - 3] = this.maskKey[1] buffer[offset - 2] = this.maskKey[2] buffer[offset - 1] = this.maskKey[3] buffer[1] = payloadLength if (payloadLength === 126) { buffer.writeUInt16BE(bodyLength, 2) } else if (payloadLength === 127) { // Clear extended payload length buffer[2] = buffer[3] = 0 buffer.writeUIntBE(bodyLength, 4, 6) } buffer[1] |= 0x80 // MASK // mask body for (let i = 0; i < bodyLength; i++) { buffer[offset + i] = this.frameData[i] ^ this.maskKey[i % 4] } return buffer }
@param {Buffer} chunk @param {() => void} callback
createFrame
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (ws) { super() this.ws = ws }
Runs whenever a new chunk is received. Callback is called whenever there are no more chunks buffering, or not enough bytes are buffered to parse.
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_write (chunk, _, callback) { this.#buffers.push(chunk) this.#byteOffset += chunk.length this.run(callback) }
Runs whenever a new chunk is received. Callback is called whenever there are no more chunks buffering, or not enough bytes are buffered to parse.
_write
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT