-
-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from bb/master
first draft of typings for typescript #69
- Loading branch information
Showing
2 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,5 +81,6 @@ | |
}, | ||
"dependencies": { | ||
"nimnjs": "^1.2.2" | ||
} | ||
}, | ||
"typings": "src/parser.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |