UNPKG

@fastly/esi

Version:

ESI implementation for JavaScript, using the modern fetch and streaming APIs.

52 lines 2.64 kB
import { ValueOrPromise } from "./util.js"; export type XmlAttr = { localName: string; namespace: string | null | undefined; localNamespacePrefix: string | null; value: string; }; export declare class XmlDocument { constructor(namespaceDefs?: { [prefix: string]: string; } | null, allowUnknownNamespacePrefixes?: boolean); namespaceDefs: { [prefix: string]: string; }; allowUnknownNamespacePrefixes: boolean; } export declare class XmlElement { constructor(document: XmlDocument, name: string, attrs?: { [fullname: string]: string; } | null, children?: XmlElementNode[] | null); document: XmlDocument; parent: XmlElement | null; localName: string; localNamespacePrefix: string | null; get localFullname(): string; namespace: string | undefined; namespaceDefs: { [prefix: string]: string; }; attrs: { [fullname: string]: XmlAttr; }; children: XmlElementNode[]; applyNamespaces(): void; lookupNamespace(prefix: string | null): string; parseName(name: string): [string | null, string]; addAttr(key: string, value: string, resolveNamespace: boolean): void; get tagOpen(): string; get tagClose(): string | null; serialize(): string; static serialize(el: XmlElementNode | null): string; } export type XmlElementNode = XmlElement | string; export declare const WalkXmlStop: unique symbol; export declare const WalkXmlStopRecursion: unique symbol; export type WalkResult<TResult> = undefined | TResult | typeof WalkXmlStop; export type BeforeWalkFunc<TContext> = (this: TContext | undefined, node: XmlElementNode, parent: XmlElement | null, index: number) => ValueOrPromise<void | typeof WalkXmlStop | typeof WalkXmlStopRecursion>; export type AfterWalkFunc<TContext, TResult> = (this: TContext | undefined, node: XmlElementNode, parent: XmlElement | null, index: number, results: undefined | (TResult | undefined)[]) => ValueOrPromise<WalkResult<TResult>>; export declare function walkXmlElements<TContext, TResult>(xmlElement: XmlElement, beforeFunc?: BeforeWalkFunc<TContext> | null | undefined, afterFunc?: AfterWalkFunc<TContext, TResult> | null | undefined, context?: TContext | undefined, collectResults?: boolean): Promise<undefined | TResult | typeof WalkXmlStop>; export type TransformFunc = (el: XmlElementNode, parent: XmlElement) => ValueOrPromise<void | null | XmlElementNode | XmlElementNode[]>; export declare function buildTransform(document: XmlDocument, fn: TransformFunc): (el: XmlElementNode) => Promise<XmlElementNode | null>; //# sourceMappingURL=XmlModel.d.ts.map