mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Add types for sax-stream (#41339)
This commit is contained in:
54
types/sax-stream/index.d.ts
vendored
Normal file
54
types/sax-stream/index.d.ts
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// Type definitions for sax-stream 1.3
|
||||
// Project: https://github.com/melitele/sax-stream
|
||||
// Definitions by: Michael de Wit <https://github.com/mjwwit>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import stream = require("stream");
|
||||
|
||||
declare namespace saxStream {
|
||||
interface Options {
|
||||
/**
|
||||
* Name of the tag to select objects from XML file, an Array of tag names can be used -
|
||||
* when multiple tags are specified stream pushes `{ tag, record }` tuples.
|
||||
*/
|
||||
tag: string | ReadonlyArray<string>;
|
||||
/**
|
||||
* Size of internal transform stream buffer - defaults to 350 objects.
|
||||
*/
|
||||
highWaterMark?: number;
|
||||
/**
|
||||
* Default to false, if true makes sax parser to accept valid XML only.
|
||||
*/
|
||||
strict?: boolean;
|
||||
/**
|
||||
* Whether or not to trim text and comment nodes.
|
||||
*/
|
||||
trim?: boolean;
|
||||
/**
|
||||
* If true, then turn any whitespace into a single space.
|
||||
*/
|
||||
normalize?: boolean;
|
||||
/**
|
||||
* If true, then lowercase tag names and attribute names in loose mode, rather than uppercasing them.
|
||||
*/
|
||||
lowercase?: boolean;
|
||||
/**
|
||||
* If true, then namespaces are supported.
|
||||
*/
|
||||
xmlns?: boolean;
|
||||
/**
|
||||
* If false, then don't track line/col/position.
|
||||
*/
|
||||
trackPosition?: boolean;
|
||||
/**
|
||||
* If true, only parse predefined XML entities (&, ', >, <, and ").
|
||||
*/
|
||||
strictEntities?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare function saxStream(options: saxStream.Options): stream.Transform;
|
||||
|
||||
export = saxStream;
|
||||
23
types/sax-stream/sax-stream-tests.ts
Normal file
23
types/sax-stream/sax-stream-tests.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import saxStream = require('sax-stream');
|
||||
|
||||
// $ExpectType Transform
|
||||
saxStream({ tag: '' });
|
||||
|
||||
// $ExpectType Transform
|
||||
saxStream({
|
||||
tag: '',
|
||||
highWaterMark: 1,
|
||||
strict: true,
|
||||
trim: true,
|
||||
normalize: true,
|
||||
lowercase: true,
|
||||
xmlns: true,
|
||||
trackPosition: true,
|
||||
strictEntities: true
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
saxStream({});
|
||||
|
||||
// $ExpectError
|
||||
saxStream();
|
||||
23
types/sax-stream/tsconfig.json
Normal file
23
types/sax-stream/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"sax-stream-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/sax-stream/tslint.json
Normal file
1
types/sax-stream/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user