$app/server
import {
import DedupeCache
DedupeCache,
import dedupe
dedupe,
function getRequestEvent(): RequestEvent<Partial<Record<string, string>>, string | null>
Returns the current RequestEvent
. Can be used inside handle
, load
and actions (and functions called by them).
In environments without AsyncLocalStorage
, this must be called synchronously (i.e. not after an await
).
getRequestEvent,
import getUnderlyingDedupeFunction
getUnderlyingDedupeFunction,
function read(asset: string): Response
Read the contents of an imported asset from the filesystem
read
} from '$app/server';
DedupeCache
Defines the cache of functions for this request.
class DedupeCache {…}
private _values;
has<F extends (...args: any[]) => any>(fn: F, ...args: Parameters<F>): boolean;
fn
- The function to check.args
- The arguments to check.- returns - Whether the function call is cached.
Check if a given function call is cached.
remove<F extends (...args: any[]) => any>(fn: F, ...args: Parameters<F>): boolean;
fn
- The function to remove.args
- The arguments to remove.- returns - Whether the function call was removed.
Remove a function call from the cache.
dedupe
Creates a deduplicated function. This means that within a request, if multiple calls are made with the same arguments, the underlying function will only be called once and the result will be cached and returned for all subsequent calls.
function dedupe<F extends (...args: any[]) => any>(
fn: F
): F;
getRequestEvent
Available since 2.20.0
Returns the current RequestEvent
. Can be used inside server hooks, server load
functions, actions, and endpoints (and functions called by them).
In environments without AsyncLocalStorage
, this must be called synchronously (i.e. not after an await
).
function getRequestEvent(): RequestEvent<
Partial<Record<string, string>>,
string | null
>;
getUnderlyingDedupeFunction
Gets the underlying function that was turned into a proxy.
function getUnderlyingDedupeFunction<
F extends (...args: any[]) => any
>(fn: F): F;
read
Available since 2.4.0
Read the contents of an imported asset from the filesystem
import { function read(asset: string): Response
Read the contents of an imported asset from the filesystem
read } from '$app/server';
import const somefile: string
somefile from './somefile.txt';
const const asset: Response
asset = function read(asset: string): Response
Read the contents of an imported asset from the filesystem
read(const somefile: string
somefile);
const const text: string
text = await const asset: Response
asset.Body.text(): Promise<string>
text();
function read(asset: string): Response;
Edit this page on GitHub llms.txt