import type { ExplicitSink, Sink } from "../types/sink"; import type { RMLTemplateExpressions, SinkBindingConfiguration } from "../types/internal"; import type { MaybeFuture } from "../types/futures"; import { SINK_TAG } from "../constants"; import { asap } from "../lib/drain"; export const AnyContentSink: Sink = (node: Element) => (htmlSource: MaybeFuture) => { asap((html: string) => node.innerHTML = html, htmlSource) } ; export const NodeValueSink: Sink = (node: Node) => (str: string) => { node.nodeValue = str } ; /** * A specialised sink to set the nodeValue on a node * @param source A present or future string * @returns RMLTemplateExpression A text-node RML template expression * @example
${NodeValue(stream)}
*/ export const NodeValue: ExplicitSink<'text'> = (source: RMLTemplateExpressions.StringLike) => >({ type: SINK_TAG, t: 'NodeValue', source, sink: NodeValueSink, }) ;