BlueSky & more on desktop lazurite.stormlightlabs.org/
tauri rust typescript bluesky appview atproto solid
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 38 lines 1.1 kB view raw
1/** 2 * @module type-guards 3 * A collection of common, reusable type guard functions 4 * for runtime type checking and type narrowing. 5 */ 6 7export function isRecordLike(value: unknown): value is Record<string, unknown> { 8 return typeof value === "object" && value !== null && !Array.isArray(value); 9} 10 11export function isString(value: unknown): value is string { 12 return typeof value === "string"; 13} 14 15export function getStringProperty(value: Record<string, unknown>, key: string): string | null { 16 const candidate = value[key]; 17 return typeof candidate === "string" ? candidate : null; 18} 19 20export function asRecord(value: unknown): Record<string, unknown> | null { 21 if (!value || typeof value !== "object" || Array.isArray(value)) { 22 return null; 23 } 24 25 return value as Record<string, unknown>; 26} 27 28export function asArray(value: unknown) { 29 return Array.isArray(value) ? value : null; 30} 31 32export function optionalNumber(value: unknown) { 33 return typeof value === "number" ? value : null; 34} 35 36export function optionalString(value: unknown) { 37 return typeof value === "string" ? value : null; 38}