@types/jstoxml
TypeScript icon, indicating that this package has built-in type declarations

2.0.4 • Public • Published

Installation

npm install --save @types/jstoxml

Summary

This package contains type definitions for jstoxml (https://github.com/davidcalhoun/jstoxml).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jstoxml.

index.d.ts

interface XmlAttrs {
    [name: string]: unknown;
}

export interface XmlElement {
    /**
     * Element's name
     */
    _name?: string | undefined;

    /**
     * Element's attributes.
     */
    _attrs?: XmlAttrs | XmlAttrs[] | undefined;

    /**
     * Element's content.
     */
    _content?: XmlElement | XmlElement[] | unknown | undefined;

    /**
     * Another way to create (sub)-elements (like in _content).
     */
    [key: string]: XmlElement | XmlElement[] | unknown;
}

export interface XmlOptions {
    /**
     * Tree depth.
     * @default 0
     */
    depth?: number | undefined;

    /**
     * By default elements are intented with 1 whitespace per depth.
     * @default " "
     */
    indent?: string | undefined;

    /**
     * Set Custom XML header when given a string,
     * when setting to true the default xml header will be added.
     * @default false
     */
    header?: string | boolean | undefined;

    /**
     * Custom filter for XML entities.
     */
    filter?: { [char: string]: string } | undefined;

    /**
     * Custom filter for XML attributes
     * Default filters are:
     * @example
     * <code>
     * const defaultEntityFilter = {
     *   "<": "&lt;",
     *   ">": "&gt;",
     *   "&": "&amp;",
     * };
     * </code>
     * Setting this to `false` disables attribute filters.
     */
    attributesFilter?: {} | undefined;

    /**
     * If for some reason you want to avoid self-closing tags, you can pass in a special config option _selfCloseTag.
     * @default true
     */
    _selfCloseTag?: boolean | undefined;
}

export function toXML(obj?: XmlElement | XmlElement[], options?: XmlOptions): string;

// do not export every type by default
export {};

Additional Details

  • Last updated: Tue, 07 Nov 2023 03:09:37 GMT
  • Dependencies: none

Credits

These definitions were written by Steven Snoeijen.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/jstoxml

Weekly Downloads

10,134

Version

2.0.4

License

MIT

Unpacked Size

6.01 kB

Total Files

5

Last publish

Collaborators

  • types