Download mobile/modules/engine/src/utils/devSnapshotRequests.ts from Anirudh1950/MentraOS: direct link, hf CLI and curl.
- Browser
- Download file 675 Bytes
-
https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mobile/modules/engine/src/utils/devSnapshotRequests.ts
- Command line
-
hf download hf://Anirudh1950/MentraOS/mobile/modules/engine/src/utils/devSnapshotRequests.ts
-
curl -L -o devSnapshotRequests.ts https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mobile/modules/engine/src/utils/devSnapshotRequests.ts
675 Bytes
| const generations = new Map<string, number>() | |
| /** Release selection invalidates any earlier asynchronous dev probe/download. */ | |
| export function invalidateDevSnapshotRequests(packageName: string): void { | |
| generations.set(packageName, (generations.get(packageName) ?? 0) + 1) | |
| } | |
| export function createDevSnapshotRequest(packageName: string) { | |
| const generation = generations.get(packageName) ?? 0 | |
| const isCurrent = () => (generations.get(packageName) ?? 0) === generation | |
| return { | |
| isCurrent, | |
| beforeActivate: () => { | |
| if (!isCurrent()) throw new Error(`Dev snapshot for ${packageName} was superseded by a release installation`) | |
| }, | |
| } | |
| } | |