export class Promises { param values throws public static async allSettledAndFulfilled < TValue > ( values ) { const results = await Promise . allSettled ( values ) ; const failed = results . filter ( ( res ) => res . status == 'rejected' ) . map ( ( res ) => res as PromiseRejectedResult ) ; if ( failed . length > 0 ) { throw new PromisesError ( failed ) ; } return results ; } } export class PromisesError extends Error { public readonly failedReasons : Array < unknown > ; constructor ( rejectedResults ) { const reasons = rejectedResults . map ( ( res ) => res . reason ) ; super ( reasons . join ( '. ' ) ) ; this . failedReasons = reasons ; } }