Download node_modules/@tanstack/query-core/src/removable.ts from metarm/QMetaRam: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/metarm/QMetaRam/resolve/main/node_modules/%40tanstack/query-core/src/removable.ts
- Command line
-
hf download hf://metarm/QMetaRam/node_modules/@tanstack/query-core/src/removable.ts
-
curl -L -o removable.ts https://huggingface.co/metarm/QMetaRam/resolve/main/node_modules/%40tanstack/query-core/src/removable.ts
1.06 kB
| import { timeoutManager } from './timeoutManager' | |
| import { isServer as isServerEnvironment } from './environmentManager' | |
| import { isValidTimeout } from './utils' | |
| import type { ManagedTimerId } from './timeoutManager' | |
| export abstract class Removable { | |
| gcTime!: number | |
| #gcTimeout?: ManagedTimerId | |
| destroy(): void { | |
| this.clearGcTimeout() | |
| } | |
| protected scheduleGc(): void { | |
| this.clearGcTimeout() | |
| if (isValidTimeout(this.gcTime)) { | |
| this.#gcTimeout = timeoutManager.setTimeout(() => { | |
| this.optionalRemove() | |
| }, this.gcTime) | |
| } | |
| } | |
| protected updateGcTime(newGcTime: number | undefined): void { | |
| // Default to 5 minutes (Infinity for server-side) if no gcTime is set | |
| this.gcTime = Math.max( | |
| this.gcTime || 0, | |
| newGcTime ?? (isServerEnvironment() ? Infinity : 5 * 60 * 1000), | |
| ) | |
| } | |
| protected clearGcTimeout() { | |
| if (this.#gcTimeout !== undefined) { | |
| timeoutManager.clearTimeout(this.#gcTimeout) | |
| this.#gcTimeout = undefined | |
| } | |
| } | |
| protected abstract optionalRemove(): void | |
| } | |