mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-24 16:55:22 +03:00
Convert to CommonJS Modules
This commit is contained in:
parent
7df8253099
commit
91f1699659
100 changed files with 9685 additions and 3735 deletions
32
js/connection/connectionFactory.js
Normal file
32
js/connection/connectionFactory.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
'use strict'
|
||||
|
||||
const { ConnectionType } = require('./connection');
|
||||
const ConnectionBle = require('./connectionBle');
|
||||
const ConnectionSerial = require('./connectionSerial');
|
||||
const ConnectionTcp = require('./connectionTcp');
|
||||
const ConnectionUdp = require('./connectionUdp');
|
||||
|
||||
var connectionFactory = function(type, instance) {
|
||||
if (instance && (instance.type == type || instance.connectionId)){
|
||||
return instance;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case ConnectionType.BLE:
|
||||
instance = new ConnectionBle();
|
||||
break;
|
||||
case ConnectionType.TCP:
|
||||
instance = new ConnectionTcp();
|
||||
break;
|
||||
case ConnectionType.UDP:
|
||||
instance = new ConnectionUdp();
|
||||
break;
|
||||
default:
|
||||
case ConnectionType.Serial:
|
||||
instance = new ConnectionSerial();
|
||||
break;
|
||||
}
|
||||
return instance;
|
||||
};
|
||||
|
||||
module.exports = connectionFactory;
|
Loading…
Add table
Add a link
Reference in a new issue