// Type definitions for node-xml2js 0.4 // Project: https://github.com/Leonidas-from-XIV/node-xml2js // Definitions by: Michel Salib // Jason McNeil // Christopher Currens // Edward Hinkle // Claas Ahlrichs // Grzegorz Redlicki // Ryan Ling // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Minimum TypeScript Version: 3.5 /// import { EventEmitter } from 'events'; import * as processors from './lib/processors'; export function parseString(str: convertableToString, callback: (err: Error, result: any) => void): void; export function parseString( str: convertableToString, options: ParserOptions, callback: (err: Error, result: any) => void, ): void; export function parseStringPromise(str: convertableToString, options?: ParserOptions): Promise; export const defaults: { '0.1': Options; '0.2': OptionsV2; }; export interface XmlDeclarationAttributes { version: string; encoding?: string | undefined; standalone?: boolean | undefined; } export interface RenderOptions { pretty?: boolean | undefined; indent?: string | undefined; newline?: string | undefined; } export class Builder { constructor(options?: BuilderOptions); buildObject(rootObj: any): string; } export class Parser extends EventEmitter { constructor(options?: ParserOptions); parseString(str: convertableToString, cb?: Function): void; parseStringPromise(str: convertableToString): Promise; reset(): void; } export interface ParserOptions { attrkey?: string | undefined; charkey?: string | undefined; explicitCharkey?: boolean | undefined; trim?: boolean | undefined; normalizeTags?: boolean | undefined; normalize?: boolean | undefined; explicitRoot?: boolean | undefined; emptyTag?: any; explicitArray?: boolean | undefined; ignoreAttrs?: boolean | undefined; mergeAttrs?: boolean | undefined; validator?: Function | undefined; xmlns?: boolean | undefined; explicitChildren?: boolean | undefined; childkey?: string | undefined; preserveChildrenOrder?: boolean | undefined; charsAsChildren?: boolean | undefined; includeWhiteChars?: boolean | undefined; async?: boolean | undefined; strict?: boolean | undefined; attrNameProcessors?: Array<(name: string) => any> | undefined; attrValueProcessors?: Array<(value: string, name: string) => any> | undefined; tagNameProcessors?: Array<(name: string) => any> | undefined; valueProcessors?: Array<(value: string, name: string) => any> | undefined; chunkSize?: number | undefined; } export interface BuilderOptions { attrkey?: string | undefined; charkey?: string | undefined; rootName?: string | undefined; renderOpts?: RenderOptions | undefined; xmldec?: XmlDeclarationAttributes | undefined; doctype?: any; headless?: boolean | undefined; allowSurrogateChars?: boolean | undefined; cdata?: boolean | undefined; } export type Options = Omit; export type OptionsV2 = ParserOptions & BuilderOptions; export interface convertableToString { toString(): string; } export { processors };