mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-06 02:00:07 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
12
types/domelementtype/domelementtype-tests.ts
Normal file
12
types/domelementtype/domelementtype-tests.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { DomElementType } from "domelementtype";
|
||||
|
||||
console.log(DomElementType.Text === 'text');
|
||||
console.log(DomElementType.Directive === 'directive');
|
||||
console.log(DomElementType.Comment === 'comment');
|
||||
console.log(DomElementType.Script === 'script');
|
||||
console.log(DomElementType.Style === 'style');
|
||||
console.log(DomElementType.Tag === 'tag');
|
||||
console.log(DomElementType.CDATA === 'cdata');
|
||||
console.log(DomElementType.Doctype === 'doctype');
|
||||
console.log(DomElementType.isTag({ type: DomElementType.Tag }));
|
||||
console.log(DomElementType.isTag({ type: DomElementType.Doctype }));
|
||||
45
types/domelementtype/index.d.ts
vendored
Normal file
45
types/domelementtype/index.d.ts
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// Type definitions for domelementtype 1.3
|
||||
// Project: https://github.com/fb55/domelementtype#readme
|
||||
// Definitions by: Johan Davidsson <https://github.com/johandavidson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export namespace DomElementType {
|
||||
/***
|
||||
* Text
|
||||
*/
|
||||
const Text = "text";
|
||||
/***
|
||||
* <? ... ?>
|
||||
*/
|
||||
const Directive = "directive";
|
||||
/***
|
||||
* <!-- ... -->
|
||||
*/
|
||||
const Comment = "comment";
|
||||
/***
|
||||
* <script> tags
|
||||
*/
|
||||
const Script = "script";
|
||||
/***
|
||||
* <style> tags
|
||||
*/
|
||||
const Style = "style";
|
||||
/***
|
||||
* Any tag
|
||||
*/
|
||||
const Tag = "tag";
|
||||
/***
|
||||
* <![CDATA[ ... ]]>
|
||||
*/
|
||||
const CDATA = "cdata";
|
||||
/***
|
||||
* <!DOCTYPE ... >
|
||||
*/
|
||||
const Doctype = "doctype";
|
||||
|
||||
/***
|
||||
* Checks whether element object is a tag
|
||||
*/
|
||||
function isTag(elem: { type: string}): boolean;
|
||||
}
|
||||
24
types/domelementtype/tsconfig.json
Normal file
24
types/domelementtype/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"domelementtype-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/domelementtype/tslint.json
Normal file
1
types/domelementtype/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
14
types/domhandler/domhandler-tests.ts
Normal file
14
types/domhandler/domhandler-tests.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { DomHandler, DomHandlerOptions, Node } from "domhandler";
|
||||
|
||||
const handler = new DomHandler((error: Error, dom: any) => {
|
||||
if (error)
|
||||
console.error('There has been an error...');
|
||||
else
|
||||
console.log(dom);
|
||||
});
|
||||
handler.ontext = (data: string) => { console.log(data); };
|
||||
handler.onreset = () => { console.log('We have a reset.'); };
|
||||
handler.onerror = (error: Error) => { console.error(Error); };
|
||||
handler.onopentag = (name: string, attribs) => { console.log(name, attribs); };
|
||||
|
||||
const dho: DomHandlerOptions = { normalizeWhitespace: true, withDomLvl1: true, withEndIndices: true, withStartIndices: true };
|
||||
79
types/domhandler/index.d.ts
vendored
Normal file
79
types/domhandler/index.d.ts
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
// Type definitions for domhandler 2.4
|
||||
// Project: https://github.com/fb55/DomHandler#readme
|
||||
// Definitions by: Johan Davidsson <https://github.com/johandavidson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export interface DomHandlerOptions {
|
||||
/***
|
||||
* Indicates whether the whitespace in text nodes should be normalized
|
||||
* (= all whitespace should be replaced with single spaces). The default value is "false".
|
||||
*/
|
||||
normalizeWhitespace?: boolean;
|
||||
|
||||
/***
|
||||
* Adds DOM level 1 properties to all elements.
|
||||
*/
|
||||
withDomLvl1?: boolean;
|
||||
|
||||
/***
|
||||
* Indicates whether a startIndex property will be added to nodes.
|
||||
* When the parser is used in a non-streaming fashion, startIndex is an integer
|
||||
* indicating the position of the start of the node in the document.
|
||||
* The default value is "false".
|
||||
*/
|
||||
withStartIndices?: boolean;
|
||||
|
||||
/***
|
||||
* Indicates whether a endIndex property will be added to nodes.
|
||||
* When the parser is used in a non-streaming fashion, endIndex is an integer
|
||||
* indicating the position of the end of the node in the document.
|
||||
* The default value is "false".
|
||||
*/
|
||||
withEndIndices?: boolean;
|
||||
}
|
||||
|
||||
export interface DomElement {
|
||||
attribs?: {[s: string]: string};
|
||||
children?: DomElement[];
|
||||
data?: any;
|
||||
name?: string;
|
||||
next?: DomElement;
|
||||
parent?: DomElement;
|
||||
prev?: DomElement;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export interface Element extends DomElement {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Node extends DomElement {
|
||||
readonly firstChild: DomElement;
|
||||
readonly lastChild: DomElement;
|
||||
readonly nodeType: number;
|
||||
}
|
||||
|
||||
export class DomHandler {
|
||||
constructor(callback: (error: any, dom: DomElement[]) => any, options?: DomHandlerOptions);
|
||||
|
||||
onparserinit(parser: any): void;
|
||||
|
||||
/***
|
||||
* Resets the handler back to starting state
|
||||
*/
|
||||
onreset(): void;
|
||||
|
||||
/***
|
||||
* Signals the handler that parsing is done
|
||||
*/
|
||||
onend(): void;
|
||||
onerror(error: Error): void;
|
||||
onclosetag(): void;
|
||||
onopentag(name: string, attribs: {[s: string]: string}): void;
|
||||
ontext(data: string): void;
|
||||
oncomment(data: string): void;
|
||||
oncdatastart(): void;
|
||||
oncommentend(): void;
|
||||
onprocessinginstruction(name: string, data: string): void;
|
||||
}
|
||||
24
types/domhandler/tsconfig.json
Normal file
24
types/domhandler/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"domhandler-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/domhandler/tslint.json
Normal file
1
types/domhandler/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user