Skip to content

Commit

Permalink
Merge pull request #71 from bb/master
Browse files Browse the repository at this point in the history
first draft of typings for typescript #69
  • Loading branch information
amitguptagwl committed Apr 2, 2018
2 parents 04fe450 + 4dbd87f commit 273416b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@
},
"dependencies": {
"nimnjs": "^1.2.2"
}
},
"typings": "src/parser.d.ts"
}
64 changes: 64 additions & 0 deletions src/parser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
type X2jOptions = {
attributeNamePrefix: string;
attrNodeName: false | string;
textNodeName: string;
ignoreAttributes: boolean;
ignoreNameSpace: boolean;
allowBooleanAttributes: boolean;
parseNodeValue: boolean;
parseAttributeValue: boolean;
arrayMode: boolean;
trimValues: boolean;
cdataTagName: false | string;
cdataPositionChar: string;
tagValueProcessor: (tagValue: string) => string;
attrValueProcessor: (attrValue: string) => string;
};
type X2jOptionsOptional = Partial<X2jOptions>;

type J2xOptions = {
attributeNamePrefix: string;
attrNodeName: false | string;
textNodeName: string;
ignoreAttributes: boolean;
cdataTagName: false | string;
cdataPositionChar: string;
format: boolean;
indentBy: string;
supressEmptyNode: boolean;
tagValueProcessor: (tagValue: string) => string;
attrValueProcessor: (attrValue: string) => string;
};
type J2xOptionsOptional = Partial<J2xOptions>;

type ESchema = string | Array | object;

type ValidationError = {
err: { code: string; msg: string };
};

export function parse(xmlData: string, options?: X2jOptionsOptional): any;
export function convert2nimn(
node: any,
e_schema: ESchema,
options?: X2jOptionsOptional
): any;
export function getTraversalObj(
xmlData: string,
options?: X2jOptionsOptional
): any;
export function convertToJson(node: any, options?: X2jOptionsOptional): any;
export function convertToJsonString(
node: any,
options?: X2jOptionsOptional
): string;
export function validate(
xmlData: string,
options?: { allowBooleanAttributes?: boolean }
): true | ValidationError;
// export j2xParser ???
export function parseToNimn(
xmlData: string,
schema,
options: Partial<X2jOptions>
): any;

0 comments on commit 273416b

Please sign in to comment.