gersemi
Version:
59 lines (58 loc) • 1.72 kB
TypeScript
import * as XML from './XML';
export declare type JSON = boolean | number | string | null | JSONArray | JSONObject;
export interface JSONObject {
[key: string]: JSON;
}
export interface JSONArray extends Array<JSON> {
}
export declare class Parser {
static doc(xml: string): Document;
static dom(xml: string): Wrap;
static json(xml: string): JSON;
private static parser;
}
export declare class Wrap {
element: Element;
static list(elements: HTMLCollection | NodeList | Node[]): Wrap[];
static map(list: Wrap[]): {
[name: string]: Wrap[];
};
kids: Wrap[] | null;
kidMap: {
[name: string]: Wrap[];
} | null;
private attrs;
constructor(element: Element);
query(selector: string): Wrap | Wrap[] | undefined;
attr(name: string): string | null;
hasAttributes(): boolean;
readonly attributes: {
[name: string]: string;
};
readonly children: Wrap[];
readonly childMap: {
[name: string]: Wrap[];
};
prop(name: string): any;
each(fn: (kid: Wrap) => boolean | void): this;
readonly targetNamespace: string | null;
isParent(): boolean;
readonly parent: Wrap | null;
readonly document: Document;
readonly name: string;
readonly type: string;
readonly text: string;
readonly value: JSON;
private readonly parsed;
json(): JSONObject;
xml(): XML.Element;
toString(nice?: boolean): string;
}
export declare class ToJSON {
static string(s: string): JSON;
static root(wrap: Wrap): JSONObject;
static any(wrap: Wrap): JSON;
static array(list: Wrap[]): JSONArray;
static object(wrap: Wrap): JSONObject;
private static isArrayLike(wrap);
}