Skip to content

Commit

Permalink
fix: Faulty error thrown by ProgramCall.addParam (#124)
Browse files Browse the repository at this point in the history
When ProgramCall.addParam is passed a DS (2D array) the second parameter is an optional object for parm options.

addParam(data, [,options])

Latest code in master throws an error when passing an DS and no options object to ProgramCall.addParam.

`Error: Specifying the parameter type is required.`

An error should not be thrown if a DS is passed to addParam without providing the option object.
  • Loading branch information
abmusse committed Mar 3, 2020
1 parent 739cb47 commit 75d081c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/ProgramCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ class ProgramCall {
addParam(data, type, options, inDs = null) {
let opt;
// DS element has no 'type', so if the second param 'type' is an Object, then it is the options.
if (typeof type === 'object') {
if (Array.isArray(data)) {
opt = type;
} else {
opt = options;
if (!type) {
if (type === undefined) {
throw new Error('Specifying the parameter type is required.');
}
}

if (!inDs) { // In recursive mode, if it is an element in DS, then no <parm> or </parm> needed.
this.xml += '<parm';
if (opt && typeof opt === 'object') { // append <param> options
Expand Down

0 comments on commit 75d081c

Please sign in to comment.