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
async function next_bundle_app_prod_turbo(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ turbo: true, bundleType: 'app', }), name: 'next-bundle-app-prod-turbo', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_app_prod_turbo
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_app_prod(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ dev: false, bundleType: 'app', }), name: 'next-bundle-app-prod', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_app_prod
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_app_dev_turbo(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ turbo: true, dev: true, bundleType: 'app', }), name: 'next-bundle-app-dev-turbo', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_app_dev_turbo
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_app_dev(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ dev: true, bundleType: 'app', }), name: 'next-bundle-app-dev', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_app_dev
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_app_prod_turbo_experimental(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ turbo: true, bundleType: 'app', experimental: true, }), name: 'next-bundle-app-prod-turbo-experimental', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_app_prod_turbo_experimental
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_app_prod_experimental(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ dev: false, bundleType: 'app', experimental: true, }), name: 'next-bundle-app-prod-experimental', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_app_prod_experimental
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_app_dev_turbo_experimental(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ turbo: true, dev: true, bundleType: 'app', experimental: true, }), name: 'next-bundle-app-dev-turbo-experimental', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_app_dev_turbo_experimental
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_app_dev_experimental(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ dev: true, bundleType: 'app', experimental: true, }), name: 'next-bundle-app-dev-experimental', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_app_dev_experimental
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_pages_prod(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ dev: false, bundleType: 'pages', }), name: 'next-bundle-pages-prod', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_pages_prod
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_pages_dev(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ dev: true, bundleType: 'pages', }), name: 'next-bundle-pages-dev', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_pages_dev
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_pages_prod_turbo(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ turbo: true, bundleType: 'pages', }), name: 'next-bundle-pages-prod-turbo', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_pages_prod_turbo
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_pages_dev_turbo(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ turbo: true, dev: true, bundleType: 'pages', }), name: 'next-bundle-pages-dev-turbo', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_pages_dev_turbo
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_server(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-runtime.webpack-config')({ dev: false, bundleType: 'server', }), name: 'next-bundle-server', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_server
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle_devtools(task, opts) { await task.source('dist').webpack({ watch: opts.dev, config: require('./next-devtools.webpack-config')({ dev: opts.dev, }), name: 'next-bundle-devtools-dev', }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle_devtools
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
async function next_bundle(task, opts) { await task.parallel( [ // builds the app (route/page) bundles 'next_bundle_app_prod_turbo', 'next_bundle_app_prod', 'next_bundle_app_dev_turbo', 'next_bundle_app_dev', // builds the app (route/page) bundles with react experimental 'next_bundle_app_prod_turbo_experimental', 'next_bundle_app_prod_experimental', 'next_bundle_app_dev_turbo_experimental', 'next_bundle_app_dev_experimental', // builds the pages (page/api) bundles 'next_bundle_pages_prod', 'next_bundle_pages_dev', 'next_bundle_pages_prod_turbo', 'next_bundle_pages_dev_turbo', // builds the minimal server 'next_bundle_server', // devtools 'next_bundle_devtools', ], opts ) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
next_bundle
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
function writeJson(file, obj, { spaces = 0 } = {}) { return fs.writeFile( file, JSON.stringify(obj, null, spaces) + (spaces === 0 ? '\n' : '') ) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
writeJson
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
function rmrf(path, options) { return fs.rm(path, { recursive: true, force: true, ...options }) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
rmrf
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
function readJson(path) { return fs.readFile(path, 'utf8').then((content) => JSON.parse(content)) }
/*.+(wasm)').target('dist/server') } export async function experimental_testing(task, opts) { await task .source('src/experimental/testing/*
readJson
javascript
vercel/next.js
packages/next/taskfile.js
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
MIT
function pluginCreator() { return { postcssPlugin: 'postcss-plugin-stub', prepare() { return {} }, } }
This file creates a stub postcss plugin It will be pre-compiled into "src/compiled/postcss-plugin-stub-for-cssnano-simple", which "postcss-svgo" will be aliased to when creating "cssnano-preset-simple"
pluginCreator
javascript
vercel/next.js
packages/next/src/bundles/postcss-plugin-stub/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/bundles/postcss-plugin-stub/index.js
MIT
prepare() { return {} }
This file creates a stub postcss plugin It will be pre-compiled into "src/compiled/postcss-plugin-stub-for-cssnano-simple", which "postcss-svgo" will be aliased to when creating "cssnano-preset-simple"
prepare
javascript
vercel/next.js
packages/next/src/bundles/postcss-plugin-stub/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/bundles/postcss-plugin-stub/index.js
MIT
get size() { return this._parsed.size; }
The amount of cookies received from the client
size
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
get(...args) { const name = typeof args[0] === "string" ? args[0] : args[0].name; return this._parsed.get(name); }
The amount of cookies received from the client
get
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
getAll(...args) { var _a; const all = Array.from(this._parsed); if (!args.length) { return all.map(([_, value]) => value); } const name = typeof args[0] === "string" ? args[0] : (_a = args[0]) == null ? void 0 : _a.name; return all.filter(([n]) => n === name).map(([_, value]) => value); }
The amount of cookies received from the client
getAll
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
has(name) { return this._parsed.has(name); }
The amount of cookies received from the client
has
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
set(...args) { const [name, value] = args.length === 1 ? [args[0].name, args[0].value] : args; const map = this._parsed; map.set(name, { name, value }); this._headers.set( "cookie", Array.from(map).map(([_, value2]) => stringifyCookie(value2)).join("; ") ); return this; }
The amount of cookies received from the client
set
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
delete(names) { const map = this._parsed; const result = !Array.isArray(names) ? map.delete(names) : names.map((name) => map.delete(name)); this._headers.set( "cookie", Array.from(map).map(([_, value]) => stringifyCookie(value)).join("; ") ); return result; }
Delete the cookies matching the passed name or names in the request.
delete
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
clear() { this.delete(Array.from(this._parsed.keys())); return this; }
Delete all the cookies in the cookies in the request.
clear
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
toString() { return [...this._parsed.values()].map((v) => `${v.name}=${encodeURIComponent(v.value)}`).join("; "); }
Format the cookies in the request as a string for logging
toString
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
constructor(responseHeaders) { /** @internal */ this._parsed = /* @__PURE__ */ new Map(); var _a, _b, _c; this._headers = responseHeaders; const setCookie = (_c = (_b = (_a = responseHeaders.getSetCookie) == null ? void 0 : _a.call(responseHeaders)) != null ? _b : responseHeaders.get("set-cookie")) != null ? _c : []; const cookieStrings = Array.isArray(setCookie) ? setCookie : splitCookiesString(setCookie); for (const cookieString of cookieStrings) { const parsed = parseSetCookie(cookieString); if (parsed) this._parsed.set(parsed.name, parsed); } }
Format the cookies in the request as a string for logging
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
get(...args) { const key = typeof args[0] === "string" ? args[0] : args[0].name; return this._parsed.get(key); }
{@link https://wicg.github.io/cookie-store/#CookieStore-get CookieStore#get} without the Promise.
get
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
getAll(...args) { var _a; const all = Array.from(this._parsed.values()); if (!args.length) { return all; } const key = typeof args[0] === "string" ? args[0] : (_a = args[0]) == null ? void 0 : _a.name; return all.filter((c) => c.name === key); }
{@link https://wicg.github.io/cookie-store/#CookieStore-getAll CookieStore#getAll} without the Promise.
getAll
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
has(name) { return this._parsed.has(name); }
{@link https://wicg.github.io/cookie-store/#CookieStore-getAll CookieStore#getAll} without the Promise.
has
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
set(...args) { const [name, value, cookie] = args.length === 1 ? [args[0].name, args[0].value, args[0]] : args; const map = this._parsed; map.set(name, normalizeCookie({ name, value, ...cookie })); replace(map, this._headers); return this; }
{@link https://wicg.github.io/cookie-store/#CookieStore-set CookieStore#set} without the Promise.
set
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
delete(...args) { const [name, options] = typeof args[0] === "string" ? [args[0]] : [args[0].name, args[0]]; return this.set({ ...options, name, value: "", expires: /* @__PURE__ */ new Date(0) }); }
{@link https://wicg.github.io/cookie-store/#CookieStore-delete CookieStore#delete} without the Promise.
delete
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
toString() { return [...this._parsed.values()].map(stringifyCookie).join("; "); }
{@link https://wicg.github.io/cookie-store/#CookieStore-delete CookieStore#delete} without the Promise.
toString
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
function replace(bag, headers) { headers.delete("set-cookie"); for (const [, value] of bag) { const serialized = stringifyCookie(value); headers.append("set-cookie", serialized); } }
{@link https://wicg.github.io/cookie-store/#CookieStore-delete CookieStore#delete} without the Promise.
replace
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
function normalizeCookie(cookie = { name: "", value: "" }) { if (typeof cookie.expires === "number") { cookie.expires = new Date(cookie.expires); } if (cookie.maxAge) { cookie.expires = new Date(Date.now() + cookie.maxAge * 1e3); } if (cookie.path === null || cookie.path === void 0) { cookie.path = "/"; } return cookie; }
{@link https://wicg.github.io/cookie-store/#CookieStore-delete CookieStore#delete} without the Promise.
normalizeCookie
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/cookies/index.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/cookies/index.js
MIT
constructor(key, value, index) { if (index === void 0 || index >= key.length) { throw new TypeError("Unreachable"); } const code = this.code = key.charCodeAt(index); if (code > 127) { throw new TypeError("key must be ascii string"); } if (key.length !== ++index) { this.middle = new _TstNode(key, value, index); } else { this.value = value; } }
@param {string} key @param {any} value @param {number} index
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
add(key, value) { const length = key.length; if (length === 0) { throw new TypeError("Unreachable"); } let index = 0; let node = this; while (true) { const code = key.charCodeAt(index); if (code > 127) { throw new TypeError("key must be ascii string"); } if (node.code === code) { if (length === ++index) { node.value = value; break; } else if (node.middle !== null) { node = node.middle; } else { node.middle = new _TstNode(key, value, index); break; } } else if (node.code < code) { if (node.left !== null) { node = node.left; } else { node.left = new _TstNode(key, value, index); break; } } else if (node.right !== null) { node = node.right; } else { node.right = new _TstNode(key, value, index); break; } } }
@param {string} key @param {any} value
add
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
insert(key, value) { if (this.node === null) { this.node = new TstNode(key, value, 0); } else { this.node.add(key, value); } }
@param {string} key @param {any} value
insert
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor(callback, delay, arg) { this._onTimeout = callback; this._idleTimeout = delay; this._timerArg = arg; this.refresh(); }
@constructor @param {Function} callback A function to be executed after the timer expires. @param {number} delay The time, in milliseconds that the timer should wait before the specified function or code is executed. @param {*} arg
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
refresh() { if (this._state === NOT_IN_LIST) { fastTimers.push(this); } if (!fastNowTimeout || fastTimers.length === 1) { refreshTimeout(); } this._state = PENDING; }
Sets the timer's start time to the current time, and reschedules the timer to call its callback at the previously specified duration adjusted to the current time. Using this on a timer that has already called its callback will reactivate the timer. @returns {void}
refresh
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
clear() { this._state = TO_BE_CLEARED; this._idleStart = -1; }
The `clear` method cancels the timer, preventing it from executing. @returns {void} @private
clear
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
setTimeout(callback, delay, arg) { return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); }
The setTimeout() method sets a timer which executes a function once the timer expires. @param {Function} callback A function to be executed after the timer expires. @param {number} delay The time, in milliseconds that the timer should wait before the specified function or code is executed. @param {*} [arg] An optional argument to be passed to the callback function when the timer expires. @returns {NodeJS.Timeout|FastTimer}
setTimeout
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
clearTimeout(timeout) { if (timeout[kFastTimer]) { timeout.clear(); } else { clearTimeout(timeout); } }
The clearTimeout method cancels an instantiated Timer previously created by calling setTimeout. @param {NodeJS.Timeout|FastTimer} timeout
clearTimeout
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
setFastTimeout(callback, delay, arg) { return new FastTimer(callback, delay, arg); }
The setFastTimeout() method sets a fastTimer which executes a function once the timer expires. @param {Function} callback A function to be executed after the timer expires. @param {number} delay The time, in milliseconds that the timer should wait before the specified function or code is executed. @param {*} [arg] An optional argument to be passed to the callback function when the timer expires. @returns {FastTimer}
setFastTimeout
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
now() { return fastNow; }
The now method returns the value of the internal fast timer clock. @returns {number}
now
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
tick(delay = 0) { fastNow += delay - RESOLUTION_MS + 1; onTick(); onTick(); }
Trigger the onTick function to process the fastTimers array. Exported for testing purposes only. Marking as deprecated to discourage any use outside of testing. @deprecated @param {number} [delay=0] The delay in milliseconds to add to the now value.
tick
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
reset() { fastNow = 0; fastTimers.length = 0; clearTimeout(fastNowTimeout); fastNowTimeout = null; }
Reset FastTimers. Exported for testing purposes only. Marking as deprecated to discourage any use outside of testing. @deprecated
reset
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor(maxCachedSessions) { this._maxCachedSessions = maxCachedSessions; this._sessionCache = /* @__PURE__ */ new Map(); this._sessionRegistry = new global.FinalizationRegistry((key) => { if (this._sessionCache.size < this._maxCachedSessions) { return; } const ref = this._sessionCache.get(key); if (ref !== void 0 && ref.deref() === void 0) { this._sessionCache.delete(key); } }); }
Exporting for testing purposes only. Marking as deprecated to discourage any use outside of testing. @deprecated
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
get(sessionKey) { const ref = this._sessionCache.get(sessionKey); return ref ? ref.deref() : null; }
Exporting for testing purposes only. Marking as deprecated to discourage any use outside of testing. @deprecated
get
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
set(sessionKey, session) { if (this._maxCachedSessions === 0) { return; } this._sessionCache.set(sessionKey, new WeakRef(session)); this._sessionRegistry.register(session, sessionKey); }
Exporting for testing purposes only. Marking as deprecated to discourage any use outside of testing. @deprecated
set
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor(maxCachedSessions) { this._maxCachedSessions = maxCachedSessions; this._sessionCache = /* @__PURE__ */ new Map(); }
Exporting for testing purposes only. Marking as deprecated to discourage any use outside of testing. @deprecated
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
get(sessionKey) { return this._sessionCache.get(sessionKey); }
Exporting for testing purposes only. Marking as deprecated to discourage any use outside of testing. @deprecated
get
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
set(sessionKey, session) { if (this._maxCachedSessions === 0) { return; } if (this._sessionCache.size >= this._maxCachedSessions) { const { value: oldestKey } = this._sessionCache.keys().next(); this._sessionCache.delete(oldestKey); } this._sessionCache.set(sessionKey, session); }
Exporting for testing purposes only. Marking as deprecated to discourage any use outside of testing. @deprecated
set
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function buildConnector({ allowH2, maxCachedSessions, socketPath, timeout, session: customSession, ...opts }) { if (maxCachedSessions != null && (!Number.isInteger(maxCachedSessions) || maxCachedSessions < 0)) { throw new InvalidArgumentError("maxCachedSessions must be a positive integer or zero"); } const options = { path: socketPath, ...opts }; const sessionCache = new SessionCache(maxCachedSessions == null ? 100 : maxCachedSessions); timeout = timeout == null ? 1e4 : timeout; allowH2 = allowH2 != null ? allowH2 : false; return /* @__PURE__ */ __name(function connect({ hostname, host, protocol, port, servername, localAddress, httpSocket }, callback) { let socket; if (protocol === "https:") { if (!tls) { tls = require("tls"); } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; assert(sessionKey); const session = customSession || sessionCache.get(sessionKey) || null; port = port || 443; socket = tls.connect({ highWaterMark: 16384, // TLS in node can't have bigger HWM anyway... ...options, servername, session, localAddress, // TODO(HTTP/2): Add support for h2c ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, // upgrade socket connection port, host: hostname }); socket.on("session", function(session2) { sessionCache.set(sessionKey, session2); }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, // Same as nodejs fs streams. ...options, localAddress, port, host: hostname }); } if (options.keepAlive == null || options.keepAlive) { const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(err); } }); return socket; }, "connect"); }
Exporting for testing purposes only. Marking as deprecated to discourage any use outside of testing. @deprecated
buildConnector
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function onConnectTimeout(socket, opts) { if (socket == null) { return; } let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; } else { message += ` (attempted address: ${opts.hostname}:${opts.port},`; } message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); }
Exporting for testing purposes only. Marking as deprecated to discourage any use outside of testing. @deprecated
onConnectTimeout
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function enumToMap(obj) { const res = {}; Object.keys(obj).forEach((key) => { const value = obj[key]; if (typeof value === "number") { res[key] = value; } }); return res; }
Exporting for testing purposes only. Marking as deprecated to discourage any use outside of testing. @deprecated
enumToMap
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor(target, kind) { /** @type {any} */ __privateAdd(this, _target, void 0); /** @type {'key' | 'value' | 'key+value'} */ __privateAdd(this, _kind, void 0); /** @type {number} */ __privateAdd(this, _index, void 0); __privateSet(this, _target, target); __privateSet(this, _kind, kind); __privateSet(this, _index, 0); }
@see https://webidl.spec.whatwg.org/#dfn-default-iterator-object @param {unknown} target @param {'key' | 'value' | 'key+value'} kind
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor(url, { interceptors, maxHeaderSize, headersTimeout, socketTimeout, requestTimeout, connectTimeout, bodyTimeout, idleTimeout, keepAlive, keepAliveTimeout, maxKeepAliveTimeout, keepAliveMaxTimeout, keepAliveTimeoutThreshold, socketPath, pipelining, tls, strictContentLength, maxCachedSessions, maxRedirections, connect: connect2, maxRequestsPerClient, localAddress, maxResponseSize, autoSelectFamily, autoSelectFamilyAttemptTimeout, // h2 maxConcurrentStreams, allowH2 } = {}) { super(); if (keepAlive !== void 0) { throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead"); } if (socketTimeout !== void 0) { throw new InvalidArgumentError("unsupported socketTimeout, use headersTimeout & bodyTimeout instead"); } if (requestTimeout !== void 0) { throw new InvalidArgumentError("unsupported requestTimeout, use headersTimeout & bodyTimeout instead"); } if (idleTimeout !== void 0) { throw new InvalidArgumentError("unsupported idleTimeout, use keepAliveTimeout instead"); } if (maxKeepAliveTimeout !== void 0) { throw new InvalidArgumentError("unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead"); } if (maxHeaderSize != null && !Number.isFinite(maxHeaderSize)) { throw new InvalidArgumentError("invalid maxHeaderSize"); } if (socketPath != null && typeof socketPath !== "string") { throw new InvalidArgumentError("invalid socketPath"); } if (connectTimeout != null && (!Number.isFinite(connectTimeout) || connectTimeout < 0)) { throw new InvalidArgumentError("invalid connectTimeout"); } if (keepAliveTimeout != null && (!Number.isFinite(keepAliveTimeout) || keepAliveTimeout <= 0)) { throw new InvalidArgumentError("invalid keepAliveTimeout"); } if (keepAliveMaxTimeout != null && (!Number.isFinite(keepAliveMaxTimeout) || keepAliveMaxTimeout <= 0)) { throw new InvalidArgumentError("invalid keepAliveMaxTimeout"); } if (keepAliveTimeoutThreshold != null && !Number.isFinite(keepAliveTimeoutThreshold)) { throw new InvalidArgumentError("invalid keepAliveTimeoutThreshold"); } if (headersTimeout != null && (!Number.isInteger(headersTimeout) || headersTimeout < 0)) { throw new InvalidArgumentError("headersTimeout must be a positive integer or zero"); } if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) { throw new InvalidArgumentError("bodyTimeout must be a positive integer or zero"); } if (connect2 != null && typeof connect2 !== "function" && typeof connect2 !== "object") { throw new InvalidArgumentError("connect must be a function or an object"); } if (maxRedirections != null && (!Number.isInteger(maxRedirections) || maxRedirections < 0)) { throw new InvalidArgumentError("maxRedirections must be a positive number"); } if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) { throw new InvalidArgumentError("maxRequestsPerClient must be a positive number"); } if (localAddress != null && (typeof localAddress !== "string" || net.isIP(localAddress) === 0)) { throw new InvalidArgumentError("localAddress must be valid string IP address"); } if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) { throw new InvalidArgumentError("maxResponseSize must be a positive number"); } if (autoSelectFamilyAttemptTimeout != null && (!Number.isInteger(autoSelectFamilyAttemptTimeout) || autoSelectFamilyAttemptTimeout < -1)) { throw new InvalidArgumentError("autoSelectFamilyAttemptTimeout must be a positive number"); } if (allowH2 != null && typeof allowH2 !== "boolean") { throw new InvalidArgumentError("allowH2 must be a valid boolean value"); } if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== "number" || maxConcurrentStreams < 1)) { throw new InvalidArgumentError("maxConcurrentStreams must be a positive integer, greater than 0"); } if (typeof connect2 !== "function") { connect2 = buildConnector({ ...tls, maxCachedSessions, allowH2, socketPath, timeout: connectTimeout, ...autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0, ...connect2 }); } if (interceptors?.Client && Array.isArray(interceptors.Client)) { this[kInterceptors] = interceptors.Client; if (!deprecatedInterceptorWarned) { deprecatedInterceptorWarned = true; define_process_default.emitWarning("Client.Options#interceptor is deprecated. Use Dispatcher#compose instead.", { code: "UNDICI-CLIENT-INTERCEPTOR-DEPRECATED" }); } } else { this[kInterceptors] = [createRedirectInterceptor({ maxRedirections })]; } this[kUrl] = util.parseOrigin(url); this[kConnector] = connect2; this[kPipelining] = pipelining != null ? pipelining : 1; this[kMaxHeadersSize] = maxHeaderSize || http.maxHeaderSize; this[kKeepAliveDefaultTimeout] = keepAliveTimeout == null ? 4e3 : keepAliveTimeout; this[kKeepAliveMaxTimeout] = keepAliveMaxTimeout == null ? 6e5 : keepAliveMaxTimeout; this[kKeepAliveTimeoutThreshold] = keepAliveTimeoutThreshold == null ? 2e3 : keepAliveTimeoutThreshold; this[kKeepAliveTimeoutValue] = this[kKeepAliveDefaultTimeout]; this[kServerName] = null; this[kLocalAddress] = localAddress != null ? localAddress : null; this[kResuming] = 0; this[kNeedDrain] = 0; this[kHostHeader] = `host: ${this[kUrl].hostname}${this[kUrl].port ? `:${this[kUrl].port}` : ""}\r `; this[kBodyTimeout] = bodyTimeout != null ? bodyTimeout : 3e5; this[kHeadersTimeout] = headersTimeout != null ? headersTimeout : 3e5; this[kStrictContentLength] = strictContentLength == null ? true : strictContentLength; this[kMaxRedirections] = maxRedirections; this[kMaxRequests] = maxRequestsPerClient; this[kClosedResolve] = null; this[kMaxResponseSize] = maxResponseSize > -1 ? maxResponseSize : -1; this[kMaxConcurrentStreams] = maxConcurrentStreams != null ? maxConcurrentStreams : 100; this[kHTTPContext] = null; this[kQueue] = []; this[kRunningIdx] = 0; this[kPendingIdx] = 0; this[kResume] = (sync) => resume(this, sync); this[kOnError] = (err) => onError(this, err); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
get pipelining() { return this[kPipelining]; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
pipelining
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
set pipelining(value) { this[kPipelining] = value; this[kResume](true); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
pipelining
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function onError(client, err) { if (client[kRunning] === 0 && err.code !== "UND_ERR_INFO" && err.code !== "UND_ERR_SOCKET") { assert(client[kPendingIdx] === client[kRunningIdx]); const requests = client[kQueue].splice(client[kRunningIdx]); for (let i = 0; i < requests.length; i++) { const request = requests[i]; util.errorRequest(client, request, err); } assert(client[kSize] === 0); } }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
onError
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
async function connect(client) { assert(!client[kConnecting]); assert(!client[kHTTPContext]); let { host, hostname, protocol, port } = client[kUrl]; if (hostname[0] === "[") { const idx = hostname.indexOf("]"); assert(idx !== -1); const ip = hostname.substring(1, idx); assert(net.isIP(ip)); hostname = ip; } client[kConnecting] = true; if (channels.beforeConnect.hasSubscribers) { channels.beforeConnect.publish({ connectParams: { host, hostname, protocol, port, version: client[kHTTPContext]?.version, servername: client[kServerName], localAddress: client[kLocalAddress] }, connector: client[kConnector] }); } try { const socket = await new Promise((resolve, reject) => { client[kConnector]({ host, hostname, protocol, port, servername: client[kServerName], localAddress: client[kLocalAddress] }, (err, socket2) => { if (err) { reject(err); } else { resolve(socket2); } }); }); if (client.destroyed) { util.destroy(socket.on("error", noop), new ClientDestroyedError()); return; } assert(socket); try { client[kHTTPContext] = socket.alpnProtocol === "h2" ? await connectH2(client, socket) : await connectH1(client, socket); } catch (err) { socket.destroy().on("error", noop); throw err; } client[kConnecting] = false; socket[kCounter] = 0; socket[kMaxRequests] = client[kMaxRequests]; socket[kClient] = client; socket[kError] = null; if (channels.connected.hasSubscribers) { channels.connected.publish({ connectParams: { host, hostname, protocol, port, version: client[kHTTPContext]?.version, servername: client[kServerName], localAddress: client[kLocalAddress] }, connector: client[kConnector], socket }); } client.emit("connect", client[kUrl], [client]); } catch (err) { if (client.destroyed) { return; } client[kConnecting] = false; if (channels.connectError.hasSubscribers) { channels.connectError.publish({ connectParams: { host, hostname, protocol, port, version: client[kHTTPContext]?.version, servername: client[kServerName], localAddress: client[kLocalAddress] }, connector: client[kConnector], error: err }); } if (err.code === "ERR_TLS_CERT_ALTNAME_INVALID") { assert(client[kRunning] === 0); while (client[kPending] > 0 && client[kQueue][client[kPendingIdx]].servername === client[kServerName]) { const request = client[kQueue][client[kPendingIdx]++]; util.errorRequest(client, request, err); } } else { onError(client, err); } client.emit("connectionError", client[kUrl], [client], err); } client[kResume](); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
connect
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function emitDrain(client) { client[kNeedDrain] = 0; client.emit("drain", client[kUrl], [client]); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
emitDrain
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function resume(client, sync) { if (client[kResuming] === 2) { return; } client[kResuming] = 2; _resume(client, sync); client[kResuming] = 0; if (client[kRunningIdx] > 256) { client[kQueue].splice(0, client[kRunningIdx]); client[kPendingIdx] -= client[kRunningIdx]; client[kRunningIdx] = 0; } }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
resume
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function _resume(client, sync) { while (true) { if (client.destroyed) { assert(client[kPending] === 0); return; } if (client[kClosedResolve] && !client[kSize]) { client[kClosedResolve](); client[kClosedResolve] = null; return; } if (client[kHTTPContext]) { client[kHTTPContext].resume(); } if (client[kBusy]) { client[kNeedDrain] = 2; } else if (client[kNeedDrain] === 2) { if (sync) { client[kNeedDrain] = 1; queueMicrotask(() => emitDrain(client)); } else { emitDrain(client); } continue; } if (client[kPending] === 0) { return; } if (client[kRunning] >= (getPipelining(client) || 1)) { return; } const request = client[kQueue][client[kPendingIdx]]; if (client[kUrl].protocol === "https:" && client[kServerName] !== request.servername) { if (client[kRunning] > 0) { return; } client[kServerName] = request.servername; client[kHTTPContext]?.destroy(new InformationalError("servername changed"), () => { client[kHTTPContext] = null; resume(client); }); } if (client[kConnecting]) { return; } if (!client[kHTTPContext]) { connect(client); return; } if (client[kHTTPContext].destroyed) { return; } if (client[kHTTPContext].busy(request)) { return; } if (!request.aborted && client[kHTTPContext].write(request)) { client[kPendingIdx]++; } else { client[kQueue].splice(client[kPendingIdx], 1); } } }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
_resume
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor() { this.bottom = 0; this.top = 0; this.list = new Array(kSize); this.next = null; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
isEmpty() { return this.top === this.bottom; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
isEmpty
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
isFull() { return (this.top + 1 & kMask) === this.bottom; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
isFull
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
push(data) { this.list[this.top] = data; this.top = this.top + 1 & kMask; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
push
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
shift() { const nextItem = this.list[this.bottom]; if (nextItem === void 0) return null; this.list[this.bottom] = void 0; this.bottom = this.bottom + 1 & kMask; return nextItem; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
shift
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor() { this.head = this.tail = new FixedCircularBuffer(); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
isEmpty() { return this.head.isEmpty(); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
isEmpty
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
push(data) { if (this.head.isFull()) { this.head = this.head.next = new FixedCircularBuffer(); } this.head.push(data); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
push
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
shift() { const tail = this.tail; const next = tail.shift(); if (tail.isEmpty() && tail.next !== null) { this.tail = tail.next; } return next; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
shift
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor(pool) { this[kPool] = pool; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
get connected() { return this[kPool][kConnected]; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
connected
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
get free() { return this[kPool][kFree]; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
free
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
get pending() { return this[kPool][kPending]; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
pending
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
get queued() { return this[kPool][kQueued]; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
queued
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
get running() { return this[kPool][kRunning]; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
running
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
get size() { return this[kPool][kSize]; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
size
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor() { super(); this[kQueue] = new FixedQueue(); this[kClients] = []; this[kQueued] = 0; const pool = this; this[kOnDrain] = /* @__PURE__ */ __name(function onDrain(origin, targets) { const queue = pool[kQueue]; let needDrain = false; while (!needDrain) { const item = queue.shift(); if (!item) { break; } pool[kQueued]--; needDrain = !this.dispatch(item.opts, item.handler); } this[kNeedDrain] = needDrain; if (!this[kNeedDrain] && pool[kNeedDrain]) { pool[kNeedDrain] = false; pool.emit("drain", origin, [pool, ...targets]); } if (pool[kClosedResolve] && queue.isEmpty()) { Promise.all(pool[kClients].map((c) => c.close())).then(pool[kClosedResolve]); } }, "onDrain"); this[kOnConnect] = (origin, targets) => { pool.emit("connect", origin, [pool, ...targets]); }; this[kOnDisconnect] = (origin, targets, err) => { pool.emit("disconnect", origin, [pool, ...targets], err); }; this[kOnConnectionError] = (origin, targets, err) => { pool.emit("connectionError", origin, [pool, ...targets], err); }; this[kStats] = new PoolStats(this); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
get stats() { return this[kStats]; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
stats
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function defaultFactory(origin, opts) { return new Client(origin, opts); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
defaultFactory
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor(origin, { connections, factory = defaultFactory, connect, connectTimeout, tls, maxCachedSessions, socketPath, autoSelectFamily, autoSelectFamilyAttemptTimeout, allowH2, ...options } = {}) { super(); if (connections != null && (!Number.isFinite(connections) || connections < 0)) { throw new InvalidArgumentError("invalid connections"); } if (typeof factory !== "function") { throw new InvalidArgumentError("factory must be a function."); } if (connect != null && typeof connect !== "function" && typeof connect !== "object") { throw new InvalidArgumentError("connect must be a function or an object"); } if (typeof connect !== "function") { connect = buildConnector({ ...tls, maxCachedSessions, allowH2, socketPath, timeout: connectTimeout, ...autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0, ...connect }); } this[kInterceptors] = options.interceptors?.Pool && Array.isArray(options.interceptors.Pool) ? options.interceptors.Pool : []; this[kConnections] = connections || null; this[kUrl] = util.parseOrigin(origin); this[kOptions] = { ...util.deepClone(options), connect, allowH2 }; this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0; this[kFactory] = factory; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function getGreatestCommonDivisor(a, b) { if (a === 0) return b; while (b !== 0) { const t = b; b = a % b; a = t; } return a; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
getGreatestCommonDivisor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function defaultFactory(origin, opts) { return new Pool(origin, opts); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
defaultFactory
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor(upstreams = [], { factory = defaultFactory, ...opts } = {}) { super(); this[kOptions] = opts; this[kIndex] = -1; this[kCurrentWeight] = 0; this[kMaxWeightPerServer] = this[kOptions].maxWeightPerServer || 100; this[kErrorPenalty] = this[kOptions].errorPenalty || 15; if (!Array.isArray(upstreams)) { upstreams = [upstreams]; } if (typeof factory !== "function") { throw new InvalidArgumentError("factory must be a function."); } this[kInterceptors] = opts.interceptors?.BalancedPool && Array.isArray(opts.interceptors.BalancedPool) ? opts.interceptors.BalancedPool : []; this[kFactory] = factory; for (const upstream of upstreams) { this.addUpstream(upstream); } this._updateBalancedPoolStats(); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
addUpstream(upstream) { const upstreamOrigin = parseOrigin(upstream).origin; if (this[kClients].find((pool2) => pool2[kUrl].origin === upstreamOrigin && pool2.closed !== true && pool2.destroyed !== true)) { return this; } const pool = this[kFactory](upstreamOrigin, Object.assign({}, this[kOptions])); this[kAddClient](pool); pool.on("connect", () => { pool[kWeight] = Math.min(this[kMaxWeightPerServer], pool[kWeight] + this[kErrorPenalty]); }); pool.on("connectionError", () => { pool[kWeight] = Math.max(1, pool[kWeight] - this[kErrorPenalty]); this._updateBalancedPoolStats(); }); pool.on("disconnect", (...args) => { const err = args[2]; if (err && err.code === "UND_ERR_SOCKET") { pool[kWeight] = Math.max(1, pool[kWeight] - this[kErrorPenalty]); this._updateBalancedPoolStats(); } }); for (const client of this[kClients]) { client[kWeight] = this[kMaxWeightPerServer]; } this._updateBalancedPoolStats(); return this; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
addUpstream
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
_updateBalancedPoolStats() { let result = 0; for (let i = 0; i < this[kClients].length; i++) { result = getGreatestCommonDivisor(this[kClients][i][kWeight], result); } this[kGreatestCommonDivisor] = result; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
_updateBalancedPoolStats
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
removeUpstream(upstream) { const upstreamOrigin = parseOrigin(upstream).origin; const pool = this[kClients].find((pool2) => pool2[kUrl].origin === upstreamOrigin && pool2.closed !== true && pool2.destroyed !== true); if (pool) { this[kRemoveClient](pool); } return this; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
removeUpstream
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
get upstreams() { return this[kClients].filter((dispatcher) => dispatcher.closed !== true && dispatcher.destroyed !== true).map((p) => p[kUrl].origin); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
upstreams
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function defaultFactory(origin, opts) { return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
defaultFactory
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor({ factory = defaultFactory, maxRedirections = 0, connect, ...options } = {}) { super(); if (typeof factory !== "function") { throw new InvalidArgumentError("factory must be a function."); } if (connect != null && typeof connect !== "function" && typeof connect !== "object") { throw new InvalidArgumentError("connect must be a function or an object"); } if (!Number.isInteger(maxRedirections) || maxRedirections < 0) { throw new InvalidArgumentError("maxRedirections must be a positive number"); } if (connect && typeof connect !== "function") { connect = { ...connect }; } this[kInterceptors] = options.interceptors?.Agent && Array.isArray(options.interceptors.Agent) ? options.interceptors.Agent : [createRedirectInterceptor({ maxRedirections })]; this[kOptions] = { ...util.deepClone(options), connect }; this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0; this[kMaxRedirections] = maxRedirections; this[kFactory] = factory; this[kClients] = /* @__PURE__ */ new Map(); this[kOnDrain] = (origin, targets) => { this.emit("drain", origin, [this, ...targets]); }; this[kOnConnect] = (origin, targets) => { this.emit("connect", origin, [this, ...targets]); }; this[kOnDisconnect] = (origin, targets, err) => { this.emit("disconnect", origin, [this, ...targets], err); }; this[kOnConnectionError] = (origin, targets, err) => { this.emit("connectionError", origin, [this, ...targets], err); }; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function defaultProtocolPort(protocol) { return protocol === "https:" ? 443 : 80; }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
defaultProtocolPort
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
function defaultFactory(origin, opts) { return new Pool(origin, opts); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
defaultFactory
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
constructor(opts) { super(); /** * @param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts * @returns {URL} */ __privateAdd(this, _getUrl); if (!opts || typeof opts === "object" && !(opts instanceof URL2) && !opts.uri) { throw new InvalidArgumentError("Proxy uri is mandatory"); } const { clientFactory = defaultFactory } = opts; if (typeof clientFactory !== "function") { throw new InvalidArgumentError("Proxy opts.clientFactory must be a function."); } const url = __privateMethod(this, _getUrl, getUrl_fn).call(this, opts); const { href, origin, port, protocol, username, password, hostname: proxyHostname } = url; this[kProxy] = { uri: href, protocol }; this[kInterceptors] = opts.interceptors?.ProxyAgent && Array.isArray(opts.interceptors.ProxyAgent) ? opts.interceptors.ProxyAgent : []; this[kRequestTls] = opts.requestTls; this[kProxyTls] = opts.proxyTls; this[kProxyHeaders] = opts.headers || {}; if (opts.auth && opts.token) { throw new InvalidArgumentError("opts.auth cannot be used in combination with opts.token"); } else if (opts.auth) { this[kProxyHeaders]["proxy-authorization"] = `Basic ${opts.auth}`; } else if (opts.token) { this[kProxyHeaders]["proxy-authorization"] = opts.token; } else if (username && password) { this[kProxyHeaders]["proxy-authorization"] = `Basic ${Buffer.from(`${decodeURIComponent(username)}:${decodeURIComponent(password)}`).toString("base64")}`; } const connect = buildConnector({ ...opts.proxyTls }); this[kConnectEndpoint] = buildConnector({ ...opts.requestTls }); this[kClient] = clientFactory(url, { connect }); this[kAgent] = new Agent({ ...opts, connect: async (opts2, callback) => { let requestedPath = opts2.host; if (!opts2.port) { requestedPath += `:${defaultProtocolPort(opts2.protocol)}`; } try { const { socket, statusCode } = await this[kClient].connect({ origin, port, path: requestedPath, signal: opts2.signal, headers: { ...this[kProxyHeaders], host: opts2.host }, servername: this[kProxyTls]?.servername || proxyHostname }); if (statusCode !== 200) { socket.on("error", noop).destroy(); callback(new RequestAbortedError(`Proxy response (${statusCode}) !== 200 when HTTP Tunneling`)); } if (opts2.protocol !== "https:") { callback(null, socket); return; } let servername; if (this[kRequestTls]) { servername = this[kRequestTls].servername; } else { servername = opts2.servername; } this[kConnectEndpoint]({ ...opts2, servername, httpSocket: socket }, callback); } catch (err) { if (err.code === "ERR_TLS_CERT_ALTNAME_INVALID") { callback(new SecureProxyConnectionError(err)); } else { callback(err); } } } }); }
@param {string|URL} url @param {import('../../types/client.js').Client.Options} options
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT
dispatch(opts, handler) { const headers = buildHeaders(opts.headers); throwIfProxyAuthIsSent(headers); if (headers && !("host" in headers) && !("Host" in headers)) { const { host } = new URL2(opts.origin); headers.host = host; } return this[kAgent].dispatch( { ...opts, headers }, handler ); }
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts @returns {URL}
dispatch
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
MIT