browser-serialport icon indicating copy to clipboard operation
browser-serialport copied to clipboard

(bad patch) .. } else if (typeof fc === 'string'){

Open Red-Owl opened this issue 5 years ago • 0 comments

options.rtscts = _options.rtscts;

if (options.flowControl || options.flowcontrol) { var fc = options.flowControl || options.flowcontrol;

if (typeof fc === 'boolean') {
  options.rtscts = true;
} else if (typeof fc === 'string'){
    var fcup = fc.toUpperCase();
    var idx = FLOWCONTROLS.indexOf(fcup);
    if (idx < 0) {
      var err = new Error('Invalid "flowControl": ' + fcup + '. Valid options: ' + FLOWCONTROLS.join(', '));
      callback(err);
      return false;
    } else {

      // "XON", "XOFF", "XANY", "DTRDTS", "RTSCTS"
      switch (idx) {
        case 0: 
			options.rtscts = true; 
		break;
      }
      return true;
    }
}else{
	
    var clean = fc.every(function (flowControl) {
    var fcup = flowControl.toUpperCase();
    var idx = FLOWCONTROLS.indexOf(fcup);
    if (idx < 0) {
      var err = new Error('Invalid "flowControl": ' + fcup + '. Valid options: ' + FLOWCONTROLS.join(', '));
      callback(err);
      return false;
    } else {

      // "XON", "XOFF", "XANY", "DTRDTS", "RTSCTS"
      switch (idx) {
        case 0: 
			options.rtscts = true; 
		break;
      }
      return true;
    }
  });
  if(!clean){
    return;
  }
}

}

Red-Owl avatar Feb 03 '20 20:02 Red-Owl