```js // @noErrors import { DedupeCache, dedupe, getRequestEvent, getUnderlyingDedupeFunction, read } from '$app/server'; ``` ## DedupeCache Defines the cache of functions for this request.
```dts class DedupeCache {/*…*/} ```
```dts private _values; ```
```dts has any>(fn: F, ...args: Parameters): 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.
```dts remove any>(fn: F, ...args: Parameters): 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.
```dts function dedupe 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`](https://nodejs.org/api/async_context.html#class-asynclocalstorage), this must be called synchronously (i.e. not after an `await`).
```dts function getRequestEvent(): RequestEvent< Partial>, string | null >; ```
## getUnderlyingDedupeFunction Gets the underlying function that was turned into a proxy.
```dts 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 ```js // @errors: 7031 import { read } from '$app/server'; import somefile from './somefile.txt'; const asset = read(somefile); const text = await asset.text(); ```
```dts function read(asset: string): Response; ```