Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function connect(maybePort:string, callback:Function) {
if (maybePort !== TRANSIENT_CONTAINER_IDENTIFIER) {
connect(maybePort);
} else {
console.info('Requesting port...');
Board.requestPort((err, port) => {
if (err) {
throw err;
} else {
console.log(port.comName);
// Remap the connection from transient state to the real port
connectionsByContainer[port.comName] = connectionsByContainer[maybePort];
delete connectionsByContainer[maybePort];
connect(port.comName);
}
});
}
function connect(port) {
console.info('Connecting to port "%s"', port);
const board = new Board(port, function(err) {
if (err) {
connect(
port : ?string,
callback: Result
) {
if (port == null) {
console.info('Requesting port...');
Board.requestPort((error, port) => {
if (error) {
callback(error);
} else {
setup(port.comName, callback);
}
});
} else {
setup(port, callback);
}
},