mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
Added ltx definitions.
This commit is contained in:
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// Type definitions for ltx 2.6
|
||||
// Project: github.com/node-xmpp/ltx/
|
||||
// Definitions by: PJakcson <https://github.com/PJakcson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export {Element} from './lib/Element'
|
||||
export {nameEqual, attrsEqual, childrenEqual, equal} from './lib/equal';
|
||||
export {isNode, isElement, isText} from './lib/is';
|
||||
export {clone} from './lib/clone';
|
||||
export {createElement} from './lib/createElement';
|
||||
export {escapeXML, unescapeXML, escapeXMLText, unescapeXMLText} from './lib/escape';
|
||||
export {Parser} from './lib/Parser';
|
||||
export {parse} from './lib/parse';
|
||||
export {tag} from './lib/tag';
|
||||
export {tagString} from './lib/tagString';
|
||||
export {stringify} from './lib/stringify';
|
||||
Vendored
+119
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* Element
|
||||
*
|
||||
* Attributes are in the element.attrs object. Children is a list of
|
||||
* either other Elements or Strings for text content.
|
||||
**/
|
||||
export declare class Element {
|
||||
name: string;
|
||||
parent: Element;
|
||||
children: Element[];
|
||||
attrs: any;
|
||||
|
||||
constructor(name: string, attrs?: any);
|
||||
|
||||
/**
|
||||
* if (element.is('message', 'jabber:client')) ...
|
||||
**/
|
||||
is(name: string, xmlns?: any): boolean;
|
||||
|
||||
/**
|
||||
* without prefix.
|
||||
*/
|
||||
getName(): string;
|
||||
|
||||
/**
|
||||
* retrieves the namespace of the current element, upwards recursively
|
||||
**/
|
||||
getNS(): any;
|
||||
|
||||
/**
|
||||
* find the namespace to the given prefix, upwards recursively
|
||||
**/
|
||||
findNS(prefix: string): any;
|
||||
|
||||
/**
|
||||
* Recursiverly gets all xmlns defined, in the form of {url:prefix}
|
||||
**/
|
||||
getXmlns(): any;
|
||||
|
||||
setAttrs(attrs: any): void;
|
||||
|
||||
/**
|
||||
* xmlns can be null, returns the matching attribute.
|
||||
**/
|
||||
getAttr(name: string, xmlns?: any): any;
|
||||
|
||||
/**
|
||||
* xmlns can be null
|
||||
**/
|
||||
getChild(name: string, xmlns?: any): Element;
|
||||
|
||||
/**
|
||||
* xmlns can be null
|
||||
**/
|
||||
getChildren(name: string, xmlns?: any): Element[];
|
||||
|
||||
/**
|
||||
* xmlns and recursive can be null
|
||||
**/
|
||||
getChildByAttr(attr: any, val: any, xmlns?: any, recursive?: any): Element;
|
||||
|
||||
|
||||
/**
|
||||
* xmlns and recursive can be null
|
||||
**/
|
||||
getChildrenByAttr(attr: any, val: any, xmlns?: any, recursive?: any): Element[];
|
||||
|
||||
getText(): string;
|
||||
|
||||
getChildText(name: string, xmlns: any): string;
|
||||
|
||||
/**
|
||||
* Return all direct descendents that are Elements.
|
||||
* This differs from `getChildren` in that it will exclude text nodes,
|
||||
* processing instructions, etc.
|
||||
*/
|
||||
getChildElements(): Element[];
|
||||
|
||||
/** returns uppermost parent */
|
||||
root(): Element;
|
||||
|
||||
tree(): Element;
|
||||
|
||||
/** just parent or itself */
|
||||
up(): Element;
|
||||
|
||||
/** create child node and return it */
|
||||
c(name: string, attrs?: any): Element;
|
||||
|
||||
/** add text node and return element */
|
||||
t(text: string): Element;
|
||||
|
||||
/**
|
||||
* Either:
|
||||
* el.remove(childEl)
|
||||
* el.remove('author', 'urn:...')
|
||||
*/
|
||||
remove(el: Element, xmlns?: any): Element;
|
||||
|
||||
clone(): Element;
|
||||
|
||||
text(val: string): string;
|
||||
|
||||
attr(attr: any, val: any): any;
|
||||
|
||||
toString(): string;
|
||||
|
||||
toJSON(): any;
|
||||
|
||||
write(writer: any): void;
|
||||
|
||||
nameEquals(el: Element): boolean;
|
||||
|
||||
attrsEquals(el: Element): boolean;
|
||||
|
||||
childrenEquals(el: Element): boolean;
|
||||
|
||||
equals(el: Element): boolean;
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
/// <reference types="node" />
|
||||
import {EventEmitter} from 'events';
|
||||
export declare class Parser extends EventEmitter {
|
||||
constructor(options?: any);
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function clone(el: any): any;
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
import {Element} from './Element';
|
||||
export declare function createElement(name: string, attrs: any): Element;
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export declare function nameEqual(a: any, b: any): boolean;
|
||||
export declare function attrsEqual(a: any, b: any): boolean;
|
||||
export declare function childrenEqual(a: any, b: any): boolean;
|
||||
export declare function equal(a: any, b: any): boolean;
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export declare function escapeXML(s: string): string;
|
||||
export declare function unescapeXML(s: string): string;
|
||||
export declare function escapeXMLText(s: string): string;
|
||||
export declare function unescapeXMLText(s: string): string;
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export declare function isNode(el: any): boolean;
|
||||
export declare function isElement(el: any): boolean;
|
||||
export declare function isText(el: any): boolean;
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function parse(data: any, options?: any): any;
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function stringify(el: any, indent: any, level: any): string;
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function tag(d: any): any;
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function tagString(d: any): string;
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as ltx from './index';
|
||||
|
||||
ltx.parse('<document/>');
|
||||
|
||||
let p = new ltx.Parser();
|
||||
|
||||
p.on('tree', function (ignored) {
|
||||
});
|
||||
|
||||
p.on('error', function (ignored) {
|
||||
});
|
||||
|
||||
|
||||
let el = new ltx.Element('root').c('children');
|
||||
el.c('child', {age: 5}).t('Hello').up()
|
||||
.c('child', {age: 7}).t('Hello').up()
|
||||
.c('child', {age: 99}).t('Hello').up();
|
||||
|
||||
el.root().toString();
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ltx-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
Reference in New Issue
Block a user