mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-06 13:11:46 +00:00
xml2js: Lint and move /// <reference types="node" /> to index
This commit is contained in:
Vendored
+67
-69
@@ -1,80 +1,78 @@
|
||||
// Type definitions for node-xml2js
|
||||
// Type definitions for node-xml2js 0.4
|
||||
// Project: https://github.com/Leonidas-from-XIV/node-xml2js
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Jason McNeil <https://github.com/jasonrm>, Christopher Currens <https://github.com/ccurrens>, Edward Hinkle <https://github.com/edwardhinkle>
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>
|
||||
// Jason McNeil <https://github.com/jasonrm>
|
||||
// Christopher Currens <https://github.com/ccurrens>
|
||||
// Edward Hinkle <https://github.com/edwardhinkle>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="./processors.d.ts" />
|
||||
/// <reference types="node"/>
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
export = xml2js;
|
||||
export function parseString(xml: convertableToString, callback: (err: any, result: any) => void): void;
|
||||
export function parseString(xml: convertableToString, options: OptionsV2, callback: (err: any, result: any) => void): void;
|
||||
|
||||
import * as events from 'events'
|
||||
export const defaults: {
|
||||
'0.1': Options;
|
||||
'0.2': OptionsV2;
|
||||
};
|
||||
|
||||
declare namespace xml2js {
|
||||
function parseString(xml: convertableToString, callback: (err: any, result: any) => void): void;
|
||||
function parseString(xml: convertableToString, options: OptionsV2, callback: (err: any, result: any) => void): void;
|
||||
export class Builder {
|
||||
constructor(options?: OptionsV2);
|
||||
buildObject(rootObj: any): string;
|
||||
}
|
||||
|
||||
var defaults: {
|
||||
'0.1': Options;
|
||||
'0.2': OptionsV2;
|
||||
}
|
||||
export class Parser extends EventEmitter {
|
||||
constructor(options?: OptionsV2);
|
||||
parseString(str: convertableToString, cb?: Function): void;
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
class Builder {
|
||||
constructor(options?: OptionsV2);
|
||||
buildObject(rootObj: any): string;
|
||||
}
|
||||
export interface Options {
|
||||
async?: boolean;
|
||||
attrkey?: string;
|
||||
attrNameProcessors?: [(name: string) => any];
|
||||
attrValueProcessors?: [(name: string) => any];
|
||||
charkey?: string;
|
||||
charsAsChildren?: boolean;
|
||||
childkey?: string;
|
||||
emptyTag?: any;
|
||||
explicitArray?: boolean;
|
||||
explicitCharkey?: boolean;
|
||||
explicitChildren?: boolean;
|
||||
explicitRoot?: boolean;
|
||||
ignoreAttrs?: boolean;
|
||||
includeWhiteChars?: boolean;
|
||||
mergeAttrs?: boolean;
|
||||
normalize?: boolean;
|
||||
normalizeTags?: boolean;
|
||||
strict?: boolean;
|
||||
tagNameProcessors?: [(name: string) => any];
|
||||
trim?: boolean;
|
||||
validator?: Function;
|
||||
valueProcessors?: [(name: string) => any];
|
||||
xmlns?: boolean;
|
||||
}
|
||||
|
||||
class Parser extends events.EventEmitter {
|
||||
constructor(options?: OptionsV2);
|
||||
parseString(str: convertableToString, cb?: Function): void;
|
||||
reset(): void;
|
||||
}
|
||||
export interface OptionsV2 extends Options {
|
||||
preserveChildrenOrder?: boolean;
|
||||
rootName?: string;
|
||||
xmldec?: {
|
||||
version: string;
|
||||
encoding?: string;
|
||||
standalone?: boolean;
|
||||
};
|
||||
doctype?: any;
|
||||
renderOpts?: {
|
||||
pretty?: boolean;
|
||||
indent?: string;
|
||||
newline?: string;
|
||||
};
|
||||
headless?: boolean;
|
||||
chunkSize?: number;
|
||||
cdata?: boolean;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
async?: boolean;
|
||||
attrkey?: string;
|
||||
attrNameProcessors?: [(name: string) => any];
|
||||
attrValueProcessors?: [(name: string) => any];
|
||||
charkey?: string;
|
||||
charsAsChildren?: boolean;
|
||||
childkey?: string;
|
||||
emptyTag?: any;
|
||||
explicitArray?: boolean;
|
||||
explicitCharkey?: boolean;
|
||||
explicitChildren?: boolean;
|
||||
explicitRoot?: boolean;
|
||||
ignoreAttrs?: boolean;
|
||||
includeWhiteChars?: boolean;
|
||||
mergeAttrs?: boolean;
|
||||
normalize?: boolean;
|
||||
normalizeTags?: boolean;
|
||||
strict?: boolean;
|
||||
tagNameProcessors?: [(name: string) => any];
|
||||
trim?: boolean;
|
||||
validator?: Function;
|
||||
valueProcessors?: [(name: string) => any];
|
||||
xmlns?: boolean;
|
||||
}
|
||||
|
||||
interface OptionsV2 extends Options {
|
||||
preserveChildrenOrder?: boolean;
|
||||
rootName?: string;
|
||||
xmldec?: {
|
||||
version: string;
|
||||
encoding?: string;
|
||||
standalone?: boolean;
|
||||
};
|
||||
doctype?: any;
|
||||
renderOpts?: {
|
||||
pretty?: boolean;
|
||||
indent?: string;
|
||||
newline?: string;
|
||||
};
|
||||
headless?: boolean;
|
||||
chunkSize?: number;
|
||||
cdata?: boolean;
|
||||
}
|
||||
|
||||
interface convertableToString {
|
||||
toString(): string;
|
||||
}
|
||||
export interface convertableToString {
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
export function firstCharLowerCase(name: string): string;
|
||||
|
||||
export function normalize(name: string): string;
|
||||
|
||||
export function parseBooleans(name: string): boolean;
|
||||
|
||||
export function parseNumbers(name: string): number;
|
||||
|
||||
export function stripPrefix(name: string): string;
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
declare module 'xml2js/lib/processors' {
|
||||
export function firstCharLowerCase(name: string): string;
|
||||
|
||||
export function normalize(name: string): string;
|
||||
|
||||
export function parseBooleans(name: string): boolean;
|
||||
|
||||
export function parseNumbers(name: string): number;
|
||||
|
||||
export function stripPrefix(name: string): string;
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"lib/processors.d.ts",
|
||||
"xml2js-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// All TODOs
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
/// <reference types="node"/>
|
||||
|
||||
import xml2js = require('xml2js');
|
||||
import * as processors from 'xml2js/lib/processors';
|
||||
import fs = require('fs');
|
||||
|
||||
xml2js.parseString('<root>Hello xml2js!</root>', (err: any, result: any) => { });
|
||||
|
||||
@@ -40,13 +39,13 @@ xml2js.parseString('<root>Hello xml2js!</root>', {
|
||||
valueProcessors: [processors.parseBooleans, processors.parseNumbers]
|
||||
}, (err: any, result: any) => { });
|
||||
|
||||
var builder = new xml2js.Builder({
|
||||
let builder = new xml2js.Builder({
|
||||
renderOpts: {
|
||||
pretty: false
|
||||
}
|
||||
});
|
||||
|
||||
var builder = new xml2js.Builder({
|
||||
builder = new xml2js.Builder({
|
||||
rootName: 'root',
|
||||
renderOpts: {
|
||||
pretty: true,
|
||||
@@ -63,29 +62,27 @@ var builder = new xml2js.Builder({
|
||||
cdata: false
|
||||
});
|
||||
|
||||
var outString = builder.buildObject({
|
||||
'hello': 'xml2js!'
|
||||
const outString = builder.buildObject({
|
||||
hello: 'xml2js!'
|
||||
});
|
||||
|
||||
var parser = new xml2js.Parser();
|
||||
const parser = new xml2js.Parser();
|
||||
|
||||
parser.on('end', (result: any) => {
|
||||
console.log("Parser Finished");
|
||||
return;
|
||||
});
|
||||
|
||||
var v1Defaults = xml2js.defaults['0.1'];
|
||||
const v1Defaults = xml2js.defaults['0.1'];
|
||||
v1Defaults.async = true;
|
||||
|
||||
var v2Defaults = xml2js.defaults['0.2'];
|
||||
const v2Defaults = xml2js.defaults['0.2'];
|
||||
v2Defaults.async = false;
|
||||
v2Defaults.chunkSize = 20000;
|
||||
|
||||
import fs = require('fs');
|
||||
|
||||
fs.readFile(__dirname + '/foo.xml', function(err, data) {
|
||||
parser.parseString(data, function (err: any, result: any) {
|
||||
console.dir(result);
|
||||
console.log('Done');
|
||||
});
|
||||
});
|
||||
fs.readFile(__dirname + '/foo.xml', (err, data) => {
|
||||
parser.parseString(data, (err: any, result: any) => {
|
||||
console.dir(result);
|
||||
console.log('Done');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user