a post-component library for building user-interfaces on the web.
at push-txxtpymvvxno 27 lines 844 B view raw
1import { html, type Displayable, type HTML, type Renderable } from 'dhtml' 2 3declare global { 4 var __DEV__: boolean 5} 6 7export function is_renderable(value: unknown): value is Renderable { 8 return typeof value === 'object' && value !== null && 'render' in value 9} 10 11export function is_iterable(value: unknown): value is Iterable<unknown> { 12 return typeof value === 'object' && value !== null && Symbol.iterator in value 13} 14 15export function assert(value: unknown, message?: string): asserts value { 16 if (!__DEV__) return 17 if (!value) throw new Error(message ?? 'assertion failed') 18} 19 20export const html_tag: unique symbol = Symbol() 21export function is_html(value: any): value is HTML { 22 return typeof value === 'object' && value !== null && html_tag in value 23} 24 25export function single_part_template(part: Displayable): HTML { 26 return html`${part}` 27}