zabsalahid / serialport-gsm

SerialPort-GSM is a simplified plugin for communicating with gsm modems. (Primarily for sms) (Focused in PDU mode)
MIT License
91 stars 48 forks source link

list function is rejecting on promise #4

Closed karianpour closed 5 years ago

karianpour commented 5 years ago

I found that if do not give callback parameter to the functions, it will return a promise which is a very nice practice. But there is a bug in the list function, it reject if it succeeds and resolve if it fails. In index.js line 13 and 15, resolve and reject should be swapped.

SerialPortGSM.list((error, results) => {
  if (error) {
    resolve(error)
  } else {
    reject(results)
  }

should be changed to :

SerialPortGSM.list((error, results) => {
  if (error) {
    reject(error)
  } else {
    resolve(results)
  }
zabsalahid commented 5 years ago

@karianpour sorry about that, was not using promises most of the time. Thanks for helping out man! just updated the package.

karianpour commented 5 years ago

@zabsalahid Man that was too fast. I wish that could give it more stars.

zabsalahid commented 5 years ago

@karianpour just happen to be still in-front of the computer. haha