Buckets:
| type RecordValue = Record<string, unknown> | |
| const isRecord = (value: unknown): value is RecordValue => { | |
| return typeof value === "object" && value !== null | |
| } | |
| export const isDisposable = (value: unknown): value is { dispose: () => void } => { | |
| return isRecord(value) && typeof value.dispose === "function" | |
| } | |
| export const disposeIfDisposable = (value: unknown) => { | |
| if (!isDisposable(value)) return | |
| value.dispose() | |
| } | |
| export const hasSetOption = (value: unknown): value is { setOption: (key: string, next: unknown) => void } => { | |
| return isRecord(value) && typeof value.setOption === "function" | |
| } | |
| export const setOptionIfSupported = (value: unknown, key: string, next: unknown) => { | |
| if (!hasSetOption(value)) return | |
| value.setOption(key, next) | |
| } | |
| export const getHoveredLinkText = (value: unknown) => { | |
| if (!isRecord(value)) return | |
| const link = value.currentHoveredLink | |
| if (!isRecord(link)) return | |
| if (typeof link.text !== "string") return | |
| return link.text | |
| } | |
| export const getSpeechRecognitionCtor = <T>(value: unknown): (new () => T) | undefined => { | |
| if (!isRecord(value)) return | |
| const ctor = | |
| typeof value.webkitSpeechRecognition === "function" ? value.webkitSpeechRecognition : value.SpeechRecognition | |
| if (typeof ctor !== "function") return | |
| return ctor as new () => T | |
| } | |
Xet Storage Details
- Size:
- 1.31 kB
- Xet hash:
- 72f93802353fd439705b7a1f7a8c0363f2875a151144c1dbd804c1c5ed06c0af
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.