Skip to content

Commit

Permalink
Merge pull request #3 from ifm-slang/fixing-array-responses
Browse files Browse the repository at this point in the history
Fixing array responses
  • Loading branch information
francescogabbrielli authored Oct 7, 2022
2 parents 6c7ce0f + b14e2d6 commit b678d0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib/xml2js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class Xml2js {
valueNodes = this.helper.selectNodes(input, './value');
if (!valueNodes.length)
return [];
return valueNodes.map(this.convert);
return valueNodes.map(this.convert, this);
}

/**
Expand Down Expand Up @@ -114,7 +114,7 @@ export class Xml2js {
/**
* Convert an xmlrpc value (as an xml tree) to a javascript object.
*/
convert(input:Node):Object|null {
convert(input:Node):Object|any[]|null {
const elt = this.helper.selectSingleNode(input, './*')
if (!elt)
return null
Expand Down
3 changes: 2 additions & 1 deletion src/lib/xmlrpc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ export class XmlrpcService {
* - undefined: for empty response
* - null: for 'nil' value
* - Object: the value as an Object
* - any[]: if the value was an Array
*
* @throws {@link Error} on fault response (or unexpected server error)
*/
parseResponse(response:string):Object|null|undefined {
parseResponse(response:string):Object|any[]|null|undefined {
const doc = this.helper.loadXml(response)
const rootNode = doc.firstChild
if (!rootNode)
Expand Down

0 comments on commit b678d0e

Please sign in to comment.