@@ -574,7 +574,7 @@ To add a new serial device, you must add an object to
574574 }
575575
576576 // Asynchronously call 'getPorts' on all devices and map results back as a series of promises
577- Promise . allSettled (
577+ Promise . all (
578578 devices . map ( ( device ) =>
579579 new Promise ( ( resolve ) => device . getPorts ( resolve ) ) . then (
580580 ( devicePorts , instantPorts ) => ( {
@@ -591,27 +591,15 @@ To add a new serial device, you must add an object to
591591 } )
592592 )
593593 )
594- ) . then ( ( devicePromises ) => {
595- // Reduce the responses to only promises that were fulfilled
596- const successfulPorts = devicePromises . reduce ( ( acc , promise ) => {
597- if ( promise . status === "fulfilled" ) acc . push ( promise . value ) ;
598- return acc ;
599- } , [ ] ) ;
600-
601- portToDevice = devicePromises . reduce ( ( acc , promise ) => {
602- if ( promise . status === "fulfilled" )
603- promise . value . value . forEach (
604- ( port ) => ( acc [ port . path ] = promise . value . device )
605- ) ;
606-
594+ ) . then ( ( results ) => {
595+ portToDevice = results . reduce ( ( acc , promise ) => {
596+ promise . value . forEach ( ( port ) => ( acc [ port . path ] = promise . device ) ) ;
607597 return acc ;
608598 } , { } ) ;
609599
610600 callback (
611- successfulPorts
612- . map ( ( val ) => val . value )
613- . reduce ( ( acc , port ) => acc . concat ( port ) , [ ] ) ,
614- successfulPorts . some ( ( val ) => val . shouldCallAgain )
601+ results . flatMap ( ( result ) => result . value ) ,
602+ results . some ( ( result ) => result . shouldCallAgain )
615603 ) ;
616604 } ) ;
617605 } ;
0 commit comments