interface HandledPromises < T > { fulfilled : T [ ] ; rejected : unknown [ ] ; } export const splitAllSettledPromises = < T = unknown > ( promises ) : HandledPromises < T > => promises . reduce ( ( result , current ) => { if ( current . status === 'fulfilled' ) { result . fulfilled . push ( current . value as T ) ; } else if ( current . status === 'rejected' ) { result . rejected . push ( current . reason ) ; } return result ; } , { fulfilled : [ ] , rejected : [ ] , } as HandledPromises < T > ) ;