Download client/simple/src/js/util/getElement.ts from Openyx/xcdv: direct link, hf CLI and curl.
- Browser
- Download file 560 Bytes
-
https://huggingface.co/spaces/Openyx/xcdv/resolve/main/client/simple/src/js/util/getElement.ts
- Command line
-
hf download hf://spaces/Openyx/xcdv/client/simple/src/js/util/getElement.ts
-
curl -L -o getElement.ts https://huggingface.co/spaces/Openyx/xcdv/resolve/main/client/simple/src/js/util/getElement.ts
560 Bytes
| // SPDX-License-Identifier: AGPL-3.0-or-later | |
| import { assertElement } from "./assertElement.ts"; | |
| type Options = { | |
| assert?: boolean; | |
| }; | |
| export function getElement<T>(id: string, options?: { assert: true }): T; | |
| export function getElement<T>(id: string, options?: { assert: false }): T | null; | |
| export function getElement<T>(id: string, options: Options = {}): T | null { | |
| options.assert ??= true; | |
| const element = document.getElementById(id) as T | null; | |
| if (options.assert) { | |
| assertElement(element); | |
| } | |
| return element; | |
| } | |